How do I create my SQL output like the following. (with ,
delimiter)
"1","FUZION",""
How do I create my SQL output like the following. (with ,
delimiter)
"1","FUZION",""
Assuming that you are selecting data from 3 columns -
col1 = '1'
col2 = 'Fuzion'
col3 = ''
You could try something like this -
SELECT '"'+ISNULL(col1,'')+'","'+ISNULL(col2,'')+'","'+ISNULL(col3,'')+'"'
Note - If any of your field is not a VARCHAR - cast it to VARCHAR and then concatenate.
Refer to the below script.
DECLARE @MyOrderList VARCHAR(MAX);
SET @MyOrderList = ''
SELECT @MyOrderList = ISNULL(@MyOrderList ,'') + '"' +ColumnName + '" ,' FROM TableName
SET @MyOrderList = SUBSTRING(@MyOrderList , 1, LEN(@MyOrderList )-1)
SELECT @MyOrderList
Hope this solves your problem.