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 |
|
ChrisB
Starting Member
6 Posts |
Posted - 2005-11-30 : 12:05:21
|
| I've tried to use exec('set identity_insert <tblnm> on'), but it does not work. It says "The command(s) completed successfully." whenever I'm trying to set it 'off' or when I try to set it 'on' and another table does not have identity_insert on. But, it doesn't actually do anything. Using SET IDENTITY_INSERT <tblnm> ON / OFF always works.Is execute not supposed to be used for SET commands? Any ideas?Thanks,Chris |
|
|
ChrisB
Starting Member
6 Posts |
Posted - 2005-11-30 : 12:53:34
|
| It turns out that you have to do everything within a single EXEC, set identity_insert TblX on, insert TblX, set identity_insert TblX off. All one string, just spaces between commands.Chris |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-12-01 : 05:30:36
|
| When you use Dynamic SQL, you should use all in the same blockEXEC('set identity_insert <tblnm> on'--Do insertion'set identity_insert <tblnm> off')MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|