Home > database >  Select the heel variable, showing "invalid column name"?
Select the heel variable, showing "invalid column name"?

Time:10-31

I use Microsoft SQL problem encountered is that after the select variables, shows no column name, in fact is the column name, beg god give directions!

Declare @ field name nvarchar (255)
The set @ field name=source type
Select distinct target vouchers, @ the field names from [K001]

After execution system shows: message 207, level 16, state 1, 43 ranks' source type is invalid,

CodePudding user response:

 DECLARE @ field name NVARCHAR (255); 
The SET @ field name='source types;
EXEC (' credentials the select distinct goals, '+ @ field name +' from [K001] ');

CodePudding user response:

This kind of situation, you have to use splicing in the form of SQL, then use the exec to perform
  • Related