mhopkins321
mhopkins321

Reputation: 3083

Adding escape characters into select

My data if similar to below

firstName | middleName | lastName |
__________|____________|__________|
   Bob    |   michael  |  Smith   |
   John   |    sam     |  Cook    |

If I want to write a query that returns results that look like this

firstName | middleName | lastName |
__________|____________|__________|
 ('Bob',  |  'michael',| 'Smith') |
 ('John', |  'sam',    | 'Cook')  |

How would I write the escape characters that would also include a paren? Research tells me I'm going to be doing a number of single tics in a row, but I'm having difficulty figuring out how many

Upvotes: 0

Views: 23

Answers (1)

Jussi Kosunen
Jussi Kosunen

Reputation: 8307

Use 2 quotes to escape a quote, so SELECT '(''' + firstName + ''',' AS firstName, ...

Upvotes: 1

Related Questions