Pass column value to function in dynamic query string

So I've got this:

select @sql = .select abc.1
FROM Test1 abc
cross apply(udf_create_Test_No(abc.1)).

Says incorrect syntax near abc

Because it's in a string do I need to open and close the string round the column value?




what are you trying to do .. !!
how does the output come !!!
based on this the answer can be given !!

Try this = is this what you are looking for
select @sql = ' select ' + abc.1 .... rest of query ...

I'm trying to run a function in the query and I am passing a column value and a variable in the call.

I'm trying ''+@variable+'' or '+@variable+'

And ' +mytable.column + '

How do I get the value to come through so that it can be passed to the function.

select cast(column1 as varchar) +cast( @var as varchar) from sample_data

Thanks, for this particular one I used '''+Cast(@TableName AS NVARCHAR(40)) +''' and it worked. Forgot the 3 single quotes either side if you're already in a string