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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Conversion Failed in SQL Query

Author  Topic 

juicyapple
Posting Yak Master

176 Posts

Posted - 2010-06-30 : 21:38:41
Hi, anyone can help to correct the error in below query? TQ.

declare @strSQL varchar(4000)
declare @intRecId int
set @intRecId = 3
Set @strSQL = 'Select Param_Value From tbl_Lube_Bath_Test_HeaderTmp (NOLOCK)
Where Rec_Id = ' + @intRecId + ' and Param_Name = ''Luber_Id'''
EXEC (@strSQL)


Conversion failed when converting the varchar value 'Select Param_Value From tbl_Lube_Bath_Test_HeaderTmp (NOLOCK)
Where Rec_Id = ' to data type int.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-07-01 : 02:40:48
quote:
Originally posted by juicyapple

Hi, anyone can help to correct the error in below query? TQ.

declare @strSQL varchar(4000)
declare @intRecId int
set @intRecId = 3
Set @strSQL = 'Select Param_Value From tbl_Lube_Bath_Test_HeaderTmp (NOLOCK)
Where Rec_Id = ' + convert(varchar(10),@intRecId) + ' and Param_Name = ''Luber_Id'''
EXEC (@strSQL)


Conversion failed when converting the varchar value 'Select Param_Value From tbl_Lube_Bath_Test_HeaderTmp (NOLOCK)
Where Rec_Id = ' to data type int.





No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -