Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

URGENT HELP PLEASE Expand / Collapse
Author
Message
Posted Monday, August 6, 2012 10:47 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, December 13, 2012 2:53 PM
Points: 5, Visits: 17
I have this select statement:

select a.active from sys_scd_profile a
inner join sys_scd_profile_activation b on (a.id = b.profile_id)
where a.active = 1 and b.date_deactivated is not NULL and b.date_reactivated is NULL and b.date_deactivated < '7 aug 2012'

I need to update all a.active to = 0 where it exists in the select statement.

Please help. very urgent
Post #1340997
Posted Tuesday, August 7, 2012 12:11 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Wednesday, February 24, 2016 6:28 AM
Points: 3,977, Visits: 6,431
Do you mean like this?

UPDATE a
SET a.active = 0
FROM sys_scd_profile a
INNER JOIN sys_scd_profile_activation b
ON a.id = b.profile_id
WHERE a.active = 1 and b.date_deactivated is not NULL and
b.date_reactivated is NULL and
b.date_deactivated < '7 aug 2012'





My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!

My thought question: Have you ever been told that your query runs too fast?

My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.


Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Learn to understand recursive CTEs by example.
Splitting strings based on patterns can be fast!
My temporal SQL musings: Calendar Tables, an Easter SQL, Time Slots and Self-maintaining, Contiguous Effective Dates in Temporal Tables
Post #1341021
Posted Tuesday, August 7, 2012 12:14 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, December 13, 2012 2:53 PM
Points: 5, Visits: 17
Awesome!!! Result i needed. Thanks heaps :)
Post #1341022
Posted Tuesday, August 7, 2012 7:12 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 3:58 PM
Points: 2,060, Visits: 8,475
Note that "b.date_deactivated is not NULL" is superfluous. If b.date_deactivated is NULL then the result of "b.date_deactivated < '7 aug 2012'" will also be NULL. So, in order for the second statement to be TRUE, the first statement must be true.

Drew



J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA



How to post data/code on a forum to get the best help.
Make sure that you include code in the appropriate IFCode tags, e.g. [code="sql"]<your code here>[/code]. You can find the IFCode tags on the left when you are writing a post.
How to Post Performance Problems
Post #1341227
Posted Tuesday, August 7, 2012 7:53 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 3:58 PM
Points: 2,060, Visits: 8,475
CELKO (8/7/2012)
It looks like you use assembly language bit flays

Until SQL support Boolean datatypes, bit flags are the next best thing.

, but you did not bother to post any DDL so we have no idea what help you need. Just follow basic Netiquette, please.


Perhaps you should try reading the thread instead of pushing your personal agenda. The question has already been answered, so obviously there was enough information provided

Drew


J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA



How to post data/code on a forum to get the best help.
Make sure that you include code in the appropriate IFCode tags, e.g. [code="sql"]<your code here>[/code]. You can find the IFCode tags on the left when you are writing a post.
How to Post Performance Problems
Post #1341277
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse