这段SQL SERVER的存储过程的语法有什么错误?我怎么查不出来了.(20分)

  • 主题发起人 主题发起人 liuyang
  • 开始时间 开始时间
L

liuyang

Unregistered / Unconfirmed
GUEST, unregistred user!
CREATE PROCEDURE p_sxr @intyear char(4)
AS
declare @varday datetime
declare @varstring varchar(20)
delete from jjr where year(rq ) = @intyear and lx = 0
@varstring = "01/" | "01/" | convert(char(4) , @intyear)
@varday = convert(datetime,@varstring)
GO

检查语法的时候总提示 @varstring 附近有语法错误
 
@varstring = "01/" | "01/" | convert(char(4) , @intyear)
~~~~ ~~~
你这个|符号是什么意思,好象标准的sql语法中,没这操作符
 
CREATE PROCEDURE p_sxr (@intyear int)
AS
declare @varday datetime
declare @varstring varchar(20)
delete from jjr where year(rq ) = @intyear and lx = 0
set @varstring = '01/' + '01/' +convert(char(4) , @intyear)
set @varday = convert(datetime,@varstring)
GO
 
呵呵,我也没见过这个东东。("01/" | "01/" | convert(char(4) , @intyear))
不过,变量付值好象要用SET 吧。
set @varstring = '01/01/' + convert(char(4) , @intyear)
set @varday = convert(datetime,@varstring)
 
参照一下
CREATE PROCEDURE TollOperation_add
(
@fvtype_id varchar(6),
@operation smallint,
@fvid_b varchar(20),
@fvid_e varchar(20),
@taker varchar(10),
@operateid int output
)
as
begin tran
insert into tolloperation (fvtypeid,operation,fvid_begin,fvid_end,taker)values(@fvtype_id,@operation,@fvid_b,@fvid_e,@taker)
select @operateid= @@IDENTITY
commit tran

GO
 
多人接受答案了。
 
后退
顶部