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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL query in PB

Status
Not open for further replies.

docky5

Programmer
Sep 27, 2007
15
US
HI,

My problem is that one of the DW gets data from an sql query result. I use if..else in it but somehow both part runs (the if and the else part as well...)
I run the script in Query Analyzer and by using BEGIN ..END on the ELSE part it worked and retrieved only once the result...BUT my problem is in PB 8.0.3 it doesn't work..PB doesn't recognize the BEGIN only the END.

How could I overlay it or any idea how could I skip it?

Thx
 
Can you provide a short example?

Matt

"Nature forges everything on the anvil of time
 
Hi,
here is the SQL, both part of the IF produces a !?result set?!(don't know how) at the second run....BUT if I use BEGIN - END on the ELSE part select in Query Analyzer then it works properly! But PB doesn't recognize the BEGIN word so I can't use BEGIN - END...how could I replace that?:

If exists(select * from tempdb.dbo.sysobjects where name = '##temptable')
Select * from ##temptable order by counter
ELSE
Select AR1.Cust_Code,
AR1.Cust_Name,
IDENTITY(int,1,1) as counter
INTO ##temptable
FROM AR1
WHERE ( AR1.Del_Flag = 'N' ) order by Cust_Name
select * from ##temptable order by counter


 
Put your sql into a stored proc which returns a result set and use that to create your datawindow.

Matt

"Nature forges everything on the anvil of time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top