May 8, 2012 at 2:12 pm
Hello -
Can someone help me and point in the right direction?? I'm trying to writing some SQL that will set rev_type = '' if the following where clause is met.
select p.project, p.status_pa, p.pm_id05, rev_type, contract_type, p.crtd_datetime, *
from pjproj p
inner join pjprojex x on x.project = p.project
where p.pm_id05 = 'AR'
and rev_type = 'PC'
Regards,
D
May 8, 2012 at 2:58 pm
With 526 points I would think you would know you should provide a bit more detail than this. This is totally a shot in the twilight.
update pjprojex
set rev_type = ''
from pjproj p
inner join pjprojex x on x.project = p.project
where p.pm_id05 = 'AR'
and rev_type = 'PC'
I assume that rev_type is in pjprojex or it would be a simple update?!?!?!?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 9, 2012 at 7:40 am
Sean Lange (5/8/2012)
With 526 points I would think you would know you should provide a bit more detail than this. This is totally a shot in the twilight.
update pjprojex
set rev_type = ''
from pjproj p
inner join pjprojex x on x.project = p.project
where p.pm_id05 = 'AR'
and rev_type = 'PC'
I assume that rev_type is in pjprojex or it would be a simple update?!?!?!?
Because pjprojex is aliased in the FROM clause, you need to use the alias in the UPDATE clause as well. The above code should be rewritten as
update x
set rev_type = ''
from pjproj p
inner join pjprojex x on x.project = p.project
where p.pm_id05 = 'AR'
and rev_type = 'PC'
This requirement makes sense if you think about an update on a table that is joined to itself.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
May 9, 2012 at 7:58 am
Sean Lange (5/8/2012)
With 526 points I would think you would know you should provide a bit more detail than this.--
Looks like 62 points to me 😛
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
May 9, 2012 at 8:17 am
Phil Parkin (5/9/2012)
Sean Lange (5/8/2012)
With 526 points I would think you would know you should provide a bit more detail than this.--
Looks like 62 points to me 😛
LOL I guess I meant visits, not points.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 9, 2012 at 8:21 am
Sean Lange (5/9/2012)
Phil Parkin (5/9/2012)
Sean Lange (5/8/2012)
With 526 points I would think you would know you should provide a bit more detail than this.--
Looks like 62 points to me 😛
LOL I guess I meant visits, not points.
Seeing planes flying do not add up to flying experience :hehe:
May 9, 2012 at 8:23 am
Eugene Elutin (5/9/2012)
Sean Lange (5/9/2012)
Phil Parkin (5/9/2012)
Sean Lange (5/8/2012)
With 526 points I would think you would know you should provide a bit more detail than this.--
Looks like 62 points to me 😛
LOL I guess I meant visits, not points.
Seeing planes flying do not add up to flying experience :hehe:
No but it does provide enough insight to know the types of things needed. Lurking other threads and seeing us ask for the same thing over and over should provide enough knowledge of the requirements for questions.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 9, 2012 at 8:46 am
Thank you both for the replies...
And to save on the knuckle beating with a ruler for future post I have reread the best practices on asking questions article.
May 9, 2012 at 8:51 am
david.ostrander (5/9/2012)
Thank you both for the replies...And to save on the knuckle beating with a ruler for future post I have reread the best practices on asking questions article.
+100 for that.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply