Home > Database > Mysql Tutorial > SQLServer拼接语句使用between and 出错,求助

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

WBOY
Release: 2016-06-07 15:25:09
Original
1620 people have browsed it

最后答案: 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+'''')

 

 

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template