emi_sastra
asked on
SP problem
Hi All,
I have SP with script below :
SET @SCRIPT = @SCRIPT + ' WHERE CONVERT(Char(8), A.TglJurnal, 112) '
SET @SCRIPT = @SCRIPT + ' BETWEEN ' + CONVERT(Char(8), @FromDate , 112)
SET @SCRIPT = @SCRIPT + ' AND ' + CONVERT(Char(8), @ToDate , 112)
SET @SCRIPT = @SCRIPT + ' AND A.BuktiJurnal = ' + @BuktiJurnal
The result :
WHERE CONVERT(Char(8), A.TglJurnal, 112)
BETWEEN 20180101 AND 20180131
AND A.BuktiJurnal = BK 0023/YSL/2017/I/18
No apostrophe at the date and string variable.
What's wrong with the script ?
Thank you.
I have SP with script below :
SET @SCRIPT = @SCRIPT + ' WHERE CONVERT(Char(8), A.TglJurnal, 112) '
SET @SCRIPT = @SCRIPT + ' BETWEEN ' + CONVERT(Char(8), @FromDate , 112)
SET @SCRIPT = @SCRIPT + ' AND ' + CONVERT(Char(8), @ToDate , 112)
SET @SCRIPT = @SCRIPT + ' AND A.BuktiJurnal = ' + @BuktiJurnal
The result :
WHERE CONVERT(Char(8), A.TglJurnal, 112)
BETWEEN 20180101 AND 20180131
AND A.BuktiJurnal = BK 0023/YSL/2017/I/18
No apostrophe at the date and string variable.
What's wrong with the script ?
Thank you.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Jim,
Hi Jim,
Where to put UNION ALL from the SQL Script I attached ?
USE [YSL_TRADING]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[ERV_SP_Print_Ledger _Detail_Ju rnal]
@FromDate = '2018/01/01',
@ToDate = '2018/02/28',
@FromAccNo = NULL,
@ToAccNo = NULL,
@LawanAccNo = NULL,
@ListAccNo = NULL,
@BuktiJurnal = ' '
--SELECT 'Return Value' = @return_value
GO
Thank you.
Hi Jim,
Where to put UNION ALL from the SQL Script I attached ?
USE [YSL_TRADING]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[ERV_SP_Print_Ledger
@FromDate = '2018/01/01',
@ToDate = '2018/02/28',
@FromAccNo = NULL,
@ToAccNo = NULL,
@LawanAccNo = NULL,
@ListAccNo = NULL,
@BuktiJurnal = ' '
--SELECT 'Return Value' = @return_value
GO
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi All,
Thank you very much for your help.
Thank you very much for your help.
ASKER
- Also of course what's the point of using @script as dynamic T-SQL? Unless there is a hard reason to use dynamic sql, better to avoid it and make it a straight SQL statement.
Please see the attached Sql Script.
Any suggestion are welcom.
Thank you.
ERV_SP_Print_Ledger_Detail_Jurnal.sql