遇到一个问题
select * from a where a.jhdate in('206-9-7','2006-9-11')
这个语句可以执行但我在存储过程中写select * from a where a.jhdate in (@newdate)
在sql2000查询分析器中赋值@newdate='2006-9-7'时候能正确执行
但当我给@newdate 赋值 '206-9-7','2006-9-11'这种形式时候就出错,
哪位能指点一下
select * from a where a.jhdate in('206-9-7','2006-9-11')
这个语句可以执行但我在存储过程中写select * from a where a.jhdate in (@newdate)
在sql2000查询分析器中赋值@newdate='2006-9-7'时候能正确执行
但当我给@newdate 赋值 '206-9-7','2006-9-11'这种形式时候就出错,
哪位能指点一下
insert @t
select '2006-9-7' union all
select '2006-9-8' union all
select '2006-9-11' union all
select '2006-9-12' declare @str varchar(100)
set @str = '2006-9-7,2006-9-11'
select * from @t where charindex(',' + replace(convert(varchar(10),jhdate,120),'-0','-') + ',',',' + @str + ',') > 0
CREATE PROCEDURE [Get_Planinfo]
(
@newdate [nvarChar] (100)
)
AS
SELECT *
FROM CKCM_PLAN
WHERE collect_date in (@newdate)
GO
按照楼上的方法在查询分析器中运行提示语法错误