Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to replace Format function when using SQL Server stored procedure 1

Status
Not open for further replies.

git2dn

Programmer
Joined
Apr 7, 2005
Messages
12
Location
US
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 ? A value would be stored in either the field Debits or Credits but not both fields on the same record. Perhaps I could use the SQL function IsNull but I'm not sure how to incorporate
2 fields into the IsNull SQL statement.

CREATE PROCEDURE dbo.procTest AS ...

Format(Nz([Debits],Nz([Credits],0)),'#.000') AS [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.
 
NZ and Format aren't SQL functions. I'd do the formatting in the application, and try the following to select the correct field:

[tt]CASE WHEN Debits IS NULL THEN Credits ELSE Debits END As Amount[/tt]

This would perhaps be more appropriate in the SQL forum (forum183)?

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top