Wednesday 12 November 2008

Transfer SQL table to different schema (eg dbo)

The SQL command to assign a table to a different schema is:

ALTER SCHEMA newSchemaName TRANSFER [OldSchemaName].MyTable

This can therefore be used to assign tables created under a particular user to dbo (which can be necessary as sometimes stored procedures may fail with "Invalid object name" if tables are not under dbo) as follows:

ALTER SCHEMA dbo TRANSFER [OldSchemaName].MyTable

No comments: