Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hello,I am going to update a column in a temp table.Can you look at is it right?
exec('update #Tmp Data set REASON=(select A.CODEDESCFROM REASONCODES A join LOAN Lon L.REAS_CD= A.CODEID WHERE #TmpData.TRAN_TYPE = A.CODEGROUP)')
Thanks
tkizer
Almighty SQL Goddess
38200 Posts
Posted - 2009-04-01 : 15:27:50
Why are you using dynamic SQL for this? There is nothing dynamic about it!I wouldn't use a subquery. I'd write it like this:update tset REASON=A.CODEDESCfrom #tmpData tINNER JOIN REASONCODES AON #t.TRAN_TYPE = A.CODEGROUP join LOAN Lon L.REAS_CD= A.CODEIDSee how it is no longer dynamic?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog"Let's begin with the premise that everything you've done up until this point is wrong."