Skip to content

Instantly share code, notes, and snippets.

@kimsk
Created October 23, 2018 17:31
Show Gist options
  • Select an option

  • Save kimsk/9308a24058547331a50f495d3d8baf52 to your computer and use it in GitHub Desktop.

Select an option

Save kimsk/9308a24058547331a50f495d3d8baf52 to your computer and use it in GitHub Desktop.
generate sp_rename tables in schema
SELECT 'exec sp_rename ''' + t1.name + '.' + t2.name + ''', ''_' + t2.name + ''';'
FROM sys.schemas t1
INNER JOIN sys.tables t2
ON t2.schema_id = t1.schema_id
WHERE t1.name = 'Measurements'
ORDER BY t1.name,t2.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment