Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Query Help Expand / Collapse
Author
Message
Posted Monday, October 22, 2012 8:00 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Saturday, July 26, 2014 5:26 PM
Points: 205, Visits: 744
Hi guys,

Need help in sql query, Let me let you what i need, during the S.P i want to like
to use this LOGIC, if EID = 0 and PID = 0 then don't run UDF.

Here is the syntax

LEFT OUTER JOIN Information_Sales A ON Case IF EID = 0 or PID = 0 then SID = 148 ELSE UDF.NEW (EID,PID) = A.SID

Please let me know if my question is not clear.

Thanks in advance..
Post #1375804
Posted Monday, October 22, 2012 11:04 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Sunday, July 20, 2014 7:16 AM
Points: 945, Visits: 1,769
can you post DDL and Sample data? While things may seem simple the udf and the the query you are trying and/or the outcome you are trying to get will help us immensely


For faster help in answering any problems Please read How to post data/code on a forum to get the best help - Jeff Moden for the best way to ask your question.

For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw

Need to Split some strings? Jeff Moden's DelimitedSplit8K
Jeff Moden's Cross tab and Pivots Part 1
Jeff Moden's Cross tab and Pivots Part 2

Jeremy Oursler
Post #1375829
Posted Tuesday, October 23, 2012 1:53 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 2:35 PM
Points: 4,013, Visits: 6,087
LEFT OUTER JOIN Information_Sales A ON Case IF EID = 0 or PID = 0 then SID = 148 ELSE UDF.NEW (EID,PID) = A.SID

Its important to remember that a CASE expression is an expression, which produces a single scalar value. It is not an IF clause.

Assuming that the SID = 148 and A.Sid are the same column. You want something more like this

LEFT OUTER JOIN Information_Sales A on A.SID = Case When EID = 0 then 148 when PID = 0 then 148 else UDF.NEW (EID,PID) end

---------
Note: NO guarantees on performance of such a join. You may well be better off doing separate queries

LEFT OUTER JOIN Information_Sales A on SID = 148 
WHERE EID = 0 or PID = 0

LEFT OUTER JOIN Information_Sales A  on UDF.NEW (EID,PID)
WHERE EID <> 0 and PID <> 0

As has already been pointed out. A lot more information is needed before anyone can give you solid, specific advice.


__________________________________________________

Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? -- Stephen Stills
Post #1376226
Posted Wednesday, October 24, 2012 10:08 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Saturday, July 26, 2014 5:26 PM
Points: 205, Visits: 744
Thanks for help guys,

Its a 18 Pages S.P, its hard for me to through all logic here, that's what i want

LEFT OUTER JOIN Information_Sales A on A.SID = Case When EID = 0 then 148 when PID = 0 then 148 else UDF.NEW (EID,PID) end

I checked Performance wise its ok not bad.

Thanks all.....
Post #1376760
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse