Dear Friends, I have a Table with one Identity column. I want to insert few records.I want to make off identity and after inserting identity should on in my table.How can I achieve it?Cheers! Siona.
SEEONA, See this.....-- Create #products table.CREATE TABLE #products (id int IDENTITY PRIMARY KEY, product varchar(40))GO-- Inserting values into #products table.INSERT INTO #products (product) VALUES ('aaa')INSERT INTO #products (product) VALUES ('bbb')INSERT INTO #products (product) VALUES ('ccc')INSERT INTO #products (product) VALUES ('ddd')GO-- Create a gap in the identity values.DELETE #products WHERE product = 'ccc'GOSELECT * FROM #products GO-- Attempt to insert an explicit ID value of 3; -- should return a warning.INSERT INTO #products (id, product) VALUES(3, 'ccc')GO-- SET IDENTITY_INSERT to ON.SET IDENTITY_INSERT #products ONGO-- Attempt to insert an explicit ID value of 3INSERT INTO #products (id, product) VALUES(3, 'ccc').GOSELECT * FROM #products GO-- Drop #products table.DROP TABLE #products GO
Sandy,It’s really helpful for me... A Hearty Thanks Sandy... Frank thanks to you 2...Cheers! Seeona.
Seeona, you are always welcome to ask anything related to SQL... I accepted your thanks...Seeona Thank You... Sandy.