November 28, 2011 at 6:21 pm
I would like to modify the following sql statement:
UPDATE pf
SET
pf.OnAirOfferSpotName = bv.OnAirOfferSpotName,
pf.NewMediaInd = bv.NewMediaInd,
pf.RightsEndDate = bv.RightsEndDate,
pf.SpotDescription = bv.SpotDescription,
pf.VideoDescription = bv.VideoDescription,
pf.AudioDescription = bv.AudioDescription,
pf.OnScreenText = bv.OnScreenText,
--We are allowing the user to enter a value rather than the hard coded default
--pf.OfferMadeBy = bv.OfferMadeBy,
pf.Duration = bv.Duration,
pf.FollowingContentTypeId = bv.FollowingContentTypeId,
pf.FollowingContentTypeDetails = bv.FollowingContentTypeDetails,
pf.LastUpdatedDate = @Now,
pf.LastUpdatedUserId = @LastUpdatedUserId,
pf.BroadViewHashCode = bv.BroadViewHashCode,
pf.BroadViewLastUpdatedDate = @Now
FROM PackagingForms.dbo.OnAirOfferSpot pf
JOIN @BroadViewData bv ON bv.BroadViewId = pf.BroadViewId
WHERE pf.BroadViewHashCode <> bv.BroadViewHashCode
OR pf.BroadViewHashCode IS NULL
I want to say:
Case
when bv.SpotDescription <> 'Spot Description' Then
pf.SpotDescription = bv.SpotDescription
End,
instead of the line that says:
pf.SpotDescription = bv.SpotDescription
I keep getting an error: Incorrect syntax near the keyword 'Case'.
What is wrong with the Case part?
November 28, 2011 at 6:44 pm
Faye Fouladi (11/28/2011)
Casewhen bv.SpotDescription <> 'Spot Description' Then
pf.SpotDescription = bv.SpotDescription
End,
instead of the line that says:
pf.SpotDescription = bv.SpotDescription
I keep getting an error: Incorrect syntax near the keyword 'Case'.
What is wrong with the Case part?
You want:
SpotDescription = CASE WHEN bv.SpotDescription <> 'Spot Description' THEN bv.SpotDescription ELSE pf.SpotDescription END
You can't set it inside the case, you need to adjust the case to set it equal to what you want.
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
November 28, 2011 at 7:48 pm
Thanks, I tried your code and it worked.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply