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 |
|
issammansour
Yak Posting Veteran
51 Posts |
Posted - 2007-08-17 : 07:01:18
|
| hi,I Have a following SP running on sql 2005:-DECLARE @MONTHNO intDECLARE @DB CHAR (8)DECLARE @CR CHAR (8)SET @MONTHNO = 2SET @DB = 'DB_'+CONVERT(NCHAR(2),@MONTHNO)SET @CR = 'CR_'+CONVERT(NCHAR(2),@MONTHNO)SELECT (acctno),@CR from bmaster. The table has a 12 field with cr_1 ... to 12. the sql can’t understand the @cr the column papers "with No column name' |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-17 : 07:08:09
|
http://www.sommarskog.se/dynamic_sql.htmlexec ('SELECT acctno, ' + @CR + ' from bmaster') E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-17 : 08:40:54
|
quote: Originally posted by issammansour hi,I Have a following SP running on sql 2005:-DECLARE @MONTHNO intDECLARE @DB CHAR (8)DECLARE @CR CHAR (8)SET @MONTHNO = 2SET @DB = 'DB_'+CONVERT(NCHAR(2),@MONTHNO)SET @CR = 'CR_'+CONVERT(NCHAR(2),@MONTHNO)SELECT (acctno),@CR from bmaster. The table has a 12 field with cr_1 ... to 12. the sql can’t understand the @cr the column papers "with No column name'
Make sure you read Sommarskog's article fullyMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|