Technical Article

SQL Script to generate columns for triggers

,

Ever needed a quick way to generate insert or select columns for a table? All you have to do is replace the 'Tablename' with your tablename. So just cut and paste the results, also the most important step is to remove the comma after the last column. (i.e.

insert tablename(

Field1,

Field2,

Field3,)

should be

insert tablename(

Field1,

Field2,

Field3)

select name + ',' from sys.columns where object_name(object_id)='Tablename' order by column_id

Rate

1.33 (3)

You rated this post out of 5. Change rating

Share

Share

Rate

1.33 (3)

You rated this post out of 5. Change rating