2

At mssql I want concat ' and 1 string

Example: Concat ('My name',''')

Ouput : My name'

2
  • Which dbms are you using? ANSI SQL has || as concatenation operator, while some products have a concat() function. Commented Apr 4, 2018 at 13:39
  • Simply: 'My name' || ''''. I.e. double the single quote inside a string literal. Commented Apr 4, 2018 at 13:42

2 Answers 2

11

Double-up the single quote character

Try this:

SELECT CONCAT('My name','''')

Ouput:

My name'
Sign up to request clarification or add additional context in comments.

Comments

9

Or you can use '+':

select 'My Name'+''''

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.