首页  >  文章  >  数据库  >  SQLServer拼接语句使用between and 出错,求助

SQLServer拼接语句使用between and 出错,求助

WBOY
WBOY原创
2016-06-07 15:25:091591浏览

最后答案: ALTER procedure [dbo].[GetBy_ItemName_BetweenTime] @itemName nvarchar(50), @beginTime datetime, @endTime datetime as declare @tableName nvarchar(50) set @tableName = (select TableName from TQueryItem where ItemName=@itemName) ex

最后答案:

 

ALTER procedure [dbo].[GetBy_ItemName_BetweenTime]
@itemName nvarchar(50),
@beginTime datetime,
@endTime datetime
as

declare @tableName nvarchar(50)
set @tableName = (select TableName from TQueryItem where ItemName=@itemName)

exec ('select * from '+@tableName+' where YYMMDD between '''+@beginTime+''' and '''+@endTime+'''')

 

 

时间上的单引号问题。。。我蠢了

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn