Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Phrase wanted. 1

Status
Not open for further replies.

IonelBurtan

Programmer
May 25, 2001
601
RO
In a stored procedure I am receiving 5 parameters @x,@y,@,z,@t,@w all of them decimal(10,2)

Depending on each of them I insert a row in another table like:
if not (@x=0.0)
INSERT INTO TABLE_WHATEVER(@Id,@x)

if not (@y=0.0)
INSERT INTO TABLE_WHATEVER(@Id,@y)
... (5 times)
Is there a way to do all 5 insert phrases in a SINGLE SQL Phrase(on SQL 7.0).

Thanx,
s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Try using CASE phrase. Mohammad Mehran Nikoo, MCSD mohmehran@msn.com
 
Hi,

Try this,

declare @x int,@y int,@z int,@t int

select @x=0,@y=1,@z=2,@t=3

insert into t
select *
from
( select @x as col union all
select @y as col union all
select @z as col union all
select @t as col
) as tbl
where tbl.col <>0.0

select * from t
--create table t(col int)

Regards, xcata.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top