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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Alter table issue...

Author  Topic 

companionz
Yak Posting Veteran

54 Posts

Posted - 2009-09-14 : 12:21:45
Hi,

Alter table not working (SQL 2005)

ALTER TABLE dbo.test ALTER COLUMN LastUpdateDate SET DEFAULT getdate()


Getting error : "Incorrect syntax near the keyword 'SET'."


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-09-14 : 13:05:03
it should be

ALTER TABLE dbo.test ALTER COLUMN LastUpdateDate datetime DEFAULT getdate()
Go to Top of Page

companionz
Yak Posting Veteran

54 Posts

Posted - 2009-09-15 : 03:28:49
Now getting this error:

Incorrect syntax near the keyword 'DEFAULT'.
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-09-15 : 04:03:32
alter table test add constraint constraintname default (getdate()) for LastUpdateDate
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-09-16 : 13:29:18
quote:
Originally posted by companionz

Now getting this error:

Incorrect syntax near the keyword 'DEFAULT'.



ALTER TABLE dbo.test

ALTER COLUMN LastUpdateDate datetime NOT NULL

CONSTRAINT AddDateDflt

DEFAULT getdate()
Go to Top of Page
   

- Advertisement -