SQL Server - Rewrite Access SQL for SQL Server
Asked By Mike Will via SQLMonster.com
22-Aug-07 08:08 AM
I've tried unsuccessfully to rewrite this query from Access in a way that SQL
Server can interpret it.
This is the Access query:
[OTHours]+[OTType]/1000000+NZ([OTRefusal],0)/10000000+IIf(tblOvertime.
OTRoster=tblEmployee.OTRoster,0.00000001,0.00000002)
Here is what I've tried in SQL Server:
[OTHours]+[OTType] / 1000000+[OTRefusal] / 10000000+(CASE WHEN tblEmployee.
Overtime = tblEmployee.OTRoster THEN 0.0000001 ELSE 0.0000002 END)
I appreciate any help.
--
Message posted via http://www.sqlmonster.com
SQL Server
(1)
TblEmployee.OTRoster
(1)
OTRefusal
(1)
OTRoster
(1)
OTHours
(1)
OTType
(1)
Precedence
(1)
Followings
(1)
Madhivanan replied...
Instead of NZ([OTRefusal],0)
use one of the followings
ISNULL([OTRefusal],0)
COALESCE([OTRefusal],0)
Madhivanan
Roy Harvey replied...
The syntax that was tried in SQL Server appears to be valid syntax, at
least I was able to get it to execute. Is it giving you a syntax
error? What error? Or is it giving the wrong results? How are the
results wrong?
In general any time I mix addition or subtraction with multiplication
or division I use (parentheses) to explicitly group items so it is
totally clear in what order the calculation should be made. There is
an order of precedence for operators, but I never let it come into
play, as I have no interest in memorizing it and possibly remembering
it incorrectly. I suggest that whatever else you do you add
parentheses as appropriate. (The one set of parentheses you have,
around the CASE expression, is actually not doing anything.)
The comment about replacing NZ with COALESCE is correct.
Roy Harvey
Beacon Falls, CT
On Wed, 22 Aug 2007 12:08:38 GMT, "Mike Will via SQLMonster.com"
MSDE on Windows 2003 R2 box, new DL385G6 - Install Fails during SQL Services SQL Server I have been finding that I am having trouble with the Crystal Reports Server XI installation failing when it is dealing with SQL. So, as a thought and in case there was something wrong with my SQL portion of the isntall. I thought ok, I will try installing the actual MSDE application direct from Microsoft. So, I downloaded the MSDE for SQL 2000 (which is msde2000a.exe), set my switches and off to the races. It quit seconds left to the installation and bombed with the same errors as the Crystal Reports Server install. The error is the same whether I try to install MSDE by itself or
Why_can’t_recursive_queries_contain. . .? SQL Server hi I hope I didn = 92t put too many questions 1) Why can = 92t recursive queries also be unioned together with UNION operator ( instead they must use UNION ALL )? thanx SQL Server Programming Discussions SQL Server 2008 (1) SQL Server 2005 (1) SQL Server 2000 (1) SQL Server (1) Oracle (1) Ruby (1) MichaelcoAToptonlineDOTnet (1
SQL Express: Failed Reinstall SQL Server Dear Setup Experts: I am trying to reinstall SQL Express after playing with it some. I uninstalled it, and now, it refuses to reinstall in the face. Any ideas what this log file means and how I can get SQL Express installed? I really do not want to have to reinstall my whole system. * ** ** Start of Log File Overall summary: Final result: SQL Server installation failed. To continue, investigate the reason for the failure, correct the problem, uninstall SQL Server, and then rerun SQL Server Setup. Exit code (Decimal): -2068643839 Exit facility code: 1203
Access 2007-> SQL Server2005 "connection was forcibly closed", GNE 1 SQL Server SQL, Server2005, "connection, was, forcibly, closed", GNE, 1" / > Hi, with an Access 2007 application, I have a very big problem connecting an SQL Server 2005. The scenario: - nearly 200 clients with Windows XP Professional (in an Active Directory Domain clients uses WAN, LAN and WLAN, different locations - one SQL Server 2005 EE, uses actually 36 databases, the Access 2007 application uses 2 of them (one
Cannot restart SQL Server service SQL Server I recently installed SQL Server 2008 Express Edition with Advanced Tools. This is the version information from SQL Server Management Studio Microsoft SQL Server Management Studio 10.0.1600.22 ((SQL_PreRelease).080709- 1414 ) Microsoft