SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Why doesn't Identy insert work
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Vinnie881
Flowing Fount of Yak Knowledge

USA
1222 Posts

Posted - 08/03/2007 :  14:42:47  Show Profile  Reply with Quote

begin
set identity_insert SpProductionDB.dbo.TSTD_ShortTermDisabilityCheck on
insert into SpProductionDB.dbo.TSTD_ShortTermDisabilityCheck
select * 
from SpProductionDBBak.dbo.TSTD_ShortTermDisabilityCheck
set identity_insert SpProductionDB.dbo.TSTD_ShortTermDisabilityCheck off
end


Why does this not work, I am getting this error

**
Msg 8101, Level 16, State 1, Line 3
An explicit value for the identity column in table 'SpProductionDB.dbo.TSTD_ShortTermDisabilityCheck' can only be specified when a column list is used and IDENTITY_INSERT is ON.
**

Vinnie881
Flowing Fount of Yak Knowledge

USA
1222 Posts

Posted - 08/03/2007 :  14:44:51  Show Profile  Reply with Quote
Turns out I just needed to write out the column names
Go to Top of Page

KenW
Constraint Violating Yak Guru

USA
391 Posts

Posted - 08/03/2007 :  16:19:01  Show Profile  Reply with Quote
For future reference,

quote:

an only be specified when a column list is used



Means that you need to write out the column names.
Go to Top of Page

DonAtWork
Flowing Fount of Yak Knowledge

2161 Posts

Posted - 08/06/2007 :  07:15:25  Show Profile  Reply with Quote
Can we add this to our collection of "Why you do NOT use 'Select *'" ?

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

pootle_flump
Flowing Fount of Yak Knowledge

United Kingdom
1064 Posts

Posted - 08/06/2007 :  09:57:44  Show Profile  Reply with Quote
quote:
Originally posted by DonAtWork

Can we add this to our collection of "Why you do NOT use 'Select *'" ?

It could have been worse - there might not have been an identity column and it might have worked
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000