Answers for "how to pass dynamic column name in sql query"

SQL
0

how to pass dynamic column name in sql query

DECLARE @sqlCommand varchar(1000)
DECLARE @columnList varchar(75)
DECLARE @city varchar(75)

SET @columnList = 'AddressID, AddressLine1, City'
SET @city = '''London'''
SET @sqlCommand = 'SELECT ' + @columnList + ' FROM Person.Address WHERE City = ' + @city

EXEC (@sqlCommand)
Posted by: Guest on April-18-2022

Code answers related to "how to pass dynamic column name in sql query"

Code answers related to "SQL"

Browse Popular Code Answers by Language