rena24 (9/14/2012)
Hello everyone!!!I have a file with these Data -->
H;2334;8989;90;000
L;XXX;YYY;90;000
L;UUU;PPP;78;000
H;4445;855989;90;000
L;AAA;BBB;90;000
L;YYY;TTT;78;000
I want to set a primary Key (gid) to each row in that way -->
1;H;2334;8989;90;000
1;L;XXX;YYY;90;000
1;L;UUU;PPP;78;000
2;H;4445;855989;90;000
2;L;AAA;BBB;90;000
2;L;YYY;TTT;78;000
Is there any way to do this with row number or with an other newer sql command? I dont want to use a cursor (I hate it).
Thanks in advance!!!!
Greetings
Rena
Glad to hear you don't want to use a cursor for a simple update. However, what is your primary key? In your example it looks like you added a column to the beginning with a value that repeats itself 3 times. If you are asking if you can have a primary key column with multiple rows containing the same value I suggest you read about what a primary key is...
If you can explain clearly what you are trying to do we can help. It would probably be best if you post ddl(create table scripts).
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/