存储过程 select in 再发一次
select @sql='SELECT A ,BFROM Table
WHERE (Time BETWEEN '''+@strat+''' AND '''+@end+''' ) AND (D in('''+@wh +''') )'
exec(@sql)
我输入参数
2008-7-1
2008-7-31
SC,CQ 或者SC'',''CQ
都返回不了值,怎么办?
我想执行的是
SELECT A ,B FROM Table WHERE (Time BETWEEN '2008-7-1‘ AND '2008-7-31') AND (D in('SC','CQ') )
怎么办?
--------------------编程问答-------------------- 你的这个存储过程能够通过吗 --------------------编程问答-------------------- 需要处理好字符串问题 --------------------编程问答-------------------- 贴出存储过程的代码 --------------------编程问答-------------------- select @sql='SELECT A ,B
FROM Table
WHERE (Time BETWEEN '''+@strat+''' AND '''+@end+''' ) AND (D in('''+@wh +''') )'
这是你存储过程的查询语句吗,是否没写完吧,
@sql='SELECT A ,B
FROM Table
WHERE (Time BETWEEN '''+@strat+''' AND '''+@end+''' ) AND (D in('''+@wh +''') )'
这是要得到A,B表
但你整个的查询的表在哪啊
--------------------编程问答-------------------- 将你的完整的存储过程和执行语句给贴出来啊 --------------------编程问答-------------------- --------------------编程问答--------------------
SELECT A ,B FROM [Table] WHERE Time BETWEEN '2008-7-1' AND '2008-7-31' AND D in('SC','CQ')
Table是保留词,还有个单引号错了 --------------------编程问答-------------------- 看看 --------------------编程问答--------------------
create procedure s_test(
@id nvarchar(50)
)
as
declare @sql nvarchar(100)
set @sql = 'select * from tablename where pid in (' + @id + ')'
exec sp_executesql @sql
exec s_test '''1a'',''2a'''
以上代码测试通过
--------------------编程问答-------------------- table>>[Table]
'''+@strat+''','2008-7-1‘ 这里面有个全角字符. --------------------编程问答--------------------
同意!!
补充:.NET技术 , ASP.NET