码迷,mamicode.com
首页 > 数据库 > 详细

SQL 动态拼接SQL 语句

时间:2015-02-11 18:27:30      阅读:282      评论:0      收藏:0      [点我收藏+]

标签:

USE [PMS_UnifiedDB_15]
GO
/****** Object:  StoredProcedure [dbo].[SP_GetLogInfo]    Script Date: 2/11/2015 3:04:13 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Alter date: <Alter Date,,>
-- Description:	<Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[SP_GetLogInfo]
	-- Add the parameters for the stored procedure here
	@id bigint,
	@userRoleInput nvarchar(50)
AS
BEGIN
	SET NOCOUNT ON;
		declare @query nvarchar(max);
		set @query =‘select * from dbo.COM_Function where function_label=‘‘‘+@userRoleInput+‘‘‘‘;
		print @query
		exec sp_executeSql @query
	
END

 

SQL 动态拼接SQL 语句

标签:

原文地址:http://www.cnblogs.com/ahghy/p/4286692.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!