Column-name and/or table-name as parameters
Given following snippet (MS SQL):

    DECLARE UpdateList CURSOR FOR
	SELECT MyColumn FROM MyTable
    OPEN UpdateList

Nothing fancy so far. Now I would like to declare two variables where I can write the column's and table's name into. Following, of course, wouldn't work. How can I achieve this?


    DECLARE @TableName nchar(20) = 'MyTable'
    DECLARE @ColumnName nchar(20) = 'MyColumn'
    DECLARE UpdateList CURSOR FOR
	SELECT @ColumnName FROM @TableName
    OPEN UpdateList

Thx for any tipps
sl3dg3
Column-name and/or table-name as parameters
===

Given following snippet (MS SQL):

    DECLARE UpdateList CURSOR FOR
	SELECT MyColumn FROM MyTable
    OPEN UpdateList

Nothing fancy so far. Now I would like to declare two variables where I can write the column's and table's name into. Following, of course, wouldn't work. How can I achieve this?


    DECLARE @TableName nchar(20) = 'MyTable'
    DECLARE @ColumnName nchar(20) = 'MyColumn'
    DECLARE UpdateList CURSOR FOR
	SELECT @ColumnName FROM @TableName
    OPEN UpdateList

Thx for any tipps
sl3dg3