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

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: Yesterday @ 6:12 PM
Points: 3,609, Visits: 5,220
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!
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


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, September 3, 2013 8:24 AM
Points: 1,240, Visits: 5,421
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
Post #1341227
Posted Tuesday, August 7, 2012 7:28 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Sunday, July 20, 2014 11:55 AM
Points: 1,945, Visits: 2,860
It looks like you use assembly language bit flays, but you did not bother to post any DDL so we have no idea what help you need. Just follow basic Netiquette, please.

Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Post #1341244
Posted Tuesday, August 7, 2012 7:53 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, September 3, 2013 8:24 AM
Points: 1,240, Visits: 5,421
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
Post #1341277
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse