Quantcast
Viewing all articles
Browse latest Browse all 91

Answer by raju chowrsiya for Add a column with a default value to an existing table in SQL Server

step-1. FIRST YOU HAVE TO ALTER TABLE WITH ADD a FIELD

alter table table_name add field field_name data_type

step-2 CREATE DEFAULT

USE data_base_name;
GO
CREATE DEFAULT default_name AS 'default_value';

step-3 THEN YOU HAVE TO EXECUTE THIS PROCEDURE

exec sp_bindefault 'default_name' , 'schema_name.table_name.field_name'

example -

USE master;
GO
EXEC sp_bindefault 'today', 'HumanResources.Employee.HireDate';

Viewing all articles
Browse latest Browse all 91

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>