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.
| Author |
Topic |
|
nisar
Starting Member
29 Posts |
Posted - 2008-12-21 : 22:04:41
|
| Hi i m having problem in executing this querycan anyone solver this value of @sectionid = 6000it is numeric value but it is passing as varcharif i make comment this statement ' and w.sectionid = '''+@sectionid+''''+ then this querywork other wise give syntax errorset @sql = 'select distinct '+@fields+' from dbo.tbl_workorderparts p (nolock, index(0)) '+ ' left join dbo.tbl_workorder w (nolock, index(0)) '+ ' left join dbo.tbl_xhfiwebdetail d (nolock, index(0)) on d.bbramsid = w.bbramsid '+ @forcat_sql + ' left join dbo.tbl_itemprocessref p1 (nolock, index(0)) on p1.itemprocessuid = w.itemprocesstypeid '+ ' left join dbo.tbl_itemprocessref p2 (nolock, index(0)) on p2.itemprocessuid = w.itemprocessuid '+ ' left join dbo.tbl_positionref s (nolock, index(0)) on s.positionuid = w.sectionid '+ ' left join dbo.tbl_itemprocessref p3 (nolock, index(0)) on p3.itemprocessuid = w.status '+ ' on w.workorderid = p.workorderid '+ ' left join dbo.tbl_tric2005 t (nolock, index(0)) '+ ' left join dbo.sut_trictransaction tt (nolock, index(0)) on tt.sut_bbramstrackid = cast(t.id as varchar(32)) '+ ' on p.workorderpartid = t.workorderpartid '+ ' where p.workorderpartid is not null '+ ' and w.sectionid = '''+@sectionid+''''+ ' and t.dept = '+@tempdept+ ' and t.dateapproved is null and t.approvingofficial is null'+ ' and p.orderedby <> '+ @templogin1 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
EugeneLim11
Posting Yak Master
167 Posts |
Posted - 2008-12-22 : 01:29:07
|
| why not use store procedures? You got @ variables, and using store procedures seems to be a better option.Anyway to solve it, remove the ' ' between the valuesand w.sectionid = "+@sectionid+"+ and it will be a numberic type instead of a string.check out my blog at http://www.aquariumlore.blogspot.com |
 |
|
|
nisar
Starting Member
29 Posts |
Posted - 2008-12-22 : 01:47:37
|
| Thanks it works for me |
 |
|
|
|
|
|