Insert single qoutes into a column for a SQL table

Culbertson Geoffrey 60 Reputation points

This seems simple enough but I am struggling with how to do it. I need add single quotes around all the records in a column call Manager in a table called ChronusExport. I know how to add them in a select statement but not how to do a bulk update to all the records in that table.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
10,920 questions
{count} votes

Accepted answer
  1. Erland Sommarskog 87,271 Reputation points

    So use the same SELECT statement, but just add INSERT on top;

    INSERT (col1, col2, col3, ..)
    SELECT ..., quotname(Manager, ''''), ...

    Note that quotename will return NULL if the input is more than 128 characters.

    Note also that qoutename will also double any single quotes in the Manager column. So Brian O'Brien will result in 'Brian O''Brien'.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful