完整语句如下:
CREATE PROCEDURE ClassJustify @CODE INT(5)asDECLARE @STR NVARCHAR(1000)SET @STR="SELECT DATEDIFF([day],
(SELECT DATEADD([day],
(SELECT moneyterm
FROM customer
WHERE code = ('@CODE')),
(SELECT developedate
FROM customer
WHERE (code = '@CODE')))), CONVERT(varchar(10), GETDATE(), 120))"if(@STR>=30)
begin
update customer set classjustify = 3
end
else if (@STR>=0)
begin
update customer set classjustify = 2
end
else if (@STR>-5)
begin
update customer set classjustify = 1
end
else
update customer set classjustify = 0go昨晚边看书,边写的,可能有些问题,请大虾们指出!如果我想用javascript调用这个存储过程应该怎么办呢?
CREATE PROCEDURE ClassJustify @CODE INT(5)asDECLARE @STR NVARCHAR(1000)SET @STR="SELECT DATEDIFF([day],
(SELECT DATEADD([day],
(SELECT moneyterm
FROM customer
WHERE code = ('@CODE')),
(SELECT developedate
FROM customer
WHERE (code = '@CODE')))), CONVERT(varchar(10), GETDATE(), 120))"if(@STR>=30)
begin
update customer set classjustify = 3
end
else if (@STR>=0)
begin
update customer set classjustify = 2
end
else if (@STR>-5)
begin
update customer set classjustify = 1
end
else
update customer set classjustify = 0go昨晚边看书,边写的,可能有些问题,请大虾们指出!如果我想用javascript调用这个存储过程应该怎么办呢?
@mt int(10), @dt varchar(10), @data varchar(10)
SET @mt = [SELECT moneyterm
FROM customer
WHERE code = '00018']
SET @dt = [SELECT developedate
FROM customer
WHERE code = '00018']
SET @data = [CONVERT(varchar(10), GETDATE(), 120)]
SET @STR = [SELECT DATEDIFF(day,(SELECT DATEADD(day, @mt, @dt)), @data]
IF (@STR >=30)
UPDATE customer SET classjustify = 3
ELSE IF (@STR >= 0)
UPDATE customer SET classjustify = 2
ELSE IF (@STR > - 5)
UPDATE customer SET classjustify = 1
ELSE
UPDATE customer SET classjustify = 0 go
AS
begin
DECLARE @STR NVARCHAR(10), @mt int(10), @dt varchar(10), @data varchar(10)
SELECT @mt = moneyterm
FROM customer
WHERE code = '00018'
SELECT @dt = developedate
FROM customer
WHERE code = '00018'
SET @data = CONVERT(varchar(10), GETDATE(), 120)
SET @STR = DATEDIFF(day,(DATEADD(day, @mt, @dt)), @data)
IF (@STR > =30)
UPDATE customer SET classjustify = 3
ELSE IF (@STR > = 0)
UPDATE customer SET classjustify = 2
ELSE IF (@STR > - 5)
UPDATE customer SET classjustify = 1
ELSE
UPDATE customer SET classjustify = 0
end
(SELECT DATEADD([day],
( SELECT code
FROM t
WHERE code ='+ @STR +'
),
(SELECT code
FROM t
WHERE code ='+ @STR +'
)
)),
CONVERT(varchar(10), GETDATE(), 120)
) '
if(@STR> =30)
begin
update customer set classjustify = 3
end
else if (@STR> =0)
begin
update customer set classjustify = 2
end
else if (@STR> -5)
begin
update customer set classjustify = 1
end
else
update customer set classjustify = 0
@CODE INT(5) --参数或变量: 不能对数据类型 int 指定列宽。
只能是 @CODE INT 才是正确的CREATE PROCEDURE ClassJustify
@CODE INT -- @CODE INT(5) 这个是错的 (@CODE INT 才是正确的 )
as
DECLARE @STR int-- DECLARE @STR NVARCHAR(1000) SET @STR='SELECT DATEDIFF([day],
(SELECT DATEADD([day],
( SELECT moneyterm
FROM customer
WHERE code ='+ @STR +'
),
(SELECT developedate
FROM customer
WHERE code ='+ @STR +'
)
)),
CONVERT(varchar(10), GETDATE(), 120)
) '
if(@STR> =30)
begin
update customer set classjustify = 3
end
else if (@STR> =0)
begin
update customer set classjustify = 2
end
else if (@STR> -5)
begin
update customer set classjustify = 1
end
else
update customer set classjustify = 0