[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL QUERY FOR APPROVAL PROCEDURE IN SAP B'ONE

Posted on 2008-11-12
1
Medium Priority
?
514 Views
Last Modified: 2013-12-08
HELLO

I HAVE A QUESTION
I HAVE CREATED 3 FIELDS CALLED U_ZCONSO, U_ZCONSO2, U_ZCONSO3 ALL ARE ALPHANUMERIC FIELDS BECAUSE NUMERIC IS LIMITED TO 11 DIGITS AND THE FIELDS ARE MORE SO I NEED 18 DIGITS.

I HAVE A QUERY FOR U_ZCONSO AND U_ZCONSO 2 WHICH MUST GIVE ME A NUMBER
1 WHEN ZCONSO3 IS EMPTY
I HAVE MADE THE FOLOWING QUERY I DO NOT HAVE ANY ERROR MESSAGE BUT THE RESULT IS NOT WHAT I WANT BECUASE IT SI EMPTY

IF $[ORDR.U_ZCONSO3] IS NULL
SELECT '0'
ELSE
SELECT SUM(T0.Balance) from OCRD T0 Where T0.U_SCONSO=$[ORDR.U_ZCONSO3]

2 WHEN ZCONSO3 IS NOT EMPTY I NEED TO COMPARE ZCONSO AND ZCONSO2 AND MAKE THEM NUMERIC VALUE THE ISSUE IS THE NUMERIC VALUE COMES WITH COMA IN THE FELDS AND THE QUERY DOES NOT CONVERT THE NVARCHAR INTO A NUMERIC FORMAT

THE QUERY IS BELOW

DECLARE @CRED AS numeric(19,6)
DECLARE @FACT AS numeric(19,6)
SET @CRED=$[ORDR.U_ZCONSO]
SET @FACT=$[ORDR.U_ZCONSO2]
SELECT DISTINCT 'TRUE' WHERE @CRED<@FACT
0
Comment
Question by:Humphrey1973
1 Comment
 
LVL 30

Accepted Solution

by:
nmcdermaid earned 2000 total points
ID: 23074784
MY EYES HURT
 Numeric is not limited to 11 digits.
Use NUMERIC(19,0) to be able to store a number with 19 digits (and no decimal places)
You second issue about converting NVARCHAR will go away when you use this datatype.
SELECT ISNULL(ZCONSO3 ,0) will give the contents of that field, or zero if that field is NULL
 
 
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

834 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