March 20, 2006 at 1:56 pm
I have a table with an identify column. What happens if you manually insert new rows in that table and increment the identify column manually.. When a new row gets inserted by the application, will it automatically pick up at the next highest number ?
March 20, 2006 at 2:19 pm
To do this you need to use the set identity_insert Tablename on.
Check out Identity_insert in Books online.
March 20, 2006 at 6:43 pm
yes, it will get the next value; here's an example:
create table #tmp (tmpid int identity(1,1) not null primary key,tmptext varchar(30) )
insert into #tmp(tmptext) values('SQL')
insert into #tmp(tmptext) values('SERVER')
insert into #tmp(tmptext) values('ROCKS')
set identity_insert #tmp on
insert into #tmp(tmpid,tmptext) values(99,'YOUR')
insert into #tmp(tmpid,tmptext) values(105,'SOCKS')
set identity_insert #tmp off
insert into #tmp(tmptext) values('OFF')
select * from #tmp
tmpid tmptext
----------- ------------------------------
1 SQL
2 SERVER
3 ROCKS
99 YOUR
105 SOCKS
106 OFF
Lowell
March 21, 2006 at 8:07 am
Thanks much. Basically what I'm doing is DTSing 33 rows from a .csv file to my table - so it doesn't look like I need to set identity insert on.. I just wasn't sure what would happen after the fact : ) but it sounds like I'm good to go
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply