Posted By

edwinet on 02/02/11


Tagged

sql table template ssms


Versions (?)

SQL Template - Add Column


 / Published in: SQL
 

My Add Column Varchar.sql This template adds a new varchar column to the table.

  1. --==========================================================================
  2. -- Add varchar column template
  3. --
  4. -- This template adds a new varchar column to the table.
  5. --
  6. -- Use the Specify Values for Template Parameters
  7. -- command (Ctrl-Shift-M) to fill in the parameter
  8. -- values below.
  9. --==========================================================================
  10.  
  11. PRINT 'ALTER TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table> ADD <new_column_name, sysname, sample_column> <new_column_datatype,, varchar(50)> <new_column_nullability,, NULL>'
  12. GO
  13. IF NOT EXISTS (SELECT * FROM dbo.syscolumns WHERE id = OBJECT_ID(N'<schema_name, sysname, dbo>.<table_name, sysname, sample_table>') AND name = N'<new_column_name, sysname, sample_column>')
  14. BEGIN
  15. ALTER TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table> ADD
  16. <new_column_name, sysname, sample_column> <new_column_datatype,, varchar(50)> <new_column_nullability,, NULL>
  17. END
  18. GO

Report this snippet  

You need to login to post a comment.