Ray Ray -4 years ago 178
SQL Question

Insert double quotes into SQL output

After I run a query and view the output, for example

select * from People

My output is as follows

First Last Email
Ray Smith raysmith@whatever.itis

How would I export this data so that it looks as follows?


Or is there a way to do this within SQL to modify records to contain quotes?

Because when you export, it's going to include the commas anyway, right?

Answer Source

If the columns you're interested in are 128 characters or less, you could use the QUOTENAME function. Be careful with this as anything over 128 characters will return NULL.

SELECT QUOTENAME(First, '"'), QUOTENAME(Last, '"'), QUOTENAME(Email, '"')
    FROM People
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download