[dba-SQLServer] Get A Value From A Table & Use In Stored Procedure

Paul Hartland paul.hartland at googlemail.com
Fri May 30 09:25:22 CDT 2008


To all,

I have never really dealt with cursors etc as yet in SQL Server, but from
what I have had a quick read of you can use a cursor as a type of recordset
(please correct me if I am wrong).

I have a table called tblParameters in which has two fields ParameterName &
ParameterValue, one of the parameter names is EXPIRY_MONTHS.  I have an
update procedure called mysp_update_expirydate which is similar to the
following:

mysp_update_expirydate
@intValue [int]
AS
BEGIN
    SET NOCOUNT ON
    UPDATE dbo.MyTable
    SET ExpiryDate=DATEADD(month, at intValue,GETDATE())
    WHERE MyCriteria
    SET NOCOUNT OFF
END

I am using Visual Basic 6.0 using a recordset to get the value from
tblParameters, then execute the store procedure passing it the value from my
recordset.

What I need to do if possible (and would be grateful of some sample code if
possible) is instead of the parameter @intValue get the value from
tblParameters inside the stored procedure ?

Has anyone done this or similar before and can point me in the right
direction please.

Thank you in advance for any help on this...


-- 
Paul Hartland
paul.hartland at googlemail.com



More information about the dba-SQLServer mailing list