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-02-28 : 07:49:42
|
| thankforhelp writes "I need help in parametization of column name.declare @temp_col varchar(50)set @temp-_col = 'employee_name' -- this going to be stored procedure parameterselect * frommaster mwhere m.@temp_col is not nullSo everytime I can change the column name and run the same stored procedure. This just example I can't give the actual query has it is part of a big system.Thanks for the help." |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-02-28 : 08:16:28
|
| Try thisdeclare @temp_col varchar(50)set @temp_col = 'employee_name'Exec('select * from master m where m.'+@temp_col+' is not null')MadhivananFailing to plan is Planning to fail |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-02-28 : 08:34:42
|
| Hope you have good security on your database, because this will open you up to all kinds of hacking. |
 |
|
|
|
|
|