Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tsql:add_a_column_to_a_table [2015/04/24 21:32]
richard created
tsql:add_a_column_to_a_table [2017/07/21 21:47] (current)
Line 2: Line 2:
  
 This temporary SP adds a column to a table, with a couple of extra features: This temporary SP adds a column to a table, with a couple of extra features:
-  * if the column already exists, ​it returns without action or error; +  * if the column already exists, ​the SP returns without action or error; 
-  * the column can be created NOT NULL be specifying an initial value (but the constraint used to permit this when adding ​the column is dropped ​automatically).+  * the column can be created NOT NULL be specifying an initial value. This is specified as a default value to add and populate ​the column, after which the constraint ​is automatically ​dropped.
  
 <code tsql>IF OBJECT_ID('​tempdb..#​spAddColumn'​) IS NOT NULL <code tsql>IF OBJECT_ID('​tempdb..#​spAddColumn'​) IS NOT NULL
Line 56: Line 56:
 </​code>​ </​code>​
  
-{{tag> }}+{{tag> ​tsql dynamic development}}
 ~~DISCUSSION~~ ~~DISCUSSION~~