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
 auto number filed insert problem

Author  Topic 

mitasid
Yak Posting Veteran

51 Posts

Posted - 2006-06-07 : 21:38:57
i am trying to insert an auot number field in my table which has got about million rows but sql 2005 is giving me na error "cant insert"
i need to index my table so that the query runs faster when i perform joins on two of such huge tables..
i tryid inserting the identity key the way it was mentioned in the forum but sql doesnt let me do that??

pls help

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-06-07 : 21:47:47
which post?

did you 'set identity_insert tablename ON'?



--------------------
keeping it simple...
Go to Top of Page

mitasid
Yak Posting Veteran

51 Posts

Posted - 2006-06-07 : 21:51:56
i guess i did not do that..i just set identity specification to "yes"
how do i do that??
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-06-07 : 22:11:21
before you start inserting data with the identity values
issue: set identity_insert tablename on

i don't understand your question , sorry

--------------------
keeping it simple...
Go to Top of Page

mitasid
Yak Posting Veteran

51 Posts

Posted - 2006-06-07 : 22:13:40
my question is
how do i set identity_insert tablename on?? where is this option??

pls explain

thanks
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-06-07 : 22:28:18
open query analyzer or ssms then new query,

type that command
your query
type the command but set it to off

run the query

--------------------
keeping it simple...
Go to Top of Page

mitasid
Yak Posting Veteran

51 Posts

Posted - 2006-06-07 : 23:11:41
thanks for your help jen.
but i still cant understand wat u mean..i am having trouble inserting an auto number field in my table i..i am soing it in the design mode of the table.. icant find the option you suggested me...
i am really sorry if i am troubling you ..
ut can u explain me in detail about that option(identity_insert)??????
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-06-07 : 23:41:27
ok... let's start over again...

set the identity specification you mentioned in your post to NO, instead of yes (click on NO for isIdentity)

--------------------
keeping it simple...
Go to Top of Page

mitasid
Yak Posting Veteran

51 Posts

Posted - 2006-06-07 : 23:54:41
ok did that..sql has accepted that but in the new column,all the values are null.....there is no numbers in it!!
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-06-08 : 01:39:36
it's just like a switch, once you're done with inserting the values you can turn it back on
unless you'll be doing this as part of your business policy, then
i suggest you create a constraint on that column, generate your own identity values and not make it an identity column

it's really the concept that you should be learning

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -