p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

sql_server thread: Problem with saving stored procedure...


Message #1 by Bukovansky@a... on Tue, 23 Jan 2001 17:18:14 +0100
> how to fix.
> assign a new temp table name when the statement is false.

But I need the same table!!! There's a problem.
So I thought about this problem and I solved the problem with this:
(So my SP is very long for posting to this list, the example is
very simplify, as all my previous examples...)

Create Procedure sp_Example
As
DECLARE @i int, @StrSQL varchar(500)
SELECT @i = 1
IF @i = 2
	SELECT @StrSQL = 'SELECT * INTO #TempTbl FROM Goods'
ELSE
	SELECT @StrSQL = 'SELECT * INTO #TempTbl FROM Goods_new'

EXECUTE @StrSQL
return

Thanx all for your efficient help.

Regards,

Richard Bukovansky

> example:
> 
> Create Procedure sp_Example
> As
> DECLARE @i int
> SELECT @i = 1
> IF @i = 2
> 	SELECT * INTO #TempTbl FROM Goods
> ELSE
> 	SELECT * INTO #TempTbl2 FROM Goods_new
> return 
> 
> 
> 
> 
> Renante Jimenez Milan
> Development Group
> AccountMate Philippines, Inc.
> 

  Return to Index