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

Arthur Fuller fuller.artful at gmail.com
Fri May 30 09:49:40 CDT 2008


Declare the variable inside the sproc and use a simple SELECT statement to
set its value, then plug it into the DateAdd() expression.

hth,
Arthur

On 5/30/08, Paul Hartland <paul.hartland at googlemail.com> wrote:
>
> 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
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
>



More information about the dba-SQLServer mailing list