拼接字符串语法及示例如下链接,可以参照。
http://www.cnblogs.com/freeliver54/p/4332422.html
拼接字符串的存储过程示例如下:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER proc [tjcountqj]
as
DECLARE @n int,
@date nvarchar(50)
set @n=1
while @n<=31
begin
set @date='2015-7-'+cast(@n as varchar)
insert into test.[dbo].[tjqj]([nq],qj , [tjcount])
select @n,@date,count(*) from dbo.[7月汇总表]
where left(Col002,9)=@date
set @n=@n+1
End
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO