SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Can i use Default in Alter Statements


Can i use Default in Alter Statements

Author
Message
Pulivarthi Sasidhar
Pulivarthi Sasidhar
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1696 Visits: 1021
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.......
Pulivarthi Sasidhar
Pulivarthi Sasidhar
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1696 Visits: 1021
I got solution......... :-D:-D

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
Paul White
Paul White
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16266 Visits: 11355
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
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search