Click here to Skip to main content
15,886,758 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
Create function [dbo].[ISDOB](@colname VarChar(100))
RETURNS VarChar(100)
as
BEGIN
DECLARE @From_Date date = '1980-01-01';
 DECLARE @To_Date date = getdate();
 DECLARE @REC_Date date = @colname;
 IF  @REC_Date > @From_Date AND @REC_Date < @To_Date
  return 1;
  return 0;
 END




Im getting an error like this in sql 2005" Msg 156, Level 15, State 1, Procedure ISDOB, Line 4
Incorrect syntax near the keyword 'DECLARE"'.How can i solve this error..please reply me...urgnetly needed..
Posted

1 solution

What you need to do is go into SQL Management Studio, right-click on Functions and choose New Multi-Statement Table Valued Function.

Regular functions don't support anything but returning data. They don't support extra lines like you are trying to do.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900