Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmatically set default value to function? 1

Status
Not open for further replies.

cheyney

Programmer
Jul 16, 2002
335
CA
Hey,

I'm remotely running MSDE and i forgot to set the default value on a table column. How do I set it programmatically?

I've tried this code:

ALTER TABLE tblInventory
{
Alter Column QtyOnHndID
{
set DEFAULT newid()
}
}
go


but i get the folling error:

[Microsoft][ODBC SQL Server Driver]Syntax error or access violation


any ideas?

cheyney
 
According to BOL the following should be valid

alter table tblInventory
add constraint QtyOnHndIDDefault
default newid()
for QtyOnHndID



ALTER TABLE tblInventory
Alter Column QtyOnHndID
set DEFAULT newid()

is the ANSI SQL syntax, which SQL server does not support.
 
awesome, thanks...don't know why i couldn't find that

cheyney
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top