c**t 发帖数: 2744 | 1 SQL Server:
create proc prc_Test
@type varchar(20),
@validFrom datetime,
@validTo datetime
as
select blah from SomeTable where type=@type
and somedate between @validFrom and @validTo
exec 'blah blah', DateAdd(dd, -7, GetDate()), GetDate()
Server: Msg 170, Level 15, State 1, Line1
Line1: Incorrect syntax near 'dd'.
but the following statements are correct:
declare @d1 as datetime, @d2 as datetime
set @d1=DateAdd(dd, -7, GetDate())
set @d2=GetDate()
exec 'blah blah', @d1, @d2
what's wrong w | m******y 发帖数: 588 | 2 don't put function in the parameter list of a procedure.
【在 c**t 的大作中提到】 : SQL Server: : create proc prc_Test : @type varchar(20), : @validFrom datetime, : @validTo datetime : as : select blah from SomeTable where type=@type : and somedate between @validFrom and @validTo : exec 'blah blah', DateAdd(dd, -7, GetDate()), GetDate() : Server: Msg 170, Level 15, State 1, Line1
| w*******o 发帖数: 6125 | 3 try exec DateAdd without parenthesis
DateAdd dd, -7....whatever
【在 c**t 的大作中提到】 : SQL Server: : create proc prc_Test : @type varchar(20), : @validFrom datetime, : @validTo datetime : as : select blah from SomeTable where type=@type : and somedate between @validFrom and @validTo : exec 'blah blah', DateAdd(dd, -7, GetDate()), GetDate() : Server: Msg 170, Level 15, State 1, Line1
|
|