July 26, 2006 at 4:46 pm
I can't use a select statement to set the value of a parameter variable that is declared locally in the stored procedure. Does anyone know a work around? My t-sql code that fails is:
CREATE PROCEDURE [dbo].[UpdateLatestCheckSum] @paramUserID int
AS
Declare @paramCheckSumNo int
Set @paramCheckSumNo = SELECT CheckSumNo
FROM AUVChangesTable Where UserIDNumber = @paramUserID
Update AUVCheckSumTable
Set LatestCheckSum = @paramCheckSumNo
Where AUVCheckSumTable.UserIDNumber = @paramUserID
July 26, 2006 at 5:50 pm
Actually you I can use a select statement to set the value of a parameter variable that is declared locally in the stored procedure.
It just must be SELECT.
SELECT @paramCheckSumNo = CheckSumNo
FROM AUVChangesTable Where UserIDNumber = @paramUserID
But in you case you don't need this variable at all.
Update AUVCheckSumTable
Set LatestCheckSum = C.CheckSumNo
FROM AUVChangesTable C
Where C.UserIDNumber = AUVCheckSumTable.UserIDNumber
-- AND AUVCheckSumTable.UserIDNumber = @paramUserID
This will update checksums for all users in 1 go.
Uncomment "AND" row if you wish to update checksum for single user.
_____________
Code for TallyGenerator
July 26, 2006 at 6:53 pm
Sergiy, Thank you so much. I tried the option of not using a the local parameter, and it work very well.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply