Groups | Blog | Home
all groups > sql server new users > october 2005 >

sql server new users : SQL Scripting - Create New Column


Jerry Spivey
10/6/2005 3:25:04 PM
Gabe,

You could probably do this using the undocumented stored procedure
SP_MSFOREACHTABLE or SQL-DMO. However, I wouldn't suggest it. I think a
"global" approach like this is asking for trouble...it takes in no account
for your current schema nor how the data will be used.

HTH

Jerry
[quoted text, click to view]

Gabe Matteson
10/6/2005 5:57:16 PM
SQL scripting... is there anyway to create a script that inserts a column
into all the USER tables in a database that is a primary key column, doesn't
allow nulls and identity is set to yes, the seed is 1 and the increment is 1
as well? I am enabling a database for replication and need to create primary
keys in all the tables and since there are quite a lot of tables i rather
script it :) thanks.

AddThis Social Bookmark Button