/ Published in: SQL
My Add Column Varchar.sql
This template adds a new varchar column to the table.
This template adds a new varchar column to the table.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
--========================================================================== -- Add varchar column template -- -- This template adds a new varchar column to the table. -- -- Use the Specify Values for Template Parameters -- command (Ctrl-Shift-M) to fill in the parameter -- values below. --========================================================================== 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>' GO 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>') BEGIN 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> END GO