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 |
|
antogonzal
Starting Member
1 Post |
Posted - 2004-10-26 : 03:30:01
|
| Hi all,Anyboy has got a way to parametrize a column so that it was possible to asign an external value to its name ?For example in an UPDATE example like this:UPDATE TableSET columm_name = newdata WHERE ( another_column = 'whatever')instead of using column_name, passing it as a parameter, like this:@variable VARCHAR (20)UPDATE TableSET @variable = newdata WHERE ( another_column = 'whatever')if you try to pass column_name as a parameter to @variable, it would not work at all.Is there any way of making this idea work ?There would be lots of uses for it, like converting colums to rows in a parametrized way, etc...Thanks !RegardsToni |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-10-26 : 03:37:01
|
| declare @sql varchar(1000)select @sql = 'update table set ' + @columnname + ' = ''whatever'' where anothercolumn = ''whatever'''exec (@sql)>> There would be lots of uses for itNot really - usually a sign of poor design.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|