Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programatically set Default Values for all fields
Message
 
 
To
01/06/2007 10:25:31
Aman Bains
Jaguar Computers
Jalandhar, India
General information
Forum:
Microsoft SQL Server
Category:
Database design
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01229752
Message ID:
01229808
Views:
18
You can bind defaults using sp_bindefault stored procedure but it's depricated and will be removed in a future version of SQL Server. It's recomended to add DEFAULT constrains using CREATE/ALTER TABLE
-- Unnamed, SQL Server will generate name
ALTER TABLE mytable
ADD 
DEFAULT ('')
FOR mycolumn
-- named
ALTER TABLE mytable
ADD 
CONSTRAINT whatever 
DEFAULT ('')
FOR mycolumn
>See all the 0 Defaults are shown in defaults as UW_ZeroDefault whereas String Defaults of " " are being converted as table/field name (e.g. Dflt_acbal_sess, Dflt_acbal_accnum) for each field. I could have created a single default as
>
>
>USE [au4]
>GO
>CREATE DEFAULT [dbo].[Dflt_SpaceDefault] AS ''
>
>
>I could have applied thew same default in all fields. Also I need to apply defaults to all the fields programatically and not manually one by one.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform