How to concatenate a column value with single quotes and a comma in sql?
select tpaa_id from dbo.Sheet
where tpaa_id is not null
At present query returns, value as ..
ABC123
ABC456
We have around 1000 records.
I expect to return as
'ABC123',
'ABC456',
ANSI SQL has || as concatenation operator, while some products have a concat() function. Simply: 'My name' || '''' . I.e. double the single quote inside a string literal.
To concatenate a quote mark in a calculation formula, put \" between quotations. In essence, the FirstName field is concatenated with a space, the double-quote character, the Nickname, the double-quote character, a space and the LastName.
Example SQL with Quotes. So here I have an example where I've declared some text, and I'm setting the text equal to my parent's car is broken. And here you can see I have a possessive “s”, with a single quote. DECLARE @text as NVARCHAR(400) SET @text = 'My Parent's car is broken.
Use this construction
SELECT CONCAT(CHAR(39), MyString ,CHAR(39)) FROM Table
return '<MyString>'
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