|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Today @ 10:44 AM
Points: 140,
Visits: 326
|
|
Hi All
Most off our tables have rowversion columns. We whant this row version to be unique through out the DB. But as per msdn site it syas that rowverison can get deuplicated if "SELECT INTO " command is used?
Is there any way that we can use "SELECT INTO" and still avaoid rowversion dupllication?
Regards Shilpa
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Monday, June 10, 2013 4:11 AM
Points: 1,474,
Visits: 2,344
|
|
It's only duplicated if the rowversion column is included in the column list of the select into statement. Don't do that, and your values will stay unique.
Cheers
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Thursday, June 13, 2013 7:03 AM
Points: 2,562,
Visits: 3,453
|
|
shilpaprele (1/14/2013) Is there any way that we can use "SELECT INTO" and still avaoid rowversion dupllication? YEs you can try like
select "all coumns except rowversion column " into newtable from oldtable then
alter table newtable add rowverison column The above is just code hint not the actual sql code
-------Bhuvnesh---------- While 1 = 1 (Learning SQL....) Click to get fast response of your post
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Friday, June 14, 2013 8:33 AM
Points: 1,402,
Visits: 6,950
|
|
SELECT INTO creates the target table, and the only exception along the lines that you are after is with the IDENTITY column. You could leave the Rowversion column out, as already suggested but we don't know the size of the tables concerned so altering the schema may be a large overhead.
Why not create the target table first and then use INSERT INTO? That will allow what you require.
CREATE TABLE Test1( Col1 rowversion, col2 VARCHAR(20) );
CREATE TABLE Test2( Col1 rowversion, col2 VARCHAR(20) );
INSERT INTO Test1(col2) VALUES( 'test1'),( 'test2')
INSERT INTO test2(col2) SELECT Col2 FROM Test1
SELECT * FROM test1; SELECT * FROM test2;
BrainDonor Linkedin
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Today @ 10:44 AM
Points: 140,
Visits: 326
|
|
Thanks all for your replies. I agree that we should exclude row version column but there my be many developers working on the DB. And if sombody uses the select into then we will have dupliction.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Thursday, June 13, 2013 7:03 AM
Points: 2,562,
Visits: 3,453
|
|
shilpaprele (1/16/2013) there may be many developers working on the DB. And if sombody uses the select into then we will have dupliction. and this cant be get restricted or stopped , so you should make them understand that why and what needs to follow ?
-------Bhuvnesh---------- While 1 = 1 (Learning SQL....) Click to get fast response of your post
|
|
|
|