I often read records from my database and use notepad++ to processing the receipt in this format:
'xxxxxxxxx'
'xxxxxxxxx',
'xxxxxxxxx',
'xxxxxxxxx'
Is there a way I can use SQL query to do this once.
Sample query I ran is:
Select ReceiptNo
from My_table
where TIN = 'KEYVALUE'
This is pretty straightforward concatenation. You need to use 4 quotes here, though: the first and last are your wrapper quotes which contain the string. The inner 2 quotes are your actual quote to use, and an escape quote.
SELECT
'''' + CAST(ReceiptNo as varchar(100)) + ''''
FROM
My_Table
WHERE
TIN = 'KEYVALUE'
You may want to try below:
SELECT
'''' + CAST(ReceiptNo as varchar(100)) + ''','
FROM
My_Table
WHERE
TIN = 'KEYVALUE'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With