Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Can i use Default in Alter Statements Expand / Collapse
Author
Message
Posted Tuesday, April 20, 2010 12:42 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, December 15, 2014 11:14 PM
Points: 1,085, Visits: 721
hi,

I am having a table. which is taking by default NULL values...

Now i want to update the Column default to'XXXX'
Script:-

CREATE TABLE [dbo].[Testowners](
[owner_id] [int] NULL,
[owname] [varchar](15) NULL
)


Alter Script 1:-
ALTER TABLE Owners
ALTER Column [owner_id] INT NOT NULL

Alter Script 2:-
ALTER TABLE Owners
ALTER Column owname VARCHAR(35) Default 'XX'

The first Alter Statement is working fine.
Cant i use the Default in Alter statement ....

Thnaks in advance.......
Post #906571
Posted Tuesday, April 20, 2010 12:54 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, December 15, 2014 11:14 PM
Points: 1,085, Visits: 721
I got solution.........

ALTER Table Owners
ADD CONSTRAINT con_owname DEFAULT 'XXX' FOR owname

But Y dont we use Default in the Alter statement. Event the below link shows it in Syntax...by SET Default...

http://msdn.microsoft.com/en-us/library/ms174123.aspx


Post #906576
Posted Tuesday, April 20, 2010 5:43 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 5:25 AM
Points: 9,928, Visits: 11,204
That is the Books Online entry for SQL Server Compact 3.5 Service Pack 1.
You want the SQL Server 2008 entry:
http://msdn.microsoft.com/en-us/library/ms190273.aspx




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #906727
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse