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 |
donchamp
Starting Member
9 Posts |
Posted - 2010-07-05 : 13:24:30
|
I'm executing the following code and it is failing. What am I missing? SET ANSI_NULLS ON GOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGOCREATE TABLE [dbo].[TestDataTable]( [ID] [int] IDENTITY(1,1) NOT NULL, [Code] [varchar](10) NULL, [Description] [varchar](100) NULL, [ParentID] [int] NULL, CONSTRAINT [ID] PRIMARY KEY CLUSTERED( [ID] ASC))GOSET ANSI_PADDING OFF--Insert Data into TestdatatableSET IDENTITY_INSERT [master] . [ dbo ] . TestDataTable ONINSERT INTO TestDataTableSELECT Code, Description, ParentID FROM TEMPTABLE |
|
jeffw8713
Aged Yak Warrior
819 Posts |
Posted - 2010-07-05 : 15:13:34
|
What error are you getting?There is no reason to set identity insert on, unless you are trying to insert a specific identity value. Remove that part, and specify the columns excluding the ID and it will work.Example:INSERT INTO TestDataTable (Code, Description, ParentID)SELECT Code, Description, ParentID FROM TempTable; |
 |
|
|
|
|