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 |
|
charul
Starting Member
18 Posts |
Posted - 2009-01-09 : 07:13:52
|
| I have a statement like thisSet @strSql= 'Select @Weightage= OCW_Weightage from PMS_OrgLevelCompWeightage,PMS_OrgLevelCompConfigwhere OCW_CU_ID=@CUID and OCW_OCC_ID=OCC_ID 'exec (@strSql)whenever i run this query i get an error saying@Weightage not defined. how to solve this? |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-09 : 07:24:33
|
| u can't use @weightage useSet @strSql= 'Select OCW_Weightage from PMS_OrgLevelCompWeightage,PMS_OrgLevelCompConfigwhere OCW_CU_ID=@CUID and OCW_OCC_ID=OCC_ID 'exec (@strSql) |
 |
|
|
ashishashish
Constraint Violating Yak Guru
408 Posts |
Posted - 2009-01-09 : 07:27:47
|
quote: Originally posted by charul I have a statement like thisSet @strSql= 'Select @Weightage= OCW_Weightage from PMS_OrgLevelCompWeightage,PMS_OrgLevelCompConfigwhere OCW_CU_ID=@CUID and OCW_OCC_ID=OCC_ID 'exec (@strSql)whenever i run this query i get an error saying@Weightage not defined. how to solve this?
Wrong method to do this,,,its never like this,,,,,Set @strSql= 'Select @Weightage= |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-01-09 : 07:28:59
|
The next error will be: @CUID not defined No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-09 : 08:33:11
|
quote: Originally posted by charul I have a statement like thisSet @strSql= 'Select @Weightage= OCW_Weightage from PMS_OrgLevelCompWeightage,PMS_OrgLevelCompConfigwhere OCW_CU_ID=@CUID and OCW_OCC_ID=OCC_ID 'exec (@strSql)whenever i run this query i get an error saying@Weightage not defined. how to solve this?
for returning values like this through dynbamic sql use sp_executesql instead of EXEChttp://technet.microsoft.com/en-us/library/ms188001.aspx |
 |
|
|
|
|
|
|
|