Just wondered if you could help me, im fairly new to SQL. I can write querys fine but now im looking to use variables in a query.
What i have is the following:
DECLARE @CLIENT varchar(20),
@TABLE_NAME varchar(100)
SET @CLIENT = '1'
SET @TABLE_NAME =
now i want the @TABLE_NAME variable to be the result of the following query:
SELECT TABLE_NAME FROM CUSTOMERS WHERE CUSTOMER_REF = @CLIENT
which returns the result of CLIENT_ABC
so the @TABLE_NAME variable would become CLIENT_ABC
if you could explain how todo this that would be appreciated.
What i have is the following:
DECLARE @CLIENT varchar(20),
@TABLE_NAME varchar(100)
SET @CLIENT = '1'
SET @TABLE_NAME =
now i want the @TABLE_NAME variable to be the result of the following query:
SELECT TABLE_NAME FROM CUSTOMERS WHERE CUSTOMER_REF = @CLIENT
which returns the result of CLIENT_ABC
so the @TABLE_NAME variable would become CLIENT_ABC
if you could explain how todo this that would be appreciated.