June 2, 2004 at 10:08 am
I have
CREATE TABLE [dbo].[File] (
[FileID] [int] IDENTITY (1, 1) NOT NULL ,
....,
....
I need to insert 20 records
from 'restore_file' table
Of course it'll give me an error
so I try to remove IDENTITY option
in EM in table Design.
But it hangs and and freezes EM.
I have to close MMC.
[File] table has 44000 records.
FIELD 'FileBinary' stores Binary data.
I was wondering if there is a
a short command to DISABLE IDENTITY?
June 2, 2004 at 11:55 am
Yes, but you'll have to issue it in Query Analyzer not Enterprise Manager. Make certain that any insert queries running while you have it turned off are inserting an identity or it will fail. This is a connection level setting, so it only affects the queries you are running as part of that connection. In other words, identity insert will still be off for other users.
SET IDENTITY_INSERT ON
Insert Query .....
SET IDENTITY_INSERT OFF
June 2, 2004 at 8:10 pm
Rawhides answer is almost exact, but you need to specify the table name as well
set identity_insert dbo.File on
'now insert your rows
set identity_insert dbo.File off
should allow you to do it.
Cheers
Al
June 2, 2004 at 8:25 pm
How dare you correct me!!!
Just kidding. Thanks, I did leave a very important part out.
June 2, 2004 at 8:35 pm
I didn't correct, I just added to it
June 3, 2004 at 7:05 am
Thank you all guys for
your response.
Just to be completely clear about
the command...
So if I 'm connected in Query Analyzer
as "user51" and turn IDENTITY INSERT
ON and then I open another
QA window and run INSERT
am I still affected by command from
the first window?
In other words is connections based
or user based?
June 3, 2004 at 8:09 am
It must be done in the same QA window in which you executed the SET IDENTITY_INSERT statement.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply