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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-04-11 : 08:47:39
|
| Bob writes "This is probably a silly question, but can I use a stored procedure to as a default value for a field? If so, how? If not, how (to work around)?Thanks,Bob" |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2002-04-11 : 08:58:17
|
quote: ...can I use a stored procedure to as a default value for a field?...
Nope. The DEFAULT argument in a CREATE (or ALTER) TABLE statement requires a constant, NULL, or system function (and I believe in sql2k a user-defined function) to use as the default value for the column.quote: ...how (to work around)?...
I think your best bet would be to define the column with the NULL constraint and then construct a Trigger ON INSERT that sets the value of the column when a value of NULL is inserted.<O> |
 |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-04-11 : 08:58:36
|
you question doesnt puts enough light on what you are seeking . can you elaborate . a example will help a lot.EDIT: someone with more insight and id change understands things more Keep the good work NewBie --------------------------------------------------------------Edited by - Nazim on 04/11/2002 09:01:35 |
 |
|
|
|
|
|