Home > DeveloperSection > Forums > How to set default value for all tables column in SQL Server?
jayprakash sharma
jayprakash sharma

Total Post:117

Points:821
Posted on    May-04-2013 2:09 AM

 MSSQL Server MSSQL Server 
Ratings:


 1 Reply(s)
 835  View(s)
Rate this:
Hi!

How to set default value for all tables column in SQL Server?

If it is string it will empty and if it is int in already created table.

Thanks in advance!


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    May-04-2013 9:05 AM

Hi Jayprakash!

Add DEFAULT constraint

Here is the way to do it:

CREATE TABLE Persons
(
id int NOT NULL,
LName varchar(25) NOT NULL,
FName varchar(25),
Addr varchar(255),
City varchar(255) DEFAULT 'Hawaii'
)

I hope it solve your problem!


Don't want to miss updates? Please click the below button!

Follow MindStick