danglesauce19
danglesauce19

Reputation: 133

SQL Server - Add text at the beginning of each record

I need to add the same string to the beginning of each record for a varchar column. How would I go about doing this?

So the contents in that column currently look like this:

| TableNames |
--------------
| Table1     |
| Table2     |
| Table3     |
| Table4     |

And I want them to be:

| TableNames |
--------------
| dbo.Table1 |
| dbo.Table2 |
| dbo.Table3 |
| dbo.Table4 |

Upvotes: 0

Views: 2683

Answers (1)

Ian
Ian

Reputation: 30813

You could update the table by using its own entry (TableNames column) like this:

update MyTable set TableNames = 'dbo.' + TableNames;
commit;

and commit is just to commit the execution result.

Upvotes: 1

Related Questions