Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Build Insert String via Stored Procedure

Author  Topic 

Erik Brown
Starting Member

1 Post

Posted - 2009-05-28 : 16:27:31
I have a web page where my team can order their traditional Burrito on Firday mornings. The table has the following columns (for the sake of brevity I left some out):

Name Huevo Chorizo Papa Jalapenos RowID

What I'd like to do is build out the combinations given and then the web page will dynamically report this. For example go to Row 1, if Huevo is True then the Combination is Heuvo. If Heuco and Chorizo are true then the Comibantion name is Huevo_Chorizo.

I've tried using If statements in a stored procedure but it keeps telling me that the column names do not exist.

This is the code I have been testing with:

ALTER PROCEDURE [dbo].[Test]
-- Add the parameters for the stored procedure here
@p1 int = 0,
@p2 int = 0
--@UserDefinedRowID char( 11 )
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
declare @RowID char( 11 )

select @RowID = min( RowID ) from tbl_BurritoOrderRpt

while @RowID is not null
begin
select Huevo,Chroizo,Papa,Jalapenos,Frijol,Queso,Fajita,Pico,Tocino,Here,UserDefinedRowID from tbl_BurritoOrderRpt where RowID = @RowID and Here='True'

Print Huevo

select @RowID = min( RowID ) from tbl_BurritoOrderRpt where RowID > @RowID
end

END

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2009-05-28 : 21:17:23
This is very hard to understand, because the query does not make sense.

Post your table structure sample data and desired results and someone can help you out.


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page
   

- Advertisement -