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
 Site Related Forums
 Article Discussion
 Article: How to Insert Values into an Identity Column in SQL Server

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-08-06 : 08:13:54

Identity columns
are commonly used as primary keys in database tables.  These columns
automatically assign a value for each new row inserted.  But what if you
want to insert your own value into the column?  It's actually very easy to
do.



Read How to Insert Values into an Identity Column in SQL Server

JLibertor
Starting Member

3 Posts

Posted - 2007-08-06 : 16:25:56
Oh man! I was JUST looking for this the other day!

I had resported to all sorts of unsavory deeds to get this done. This is a much better solution.

Go to Top of Page

KBM
Starting Member

4 Posts

Posted - 2007-08-21 : 03:26:41
I was looking for that as well, no just one more thing and I am home free.

How do you ignore constraints and triggers? The I can upsize my data from access without using the upsizing wizard and have my tables set up correctly right out the gate.
Go to Top of Page

mohit_sme
Starting Member

13 Posts

Posted - 2007-08-22 : 13:07:36
Great, this is really useful. DBCC CHECKIDENT is another useful utility to work with IDENTITY columns.

Thanks
Mohit Nayyar
http://mohitnayyar.blogspot.com/

Thanks
Mohit Nayyar
http://mohitnayyar.blogspot.com
Go to Top of Page

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2007-08-22 : 13:28:39
KBM, you can disable constraints and triggers but I'm not sure you can ignore them. You'd have to disable them, do the insert and then enable them.

===============================================
Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page

KBM
Starting Member

4 Posts

Posted - 2007-08-22 : 16:44:05
Graz, Can you disable them Globally or do you have to do each one specifically?
Go to Top of Page

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2007-08-22 : 16:59:31
You have to do it per constraint as far as I know. I'd go through books online on constraints for more details. There may be an option to ignore constraints buried in BULK INSERT or the SSIS bulk insert task. If there is I don't remember it.

===============================================
Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page
   

- Advertisement -