由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 这个stored proc错在哪里?
相关主题
今夭的面试题SSIS: execute SQL task failed on Insert statements
请教:sql, 同时得出count_lastweek & count_allquery analyzer VS. Stored procedure
测一下你的t-sql 功力Access中有如substring和dateadd的函数是什么?
包子谢,怎么加个table到一个function里求助access大牛
select 跟 set 的区别?A question of filling in missing value in SQL
再请教大牛一个问题TSQL中如何计算 moving avg and stdev
date format转换问题请教Need help with an oracle SQL expression
SQL Server - convert datetime to a string YY-MM-DD HHsql面试题2
相关话题的讨论汇总
话题: getdate话题: datetime话题: blah话题: dateadd话题: d1
进入Database版参与讨论
1 (共1页)
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

1 (共1页)
进入Database版参与讨论
相关主题
sql面试题2select 跟 set 的区别?
请问sql server里面怎么输出变量到文本文件?再请教大牛一个问题
sybase 问题请教date format转换问题请教
SQL Server 如何把日期自动加入文件名中?SQL Server - convert datetime to a string YY-MM-DD HH
今夭的面试题SSIS: execute SQL task failed on Insert statements
请教:sql, 同时得出count_lastweek & count_allquery analyzer VS. Stored procedure
测一下你的t-sql 功力Access中有如substring和dateadd的函数是什么?
包子谢,怎么加个table到一个function里求助access大牛
相关话题的讨论汇总
话题: getdate话题: datetime话题: blah话题: dateadd话题: d1