exec ('select ProductCatalogName,productname'+@sql+' from exportBillSaleView
where CreateTime between '+'''@startTime'''+' and '+'''@endTime'''+' group by ProductCatalogName,productname order by ProductCatalogName')
这么写为什么不可以?
where CreateTime between '+'''@startTime'''+' and '+'''@endTime'''+' group by ProductCatalogName,productname order by ProductCatalogName')
这么写为什么不可以?
解决方案 »
- 急求:提取所有 数据类型为 int或double型的列,求和显示出来
- 我的SQLserver中的有个字段是时间日期型的,可是现在有一部分不知道怎么都变成"YYYY-MM-DD 09:17:00"???
- 如何在sql中将服务器中数据库备份到网络中另一台机器上
- 求一个SQLite更新语句
- 急急急急急急!用路径存储的方法如何实现wav文件的存储及访问!
- 日志转移相关问题
- 我的sql为什么总是在运行以后右下角的图标隐藏不见,但点那位置还是有?(sql7)
- zjcxc(邹建),当然有记录了
- 两台win2k机器,其中一台装有sqlserver7,另一台用sa身份连接sqlserver,是否必须先经过NT验证?
- 小白急求助,初学数据库。求配置环境+编写程序+测试。谢谢!
- 急啊急啊,SQL Server 2000连接问题,大家来帮忙?
- 請教一個SQL 語句.關於時間的order by
where CreateTime between '+'''@startTime'''+' and '+'''@endTime'''+' group by ProductCatalogName,productname order by ProductCatalogName')
exec ('select ProductCatalogName,productname'+@sql+' from exportBillSaleView
where CreateTime between '+'''[@startTime]'''+' and '+'''[@endTime]'''+' group by ProductCatalogName,productname order by ProductCatalogName')
你再试一试,我感觉变量不用双引号。
where CreateTime between '+'''convert(datetime,@startTime)'''+' and '+'''convert(datetime,@endTime)'''+' group by ProductCatalogName,productname order by ProductCatalogName')建议用datediff
看看这样行么?
exec ('select ProductCatalogName,productname'+@sql+' from exportBillSaleView
where createtime between '''+@startTime+''' and '''+@endTime+''' group by ProductCatalogName,productname order by ProductCatalogName')