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 |
|
wleonard
Starting Member
30 Posts |
Posted - 2011-01-20 : 17:01:06
|
| SELECT GETDATE ()DECLARE @presentdate DATETIMEDECLARE @futuredate DATETIMESET @futuredate = (SELECT startdate FROM Shipping_Promo_Date_Select_Test)if @futuredate = (SELECT GETDATE ()) DELETE FROM Shipping_Discount_Test INSERT INTO Shipping_Discount_Test SELECT * FROM Shipping_Discount_Future_TestI receive the following error:Msg 8101, Level 16, State 1, Line 11An explicit value for the identity column in table 'Shipping_Discount_Test' can only be specified when a column list is used and IDENTITY_INSERT is ON.What does this mean and how do I correct it?Will Leonard |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
Skorch
Constraint Violating Yak Guru
300 Posts |
Posted - 2011-01-20 : 17:08:17
|
| It means your Shipping_Discount_Test table has an IDENTITY column. Two ways of getting around this:SET IDENTITY_INSERT Shipping_Discount_Test ON;Then rather than inserting using SELECT * FROM... provide the entire list of columns that will be going to the table.Another way of doing this is since you're deleting the entire table anyway, drop the table and use INSERT INTO to recreate it from your Shipping_Discount_Future_Test data. However only do this if the structures of the two tables match.Some days you're the dog, and some days you're the fire hydrant. |
 |
|
|
|
|
|