Link to home
Start Free TrialLog in
Avatar of pkr2606
pkr2606

asked on

T-sql to change schema of all tables

I have a table in which there are fields like
Schema      
Name of table  
Create_date      
Modify_date      
Action       
Owner

I would like to change schema of all the tables into one particular schema..i need a t-sql to change as there are many tables
Avatar of Aneesh
Aneesh
Flag of Canada image

if you just need to change the schema in that particular table use this

UPDATE tableName set [Schema] = 'newSchemaName'
Avatar of pkr2606
pkr2606

ASKER

HI, first I need to crate a copy of all tables and then delete. Instead of updating can you tell me to copy tables to different schema in a loop.
ASKER CERTIFIED SOLUTION
Avatar of ProjectChampion
ProjectChampion
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Additional IMPORTANT NOTE: Please ensure that you have scripted all the permission of original object before transferring to new schema because permissions granted to original object e.g. dbo.testTable will be removed during transfer.