这是我在这张表中的数据,我希望我的输出显示如下 FoodID,ItemID,FoodName,ItemName, 1,2 1肉鸡,猪肉解决方案 我认为你是Totaly困惑你想要做什么? ?????????????????????????示例 SET ANSI_NULLS Ø N GO SET QUOTED_IDENTIFIER ON GO 创建 PROCEDURE [dbo]。[SP_ADD_ROLE] @RoleDesc nvarchar ( 50 ), @ Comments nvarchar (max), @ RcoUpdate as nvarchar (max), @ IsActive varchar ( 1 ), @DateCreated date , @ IsDelete varchar ( 1 ), @Result as nvarchar ( 50 )输出 AS BEGIN - 添加SET NOCOUNT ON以防止来自的额外结果集 - 干扰SELECT语句。 SET NOCOUNT ON ; 插入 进入 TBLCFGROLES(RoleDesc,Comments,RCOupdate,IsActive,DateCreated, IsDelete) 值( @ RoleDesc , @评论, @ RcoUpdate , @ IsActive , @DateCreated , @ IsDelete ) SET @结果 = N ' 数据已成功插入' END 如果你想加入你的桌子 这里是一个示例查询 SELECT TBLEMP.Name,TBLEMP.FName,TBLEMP.Mobile, TBLMARITALSTATUS.MaritalStatusDesc,TBLCFGSEX.SexDe cription, TBLEMPSTATUS.EmpStatusDesc FROM TBLEMP INNER JOIN TBLCFGSEX ON TBLEMP.CfgSexId = TBLCFGSEX.CfgSexId INNER JOIN TBLEMPSTATUS ON TBLEMP.StatusId = TBLEMPSTATUS.StatusId INNER JOIN TBLMARITALSTATUS ON TBLEMP.MaritalStatusId = TBLMARITALSTATUS.MaritalStatusId INSERT INTO Inventory (FoodID, ItemID , FoodName, ItemNameSelect f.FoodID, i.FoodName SUBSTRING(Select f.FoodID, (','+ f.FoodID) , f.FoodName , (','+ i.FoodName) from Event et CROSS JOIN Volunteer vtwhere FoodID = FoodID , ItemName = ItemNameorder by FoodID, ItemIDENDIn this case, how would you avoid it?This is my data in this table, I want my output to appear like thisFoodID, ItemID, FoodName, ItemName,1,2 1 Meat Chicken, Pork 解决方案 I think You are Totaly Confused What Your are Trying to Do?????aNy how If You Want To insert Data Into Table Trough Store ProcedureHere is A sample SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCreate PROCEDURE [dbo].[SP_ADD_ROLE] @RoleDesc nvarchar(50),@Comments nvarchar(max), @RcoUpdate as nvarchar(max),@IsActive varchar(1),@DateCreated date,@IsDelete varchar(1),@Result as nvarchar(50) outputASBEGIN-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.SET NOCOUNT ON; insert into TBLCFGROLES (RoleDesc,Comments,RCOupdate,IsActive,DateCreated,IsDelete) values (@RoleDesc,@Comments,@RcoUpdate,@IsActive,@DateCreated,@IsDelete) SET @Result = N'Data Inserted Successfuly'ENDand If you want to Join Your Tables here is a Sample QuerySELECT TBLEMP.Name, TBLEMP.FName, TBLEMP.Mobile, TBLMARITALSTATUS.MaritalStatusDesc, TBLCFGSEX.SexDecription, TBLEMPSTATUS.EmpStatusDescFROM TBLEMP INNER JOIN TBLCFGSEX ON TBLEMP.CfgSexId = TBLCFGSEX.CfgSexId INNER JOIN TBLEMPSTATUS ON TBLEMP.StatusId = TBLEMPSTATUS.StatusId INNER JOIN TBLMARITALSTATUS ON TBLEMP.MaritalStatusId = TBLMARITALSTATUS.MaritalStatusId 这篇关于存储过程错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-12 13:24