SQL Server stored procedure: Not recognized function name

Posted on 2005-04-11
Last Modified: 2012-06-27
I am in the process of migrating from Access local tables to using a SQL Server back-end database. I was trying to convert SQL strings within my Access application into stored procedures.

How would I convert the following SQL string from my Access application into a stored procedure ?

CREATE PROCEDURE dbo.procTest  AS ...

Format(Nz([CashBalance],Nz([Quantity],0)),'#.000') AS [Check/Cert Amount]

I get the error message:

Error 195:  'Nz' is not a recognized function name.

If I remove Nz, I get the error message:

Error 195:  'Format' is not a recognized function name.
Question by:zimmer9
    LVL 22

    Expert Comment

    by:Kelvin Sparks
    Replace Nz with the SQL Function ISNULL


    Format won't be recognised, you'll need to use either CAST or CONVERT
    LVL 22

    Expert Comment

    by:Kelvin Sparks

    Should have given example with CAST

    CAST(ISNULL([CashBalance],0) AS decimal(9,3)) as [Check/Cert Amount]

    Author Comment

    How would I rewrite the following SQL statement using ISNULL incorporating both fields CashBalance and Quantity into the SQL statement ?

    The field Check/Cert Amount will reflect the value stored in either CashBalance or Quantity depending upon which of these 2 fields contains a value on each record read.

    Format(Nz([CashBalance],Nz([Quantity],0)),'#.000') AS [Check/Cert Amount]
    LVL 22

    Accepted Solution

    CAST(ISNULL([CashBalance],ISNULL([Quantity],0)) AS decimal(9,3)) as [Check/Cert Amount]

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now