Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Change number to a string in query table

Author  Topic 

plumby78
Starting Member

1 Post

Posted - 2015-04-16 : 04:31:42
Hi all,

I'm pretty much a novice at SQL programming so apologies if my question is basic!

I have a query which runs exactly as I want it to. Let's say it returns this in a table:

ID Number
1 23
2 12
3 12

I want to change (find and replace?) all the number 12s in the 'Number' column for a string. Let's say I want to change the 12s to the word: HelloWorld. Can this be done? I don't want to update the table, merely the table that is being returned in the query.

I hope this makes sense.

Maithil
Starting Member

29 Posts

Posted - 2015-04-16 : 04:46:20
Hi

Try This
SELECT REPLACE(CAST(Number as nvarchar),'12','HelloWorld') from Your_TableName
Go to Top of Page
   

- Advertisement -