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

Stuart McLachlan stuart at lexacorp.com.pg
Fri May 30 19:36:00 CDT 2008


mysp_update_expirydate
AS
BEGIN
Declare @IntValue Int
Set @Intvalue = (Select ParameterValue from tblParameters where ParameterName = 
'EXPIRY_MONTHS')
.....



On 30 May 2008 at 15:25, Paul Hartland 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