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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Cannot INSERT into a table with incr seed

Author  Topic 

nshovater
Starting Member

6 Posts

Posted - 2009-02-10 : 12:20:44
I have a table with a column I have named "seq" and it takes no NULLS and increments being seed with 1.

I need to daily INSERT new records into the table. I CANNOT. It gives me the error the "seq" field cannot be NULL, which I understand, however, I don't know how to get around it.
I have tried SET IDENTITY_INSERT tbl_InventoryList ON then running it; errored. The only way I am doing it is manually deleting the "seq" column, doing the INSERT and whatever else, then manually adding it back. RIDICULOUS!

Can anyone help please??????

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-02-10 : 12:28:51
So you want your column "seq" to automatic increment and it is an identity column?
Just make your insert witout adressing this colum.
insert table(
seq,
col2,
col3
)
select
null,
value_for_col1,
value_for_col2
from whatever

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

nshovater
Starting Member

6 Posts

Posted - 2009-02-10 : 13:29:50
quote:
Originally posted by webfred

So you want your column "seq" to automatic increment and it is an identity column?
Just make your insert witout adressing this colum.
insert table(
seq,
col2,
col3
)
select
null,
value_for_col1,
value_for_col2
from whatever

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.



BRILLIANT! TOO SIMPLE! Works great, thank you!
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-02-10 : 13:37:14
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -