Drake
12-29-2000, 01:07 PM
Ok, I got a good one for you guys.. I am trying to do the below statement,
but within a stored procedure. Usually it isn't a problem using the exec
command, but since there is arithmetic, I am having issues.. Can anyone help
out..
This statement works, no problem...
UPDATE tblSchedPaper
SET IntPaperID= 42 ,
IntListRollSizeID= 95 ,
IntQty = round(floor( ( (cast( 40 as decimal(18,6))/cast( 50 as decimal(18,6)))*(s2.IntQty
* .0453592)) + 499 ),-3)
FROM tblCustProdSche INNER JOIN tblSchedPaper s2 ON s2.IntScheduleID = tblCustProdSche.IntScheduleID
WHERE IntPaperID IS NOT NULL
When I try to pass in parameters, that is when I am having issues:
CREATE Procedure usp_Migration_Rounding
@DestIntPaperID int,
@DestIntListID int,
@Destgrade decimal (18,6),
@Sourcegrade decimal (18,6),
@Factor decimal (18,6),
@where varchar(200)
AS
exec ('
UPDATE tblSchedPaper
SET IntPaperID= '+ @DestIntPaperID + ' ,
IntListRollSizeID= ' + @DestIntListID + ' ,
IntQty = round(floor( ( (cast( ' + @destgrade + ' as decimal(18,6))/cast(
' + @sourcegrade + ' as decimal(18,6)))*(s2.IntQty * ' + @factor + ')) +
499 ),-3)
FROM tblCustProdSche INNER JOIN tblSchedPaper s2 ON s2.IntScheduleID = tblCustProdSche.IntScheduleID
WHERE ' + @where )
RETURN @@ROWCOUNT
I get the following error:
Server: Msg 170, Level 15, State 1, Line 0
Line 3: Incorrect syntax near '*'.
Server: Msg 170, Level 15, State 1, Line 0
Line 5: Incorrect syntax near 'cast'.
but within a stored procedure. Usually it isn't a problem using the exec
command, but since there is arithmetic, I am having issues.. Can anyone help
out..
This statement works, no problem...
UPDATE tblSchedPaper
SET IntPaperID= 42 ,
IntListRollSizeID= 95 ,
IntQty = round(floor( ( (cast( 40 as decimal(18,6))/cast( 50 as decimal(18,6)))*(s2.IntQty
* .0453592)) + 499 ),-3)
FROM tblCustProdSche INNER JOIN tblSchedPaper s2 ON s2.IntScheduleID = tblCustProdSche.IntScheduleID
WHERE IntPaperID IS NOT NULL
When I try to pass in parameters, that is when I am having issues:
CREATE Procedure usp_Migration_Rounding
@DestIntPaperID int,
@DestIntListID int,
@Destgrade decimal (18,6),
@Sourcegrade decimal (18,6),
@Factor decimal (18,6),
@where varchar(200)
AS
exec ('
UPDATE tblSchedPaper
SET IntPaperID= '+ @DestIntPaperID + ' ,
IntListRollSizeID= ' + @DestIntListID + ' ,
IntQty = round(floor( ( (cast( ' + @destgrade + ' as decimal(18,6))/cast(
' + @sourcegrade + ' as decimal(18,6)))*(s2.IntQty * ' + @factor + ')) +
499 ),-3)
FROM tblCustProdSche INNER JOIN tblSchedPaper s2 ON s2.IntScheduleID = tblCustProdSche.IntScheduleID
WHERE ' + @where )
RETURN @@ROWCOUNT
I get the following error:
Server: Msg 170, Level 15, State 1, Line 0
Line 3: Incorrect syntax near '*'.
Server: Msg 170, Level 15, State 1, Line 0
Line 5: Incorrect syntax near 'cast'.