Return to Snippet

Revision: 40457
at February 23, 2013 02:56 by edwinet


Updated Code
--==========================================================================
-- 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

Revision: 40456
at February 2, 2011 09:43 by edwinet


Initial Code
--==========================================================================
-- Add varchar column template
--
-- This template adds a new varchar column to the table.
--==========================================================================

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

Initial URL

                                

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

Initial Title
SQL Template - Add Column

Initial Tags
sql, table, template

Initial Language
SQL