Groups | Blog | Home
all groups > sql server msde > september 2007 >

sql server msde : Alter using osql


Ryan
9/13/2007 3:16:02 PM
Currently, PaymentDate in my table is a SMALLDATETIME and NULL is allowed. I
would like to alter PaymentDate column to be NOT NULL and set its default
value to current date.
I am using the following osql command but it generated an error; could
someone please help?

Jonathan Psaila-Depasquale
9/14/2007 12:00:00 AM
Hi,

You have to do it in two commands and anyway the command is actually
ALTER TABLE. So try the following:


alter table mydb.dbo.mytable
alter column paymentdate smalldatetime not null

alter table mydb.dbo.mytable
add constraint paymentdate_def default getdate() for paymentdate


Jonathan



[quoted text, click to view]
Ryan
9/17/2007 6:56:00 AM
Thanks, it worked.

[quoted text, click to view]
AddThis Social Bookmark Button