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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-12-09 : 07:00:15
|
| padmanaban writes "select substring(Col_1,7,12) as col_1 from tblhere col_1 is a column name in the table tbl and it is working fine.declare @strq varchar(500)set @strq = 'select '+ substring(Col_1 ,1,12)+' as Col_1 from tbl'exec(@strq)im getting error invalid column name 'col_1' while its executed.Could Anyone help for this.thanks in advance.Padmanaban." |
|
|
surendrakalekar
Posting Yak Master
120 Posts |
Posted - 2005-12-09 : 07:26:44
|
| try this..declare @strq varchar(500)set @strq = 'select substring(Col_1 ,1,12) as Col_1 from tbl'exec(@strq)Surendra |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-12-09 : 08:43:06
|
| The entire statement should be assigned to Variable as suggestedRead this more on Dynamic SQLhttp://www.sommarskog.se/dynamic_sql.htmlMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|