views:

23

answers:

1

I am executing Dynamic SQL,

sqlQuery = " SELECT ";
sqlQuery += _Allowed + " , "; 
sqlQuery += " + cast( ";
sqlQuery += " _ID as nvarchar ) ";
sqlQuery += " FROM ";
sqlQuery += " TBL_SUCCESS ";  

when i execute it suppose to return common separated values like 2,4,5 in single column

instead it return values in separate column

my MyDataTable suppose to populate

Column1
2,4,5

but it populates

column1  column2  column3
2         4         5   

How to get the output?

+1  A: 

Need to see the value of _Allowed to know what else is happening, but you need to at least put quotes around the comma and concatenate it inside the SQL statement, like this:

sqlQuery += _Allowed + " + ' , ' ";  
RedFilter