Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Default Value

Author  Topic 

Easwar
Yak Posting Veteran

59 Posts

Posted - 2007-03-23 : 03:49:59
How to set default value(0) in particular column

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-23 : 03:55:52
Create default and bind it to existing column using sp_bindefault.

Or while creating table,

Create Table <table-name>
(
<column-name> <data-type> Default (<default-value>)
...
)


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Easwar
Yak Posting Veteran

59 Posts

Posted - 2007-03-23 : 04:08:12

I'm already create table. just now add three column.

in three column how set default value...

tell me query.........
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-23 : 04:14:49
I already told how to do it:

Create Default def1 as (0)
Go
exec sp_bindefault def1, 'Table1.col1'
exec sp_bindefault def1, 'Table1.col2'
exec sp_bindefault def1, 'Table1.col3'
GO


And please take some efforts to read the SQL Server help. Just doing copy-n-paste is not going to get you far.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Easwar
Yak Posting Veteran

59 Posts

Posted - 2007-03-23 : 04:21:59
thank u very much sir
Go to Top of Page
   

- Advertisement -