Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
INSERT INTO Inventory (FoodID, ItemID , FoodName, ItemName
Select f.FoodID, i.FoodName SUBSTRING(
Select f.FoodID, (','+ f.FoodID) , f.FoodName , (','+ i.FoodName) from Event et CROSS JOIN Volunteer vt
where FoodID = FoodID , ItemName = ItemName
order by FoodID, ItemID
END

In this case, how would you avoid it?

This is my data in this table, I want my output to appear like this

FoodID, ItemID, FoodName, ItemName,

1,2 1 Meat Chicken, Pork
Posted
Comments
Basmeh Awad 5-Feb-14 3:18am    
not clear what is the data in your table and what how you want the output to be????
add more information
Simon_Whale 5-Feb-14 4:31am    
Is your query complete? where are the tables that you have aliases for i and f?

1 solution

I think You are Totaly Confused What Your are Trying to Do?????


aNy how If You Want To insert Data Into Table Trough Store Procedure
Here is A sample
SQL
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create 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)  output
AS
BEGIN
	-- 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'
END


and If you want to Join Your Tables
here is a Sample Query
SQL
SELECT        TBLEMP.Name, TBLEMP.FName, TBLEMP.Mobile, TBLMARITALSTATUS.MaritalStatusDesc, TBLCFGSEX.SexDecription, 
                         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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900