|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Default Constraints (call: User-Defined Function or proc)Hi
Have any way to call User-Defined Function or proc of a Default Constraint?? INT CONSTRAINT test_df DEFAULT dbo.myFunc() Thaks According to the SQL BOL, a user-defined function can be used in a DEFAULT
clause. A stored procedure - not that I am aware of. HTH Jerry Show quote "ReTF" <re.tf@newsgroup.nospam> wrote in message news:%23hlZz7LwFHA.624@TK2MSFTNGP11.phx.gbl... > Hi > Have any way to call User-Defined Function or proc of a Default > Constraint?? > > INT CONSTRAINT test_df DEFAULT dbo.myFunc() > > Thaks > Hi
Here is an example of a udf: CREATE FUNCTION SetDate () RETURNS Datetime AS BEGIN DECLARE @Startdate Datetime SET @Startdate = '20050101' RETURN @Startdate END CREATE TABLE MyTest ( id int not null identity(1,1) Primary key, name varchar(10) NOT NULL, StartDate datetime not null default dbo.SetDate(), EndDate datetime not null default getdate()+1 ) INSERT INTO MyTest ( name ) VALUES ( 'John') SELECT * FROM MyTest /* id name StartDate EndDate ----------- ---------- ------------------------------------------------------ ---------------------------1 John 2005-01-01 00:00:00.000 2005-09-25 15:38:48.220 (1 row(s) affected) */ John Show quote "ReTF" <re.tf@newsgroup.nospam> wrote in message news:%23hlZz7LwFHA.624@TK2MSFTNGP11.phx.gbl... > Hi > Have any way to call User-Defined Function or proc of a Default > Constraint?? > > INT CONSTRAINT test_df DEFAULT dbo.myFunc() > > Thaks > |
|||||||||||||||||||||||