| Author |
Topic  |
|
|
KabirPatel
Yak Posting Veteran
54 Posts |
Posted - 05/14/2007 : 10:26:22
|
Hi,
I have a table with an identity column.
I want to swap 2 of the values in my identity column. To do this I have attempted to get rid of the "IDENTITY" from the column but without success.
Can somebody help?
Thanks in advance Kabir
|
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29156 Posts |
Posted - 05/14/2007 : 10:28:37
|
"Swap"? What are you trying to accomplish?
Peter Larsson Helsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29156 Posts |
Posted - 05/14/2007 : 10:30:30
|
1) SELECT * INTO #TempTable FROM OriginalTable 2) DELETE FROM OriginalTable WHERE ID IN (3, 4) 3) SET IDENTITY_INSERT OriginalTable ON 4) INSERT OriginalTable SELECT 4, ... FROM #TempTable WHERE ID = 3 5) INSERT OriginalTable SELECT 3, ... FROM #TempTable WHERE ID = 4 6) SET IDENTITY_INSERT OriginalTable OFF
Peter Larsson Helsingborg, Sweden |
Edited by - SwePeso on 05/14/2007 11:36:14 |
 |
|
|
KabirPatel
Yak Posting Veteran
54 Posts |
Posted - 05/14/2007 : 10:31:57
|
I have the following values in my table:
ColA ColB ------------ 1 Text A 2 Text B 3 Text C 4 Text D
I want the 3 to become 4, and the 4 to become 3.
Cheers, Kabir |
 |
|
|
madhivanan
Premature Yak Congratulator
India
22469 Posts |
Posted - 05/14/2007 : 10:38:16
|
Where do you want to show data? If you use front end application, do numbering there All you need to do is sort it by colb and number them when displaying
Madhivanan
Failing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
India
22469 Posts |
Posted - 05/15/2007 : 09:29:37
|
Peso, it seems you updated your reply Can you highlight that? 
Madhivanan
Failing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29156 Posts |
Posted - 05/16/2007 : 00:55:05
|
I changed ID {1,2} to {3,4} to avoid confusion...
Peter Larsson Helsingborg, Sweden |
 |
|
| |
Topic  |
|