Link to home
Start Free TrialLog in
Avatar of jedistar
jedistarFlag for Singapore

asked on

Create tables in a faster easier way

Hi,

I have abt 100 tables in my MS SQL Server 2000.

I would like to ask how can i generate a script that will auto these
tables when i move them to another server.

I also need to change the owner for each table, how do i do that?

Thanks.
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

use the MS_foreachTAble  stored procedure

and run the sp_changeowner stored procedure First?

to script out the tables in the first place...
just right click the database in enterprise manager and
select all task  - script ...

make sure your visit each SCREEN and select all the required functions
e.g. indexes / constraints, etc...


but this should be a task you use your modelling/design tool for....  

what did you use to design the database in the first place...



Avatar of jedistar

ASKER

i merely added tables/fields etc.

what is MS_foreachTAble  stored procedure
and sp_changeowner stored procedure ?

How again.
Avatar of Sirees
Sirees

To change the owner for all tables of a database at once

You can use the undocumented function ms_foreachtable and the stored procedure sp_changeobjectowner in Query Analyzer to archive that quite easy.

Example to take over for dbo: sp_msforeachtable "sp_changeobjectowner '?', 'dbo'".

hrm still don't understand
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada 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