本文介绍了如何在select(传递给变量)中传递值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好, i有一个存储过程 alter Procedure [dbo]。[getFromQueryMaster] @ EmpId int , @ RoleId int , @ ModuleId int , @CompanyId int , @ Frid int , @ callerid varchar ( 15 ) as DECLARE @ QUERY NVARCHAR ( 2000 ) SELECT @ QUERY = QUERY FROM QUERYMASTER WHERE COMPANYID = @ COMPANYID AND Frid = @ Frid AND ROLEID = @ ROLEID AND MODULEID = @ MODULEID EXEC ( @ QUERY + @ callerid ) 这里@查询将从查询主表中加载值,当它执行时它应该从@caller id取值 我的查询应该像这样工作, SELECT top 5 Callerid ,Taxicategory,PickupZone,DropoffZone FROM [JobsCurrent4。 0 ] 其中 Callerid = @ Callerid,' 接听电话', 1 , 1 , 1 , 1 , 1 , 1 请告诉我如何传递exec querys 表插入声明: INSERT INTO [dbo]。[QueryMaster] ([查询] ,[Modulename] ,[ModuleId] ,[EmpId] ,[RoleID] ,[UserId] ,[CompanyId] ,[frID]) VALUES (' SELECT 顶部 5 Callerid,Taxicategory,PickupZone,DropoffZone FROM [JobsCurrent4。 0 ] 其中 Callerid = @ Callerid,' 接听电话', 1 , 1 , 1 , 1 , 1 , 1 ) 解决方案 我们需要进行一些修改。 INSERT INTO [dbo]。[QueryMaster] ([查询] ,[Modulename] ,[ModuleId] ,[ EmpId] ,[RoleID] ,[UserId] ,[CompanyId] ,[frID]) VALUES (' SELECT top 5 Callerid,Taxicategory,PickupZone,DropoffZone FROM [JobsCurrent4 。 0 ] 其中 Callerid =,' 接听电话', 1 , 1 , 1 , 1 , 1 , 1 ) 只需删除@ callerid,一切正常。 Hi all,i have an stored procedure alter Procedure [dbo].[getFromQueryMaster]@EmpId int,@RoleId int,@ModuleId int,@CompanyId int,@Frid int,@callerid varchar(15)asDECLARE @QUERY NVARCHAR(2000)SELECT @QUERY =QUERY FROM QUERYMASTER WHERE COMPANYID=@COMPANYID AND Frid=@Frid AND ROLEID=@ROLEID AND MODULEID=@MODULEID EXEC (@QUERY + @callerid )here the @ query will load the value from the Query master table,when it is executing it should take values from @caller id my query should work like this,SELECT top 5 Callerid,Taxicategory,PickupZone,DropoffZone FROM [JobsCurrent4.0] where Callerid=@Callerid,'Answer Call', 1,1,1,1,1,1pls suggest me me how to pass in exec querysTable Insert Statement :INSERT INTO [dbo].[QueryMaster] ([Query] ,[Modulename] ,[ModuleId] ,[EmpId] ,[RoleID] ,[UserId] ,[CompanyId] ,[frID]) VALUES ('SELECT top 5 Callerid,Taxicategory,PickupZone,DropoffZone FROM [JobsCurrent4.0] where Callerid=@Callerid,'Answer Call', 1,1,1,1,1,1) 解决方案 in the insert we need to make little bit of modification.INSERT INTO [dbo].[QueryMaster] ([Query] ,[Modulename] ,[ModuleId] ,[EmpId] ,[RoleID] ,[UserId] ,[CompanyId] ,[frID]) VALUES ('SELECT top 5 Callerid,Taxicategory,PickupZone,DropoffZone FROM [JobsCurrent4.0] where Callerid=,'Answer Call', 1,1,1,1,1,1)just remove the @callerid,everything works fine. 这篇关于如何在select(传递给变量)中传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-22 19:59