Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
KabirPatel
Yak Posting Veteran
54 Posts |
Posted - 2007-05-14 : 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 advanceKabir |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-05-14 : 10:28:37
|
"Swap"?What are you trying to accomplish?Peter LarssonHelsingborg, Sweden |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-05-14 : 10:30:30
|
1) SELECT * INTO #TempTable FROM OriginalTable2) DELETE FROM OriginalTable WHERE ID IN (3, 4)3) SET IDENTITY_INSERT OriginalTable ON4) INSERT OriginalTable SELECT 4, ... FROM #TempTable WHERE ID = 35) INSERT OriginalTable SELECT 3, ... FROM #TempTable WHERE ID = 46) SET IDENTITY_INSERT OriginalTable OFFPeter LarssonHelsingborg, Sweden |
|
|
KabirPatel
Yak Posting Veteran
54 Posts |
Posted - 2007-05-14 : 10:31:57
|
I have the following values in my table:ColA ColB------------1 Text A2 Text B3 Text C4 Text DI want the 3 to become 4, and the 4 to become 3. Cheers,Kabir |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-05-14 : 10:38:16
|
Where do you want to show data?If you use front end application, do numbering thereAll you need to do is sort it by colb and number them when displayingMadhivananFailing to plan is Planning to fail |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-05-15 : 09:29:37
|
Peso, it seems you updated your replyCan you highlight that? MadhivananFailing to plan is Planning to fail |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-05-16 : 00:55:05
|
I changed ID {1,2} to {3,4} to avoid confusion...Peter LarssonHelsingborg, Sweden |
|
|
|
|
|
|
|