Skip to content

Instantly share code, notes, and snippets.

@Dzoge
Created January 28, 2021 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dzoge/ebf7be3d3a6de1ff3b4334aa01e5e5b4 to your computer and use it in GitHub Desktop.
Save Dzoge/ebf7be3d3a6de1ff3b4334aa01e5e5b4 to your computer and use it in GitHub Desktop.
Replace text in all NVARCHAR type columns in all tables
SELECT
'UPDATE ['+TABLE_SCHEMA+'].['+table_name+'] SET ['+column_name+'] = REPLACE(['+column_name+'], ''existing-text'', ''new-text'');'
--,table_name as [TableName]
--,column_name as [ColumnName]
--,TABLE_SCHEMA as [SchemaName]
from information_schema.columns
where data_type = 'nvarchar'
and character_maximum_length=-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment