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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 insert into problem

Author  Topic 

bobz_0585
Yak Posting Veteran

55 Posts

Posted - 2009-05-17 : 07:34:32
i have a table for which the creating script is:
CREATE TABLE [dbo].[Updates_table](
[node code] [nvarchar](50) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL,
[Team_number] [nvarchar](10) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL,
[Status] [nvarchar](56) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL,
[Notes] [nvarchar](500) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL,
[is_assigned] [bit] NOT NULL,
[Activity] [nvarchar](50) COLLATE SQL_Latin1_General_CP1256_CI_AS NULL,
[is_other] [bit] NOT NULL,
[id] [int] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]

when i run this insert comand:
Insert into updates_table 
select [node code],IC,status,[client name],IC,status,IC
from dbo.remote_list_view() f1 order by glallocationid desc


whene ever i run the previos query i get this error

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

what am i doing wrong..i tried adding set identity_insert on before the query but i made no deferance

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-05-17 : 09:07:20
because you're not specifying a columnlist in insert its assuming you're trying to pass a value for identity column as well and hence the error. you should use a column list if you're not passing value for all the columns. so insert should be


Insert into updates_table ([node code],[Team_number],[Status],[Notes],[is_assigned],[Activity],[is_other])
select [node code],IC,status,[client name],IC,status,IC
from dbo.remote_list_view() f1 order by glallocationid desc
Go to Top of Page

bobz_0585
Yak Posting Veteran

55 Posts

Posted - 2009-05-17 : 09:20:00
thank you man it is working ..its wierd it was working before and suddenly it stopped thanks man..
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-05-17 : 09:26:17
welcome
Go to Top of Page
   

- Advertisement -