Posted By

edwinet on 02/02/11


Tagged

sql table template ssms


Versions (?)

SQL Template - Drop Column


 / Published in: SQL
 

My Drop Column.sql This template drops a columns of the table.

  1. --==========================================================================
  2. -- Drop column template
  3. --
  4. -- This template drops a columns of 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> DROP <drop_column_name, sysname, sample_column>'
  12. GO
  13. IF EXISTS (SELECT * FROM dbo.syscolumns WHERE id = OBJECT_ID(N'<schema_name, sysname, dbo>.<table_name, sysname, sample_table>') AND name = N'<drop_column_name, sysname, sample_column>')
  14. BEGIN
  15. ALTER TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table> DROP COLUMN
  16. <drop_column_name, sysname, sample_column>
  17. END
  18. GO

Report this snippet  

You need to login to post a comment.