Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: Database: MS SQL Server
 SQL Server 2005 migration (how to change schemas)
 New Topic  Topic Locked
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 2

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 24 May 2008 :  06:52:57  Show Profile  Send ruirib a Yahoo! Message
You'd just need to change one of the schemas. I don't have a script lying around for that and would need to have a look at how I'd write it.<


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Astralis
Senior Member

USA
1218 Posts

Posted - 24 May 2008 :  06:55:57  Show Profile  Send Astralis a Yahoo! Message
quote:

You need no server roles to access tables, that is determined by the database roles, not the server roles. Even accessing tables, you don't even need db_owner role, you can settle with "lesser" roles.


Okay...I'm understanding this more. I appreciate it. Why do you think I'm getting that permissions error?
quote:

You'd just need to change one of the schemas


Yes, one schema has about 200 tables. The other schema has a little more than that. The table was designed like this because the host only allowed one database when I setup the account ages ago. Now they allow you to have five databases.<

Edited by - Astralis on 24 May 2008 06:56:25
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 24 May 2008 :  07:04:29  Show Profile  Send ruirib a Yahoo! Message
Well I haven't done that before and it would take me a while to write such a script. Probably the easiest way would be to do a database migration consisting of three steps:

1. Generate a script for all your database tables (and other relevant objects), in SQL Server 2000, not including the object owner
2. Use the script in a new database, to completely recreate the table structure. Like this all tables would be created in the same schema.
3. Transfer the data between the databases as explained in several posts regarding Access to SQL Server migration.<


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 24 May 2008 :  07:41:01  Show Profile  Send ruirib a Yahoo! Message
Actually it was easier than I thought. This one will transfer the objects from astralis into dbo. To change the order, just change the values of @startSchema and @endSchema.

Here you go:

DECLARE @tname varchar(100)
DECLARE @v varchar (200)
DECLARE @startSchema varchar(20)
DECLARE @endSchema varchar(20)


SET @startSchema = 'astralis'
SET @endSchema = 'dbo'

DECLARE testCursor CURSOR
FOR SELECT TABLE_NAME FROM INFORMATION_SCHEMA.tables WHERE TABLE_SCHEMA=@startSchema

OPEN testCursor

FETCH NEXT FROM testCursor INTO @tname

WHILE @@FETCH_STATUS=0
BEGIN
 
  
    SET @v = 'ALTER SCHEMA ' + @endSchema + ' TRANSFER ' + @startSchema + '.' + @tname

    EXEC(@v)

    FETCH NEXT FROM testCursor INTO @tname
END

CLOSE testCursor
DEALLOCATE testCursor
<


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Astralis
Senior Member

USA
1218 Posts

Posted - 24 May 2008 :  09:32:24  Show Profile  Send Astralis a Yahoo! Message
Ruirib,

Thank you! I'll get back to you later today.<
Go to Top of Page

Astralis
Senior Member

USA
1218 Posts

Posted - 27 May 2008 :  00:57:04  Show Profile  Send Astralis a Yahoo! Message
Ruirib,

This is brilliant! Thank you so much!

I suspect more people will be running into this as they upgrade to 2005 or more. Wonderful stuff.

I actually found two non-forum tables that had the same name but different schema. It might be worthwhile placing the forum files in its own database? I don't know, though. Maybe there should be a way to for future releases (.net) to explicitly state as a variable what the schema the forum tables use.<
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 27 May 2008 :  02:06:52  Show Profile  Send ruirib a Yahoo! Message
Glad it worked .<


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 27 May 2008 :  03:19:55  Show Profile  Visit HuwR's Homepage
the forum tables would allways be created in the schema of the user used in Snitz, that is one of the reasons we allways say to use the forum code to create the tables. also if your user is correctly setup as the db owner it should have no issues accessing any schema in the db, astralis or dbo it does not matter.

quote:
Maybe there should be a way to for future releases (.net) to explicitly state as a variable what the schema the forum tables use.
you can do this in the asp version by simply prepending the schema name to the table prefix in config.asp<
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Previous Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000 Version 3.4.07