Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identity Insert 1

Status
Not open for further replies.

travisbrown

Technical User
Dec 31, 2001
1,016
What's wrong with this statement?

Code:
SET IDENTITY_INSERT  dbo.tbl_tickets ON
INSERT INTO tbl_tickets
SELECT ticket_id, ticket_number, ticket_district, NULL, ticket_start_ts, ticket_user, ticket_notes, ticket_emergent, ticket_called_manager
FROM COPs.dbo.tblDispatchTicket
SET IDENTITY_INSERT dbo.tbl_tickets OFF

I get
"An explicit value for the identity column in table 'tbl_tickets' can only be specified when a column list is used and IDENTITY_INSERT is ON."

However, I thought I was turning ID_INSERT on.

 
Oh, I just reread the error. Is it where I have to specify the input columns in parentheses following the input table name?
 
Ah, see what happens when I don't panic and read the error?

Code:
SET IDENTITY_INSERT  dbo.tbl_tickets ON
INSERT INTO tbl_tickets
   (ticket_id, ticket_number, ticket_group, ticket_class, ticket_start_ts, ticket_dispatcher, ticket_dispatcher_note, ticket_emergent, ticket_call_manager)
SELECT ticket_id, ticket_number, ticket_district, NULL, ticket_start_ts, ticket_user, ticket_notes, ticket_emergent, ticket_called_manager
FROM COPs.dbo.tblDispatchTicket
SET IDENTITY_INSERT dbo.tbl_tickets OFF
 
now have fun accidentally leaving identity_insert on for some random table in your database... then try to set it on for another.

Now you have to find out which one has it on, or run script to set it off for all of them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top