Set existing int column, IDENTITY option using T-SQL script 
Author Message
 Set existing int column, IDENTITY option using T-SQL script
Hi,

  Can anyone help.

  I want to enable the Identity option, on an existing int column, using T-SQL.

Thanks,
       Phil



Mon, 01 Dec 2003 18:29:59 GMT
 Set existing int column, IDENTITY option using T-SQL script

You must create a new table to do this...or add a column to an existing
table

--
Wayne Snyder SQL Server MVP
IKON Education Services, C{*filter*}te, NC
(Please Respond to newsgroups)



Mon, 01 Dec 2003 18:59:33 GMT
 Set existing int column, IDENTITY option using T-SQL script
Thanks for your reply.

  I can successfully add a new column using Alter Table.

I.e. I have a table with the following columns

ID
Test

If I remove column ID and then add a new column ID (with Identity) the position of this column would be i.e.

Test
ID

Is there any method within T-SQL to specify the order of the new column?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Mon, 01 Dec 2003 19:24:39 GMT
 Set existing int column, IDENTITY option using T-SQL script
When adding a new column you may NOT specify the column order...
Code should NOT be written which depends on column order either
 no select *
no insert into ... .without a column list...

If your coders DO those things, they will probably have to change
code....You *could* create a view which selects the columns in the order you
prefer however...

--
Wayne Snyder MCSE, MCDBA, SQL Server MVP
IKON Education Services, C{*filter*}te, NC
(Please respond ONLY to newsgroups)

Hi,

  Can anyone help.

  I want to enable the Identity option, on an existing int column, using
T-SQL.

Thanks,
       Phil



Mon, 01 Dec 2003 22:11:22 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. Turning IDENTITY() NOT FOR REPLICATION option on for existing column

2. Script to copy data from one existing column to a new column in another existing table

3. how do I set the identity property on an existing column

4. automatically assigning identity columns using existing data

5. Designating an existing column as Identity column

6. Designating an existing column as Identity column

7. Setting the Next identity value on an IDENTITY column

8. generate sql script & SET options

9. Generate SQL Script for all objects in a database programmatically using TSQL

10. TSQL Update a column if it exists

11. how to set default value for column using script

12. Checking if a Column Exists in TSQL


 
Powered by phpBB® Forum Software