Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Updating a column with a input parameter in a stor

Author  Topic 

Pregz
Starting Member

2 Posts

Posted - 2014-05-19 : 06:04:23
Hi

Is it possible to assign to a column a value passed as a parameter?

When I run the proc I get the following error :


Msg 245, Level 16, State 1, Procedure Transfer, Line 17
Conversion failed when converting the varchar value '@ID' to data type int.


Any help with be appreciated.

----####################################################

USE [tbldata]
GO
/****** Object: StoredProcedure [dbo].[Transfer] Script Date: 05/19/2014 11:26:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Transfer](@ID int)

AS

BEGIN


update tbldata
set Status = '9999'
where MessageID in (select top 5000 MessageID
from tbldata
)


update tbldata
set Status = 0,tblID = '@ID'



END
----####################################################

Thanks

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2014-05-19 : 06:31:07
Don't set the variable in single quotes.


Too old to Rock'n'Roll too young to die.
Go to Top of Page
   

- Advertisement -