首页 > 数据库技术 > 详细

SQL 动态拼接SQL 语句

时间:2015-02-11 18:26:57      阅读:222      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!