SQL Template - Drop Column


/ Published in: SQL
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.