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

Ms.Access update query emulate to SQL Expand / Collapse
Author
Message
Posted Sunday, March 23, 2014 12:24 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Yesterday @ 8:56 AM
Points: 25, Visits: 170
Hi guys,

I need some insight on how to emulate the below Ms. Access query to SQL.

Thanks in advance.

UPDATE [01 - MemberHomeAssignment] SET [01 - MemberHomeAssignment].[IBNR SNF Days] = IIf([01 - MemberHomeAssignment]![AuthDaysByMonth]<[01 - MemberHomeAssignment]![TotalDaysFromClaims],0,[01 - MemberHomeAssignment]![AuthDaysByMonth]-[01 - MemberHomeAssignment]![TotalDaysFromClaims]);

Post #1553834
Posted Sunday, March 23, 2014 1:49 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 7:09 AM
Points: 1,913, Visits: 19,457
have you looked at the T-SQL CASE statement....this may provide what you require

______________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
Post #1553836
Posted Monday, March 24, 2014 8:16 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, September 25, 2014 5:42 AM
Points: 136, Visits: 252
IF..ELSE is also a possibility since you've got a simple boolean condition.

____________
Just my $0.02 from over here in the cheap seats of the peanut gallery - please adjust for inflation and/or your local currency.
Post #1554046
Posted Monday, March 24, 2014 8:28 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 7:05 AM
Points: 12,999, Visits: 12,415
lshanahan (3/24/2014)
IF..ELSE is also a possibility since you've got a simple boolean condition.


You can't have an IF ELSE inside of an update statement. The IF operator is used to control flow of statements.


_______________________________________________________________

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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1554057
Posted Monday, March 24, 2014 8:33 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 7:05 AM
Points: 12,999, Visits: 12,415
It would be something like this.

UPDATE [01 - MemberHomeAssignment] 
SET [IBNR SNF Days] =
case when AuthDaysByMonth < TotalDaysFromClaims then 0
else AuthDaysByMonth - TotalDaysFromClaims
end

Your code would be a million times easier to read and work with if you change the names to get rid of all the spaces.


_______________________________________________________________

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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1554058
Posted Monday, March 24, 2014 12:02 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Yesterday @ 8:56 AM
Points: 25, Visits: 170
Thanks for the replies guys, however, I had figured out the answer shortly after my post. My apologizes for not updating the thread.
Post #1554180
Posted Monday, March 24, 2014 12:09 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 7:09 AM
Points: 1,913, Visits: 19,457
Briceston (3/24/2014)
Thanks for the replies guys, however, I had figured out the answer shortly after my post. My apologizes for not updating the thread.


Glad to hear you solved the issue.
for the benefit of others that may come across this question ...can you share your solution please?


______________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
Post #1554181
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse