消息156,级别15,状态1,过程ISDOB,第4行关键字'DECLARE'附近的语法不正确。 [英] Msg 156, Level 15, State 1, Procedure ISDOB, Line 4 Incorrect syntax near the keyword 'DECLARE'.

查看:67
本文介绍了消息156,级别15,状态1,过程ISDOB,第4行关键字'DECLARE'附近的语法不正确。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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









我在sql 2005中收到这样的错误消息156,级别15,状态1,过程ISDOB,第4行

关键字'DECLARE附近的语法不正确'。我怎么能解决这个错误..请回复我...需要...

推荐答案

你需要做的是进入SQL Management Studio,右键单击Functions并选择New Multi-Statement Table Valued Function。



常规函数除了返回数据外不支持任何操作。它们不像你想要的那样支持额外的行。
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.


这篇关于消息156,级别15,状态1,过程ISDOB,第4行关键字'DECLARE'附近的语法不正确。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆