I wish to create an SQL statement in the form:
SELECT tblgrades.SearchText
FROM tblGrades
where tblGrades is the table being queried and SearchText is a variable
whose value is supplied by the user. Is this the right syntax? I want
the user to be able to ask for a column of values from a database.
Thanks for any help you can supply.
Zach Dezman
declare @columnName sysname
select @columnName = 'SearchText'
exec ('select ' + @columnName + ' from tblGrades')
---------------------------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc) which can be
cut and pasted into Query Analyzer is appreciated.
Zachary Dezman <zde...@mines.edu> wrote in message
news:39578F28...@mines.edu...