September 24, 2008 at 10:23 am
Does anyone knows how to convert the below statement into MS SQL? It doesn't looked like an inner join statement to me.
UPDATE TableA, TableB
SET TableB.CapCode = TableA![Cap Code]
WHERE (((TableB.CapCode) Is Null) AND ((TableB.FromDate) Between [Effect Date] And [Term Date])) OR (((TableB.CapCode) Is Null) AND ((TableB.FromDate)>=[Effect Date]) AND ((TableA.[Term Date]) Is Null));
September 24, 2008 at 11:26 am
September 24, 2008 at 12:34 pm
I can produce the query into MS SQL Select statement, but I can't figure a way to convert it to an Update Statement.
SELECT * FROM TableA,TableB
WHERE (TableA.CapCode='' AND
(convert(datetime,TableA.FromDate) Between convert(datetime,TableB.EffectDate) And convert(datetime,TableB.TermDate)) OR
(convert(datetime,TableA.FromDate) >= convert(datetime,TableB.EffectDate) AND TableB.TermDate=''))
September 24, 2008 at 12:43 pm
The original syntax didn't work? What error did it give? Have a look at Jeff's excellent article on fixing updates here. http://www.sqlservercentral.com/articles/Performance+Tuning/62278/
September 24, 2008 at 1:08 pm
i think the update is this:
UPDATE TableA
SET TableA.[Cap Code] = TableB.CapCode
FROM TableB
WHERE (((TableB.CapCode) Is Null) AND ((TableB.FromDate)
Between [Effect Date] And [Term Date]))
OR (((TableB.CapCode) Is Null) AND ((TableB.FromDate)>=[Effect Date])
AND ((TableA.[Term Date]) Is Null));
Lowell
September 24, 2008 at 1:58 pm
Okay I know what the problem is. The Access query I have is missing a join statement. There is a a Table in my Access Database being linked to another Database, which I don't have access to. So when I open up the Query, the link wasn't showing in the Design View and no JOIN statement was found in the SQL View.
I thought the Access Query looked weird, but I'm not too experience with Access either. Thanks for ya help though.
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply