1.sql2005的数据库还原到sql2000
一老外文章,按步骤做就可以了As you may all know, SQL Server 2005 request a minimum of 8GB RAM to work… let's say satisfactorily. I first didn't know that and after a while from the upgrade I did from SQL Server 2000 to 2005 my SQL Services were starting to crash three or four times per DAY!!! At first I thought I was being attacked, but soon I realized it was nothing like that. I then decided to downgrade to a SQL Server 2000 edition. Though I looked around the internet to find some information on how to do that, I got very disappointed when I realized that no actual documentation of any kind could be found for that. So I am posting this thread to inform you on the procedures I had to follow for this action. Before beginning I must assume, firstly that the user, who will attempt such thing, has a basic knowledge of SQL Environment, secondly that he has the two versions already installed (both 2000 and 2005), that a basic backup of the databases has been created and finally that all the 2005 SQL Server Users have been created at the SQL Server 2000 environment as well.Step 1: Generating Scripts for the Database Elements and Structures1. Right-click over the desired Database at 2005, Choose Tasks and the Generate Scripts (Option). 2. At the pop-up Dialog Box click at the Script All Objects in the selected Databases check box, to activate it and then Click the Next Button. 3. Set the following Elements to the following Values 1. Script Collation , set to TRUE 2. Script Database Create, set to TRUE 3. Script of SQL Version, set to SQL SERVER 2000 4. Script foreign keys, set to FALSE 5. Script Triggers, set to FALSE Then Hit the Next button4. Select the way the generated scripts should be saved (There are different selections. The most common one is Clipboard). Finally click the Next button till you reach the end. 5. Click FinishAfter completing this procedure, we have to move to the SQL SERVER 2000 environment. Here, by using the Query Analyzer, we will have to run the scripts that were generated using the master database. Copy and Paste the script at the Query Analyzer and run it. After that the Structure of the Database will be created.Be careful, the SQL Server 2005 Edition inserts the Views in a random place through the script. Therefore, all the scripts that are referred to the Views MUST be moved to the end of the script. If the Query Analyzer shows some errors do not be bothered. Delete all the elements created from the script and after you fix the code run it again.Step 2: Moving the data from 2005 to 20001. After completing the previous step successfully, moving the data follows. Right-click at the 2005 database you used to run the previous step and select Tasks and then choose the Export Data (option). 2. From the pop-up Dialog Box, select the Source Db and Click at the Next Button. 3. At the next step you will have to choose the destination server and the destination Database for the Data to be exported. Then Click Next. 4. A List of all the Source Database's Elements will appear in the screen. Select one by one all the Elements you wish to move and for each one click at the button Edit Mappings (Located at the bottom right corner of the Dialog Box just under the Elements list). A new Dialog box will pop-up. Select the Delete rows in Destination Tables option and activate the Enable Identity Insert Option. (Remember to repeat this action for each of the selected Element from the list that will be moved.CAUTION!!! A malfunction of the SQL Server 2005 has been found. Not sure why, after multiple tries I have observed that when I tried to move more than twelve Elements at once, the Export Data Wizard of SQL Server 2005 seemed to disable the Enable Identity Insert Option that was activated over the Edit Mappings Dialog Box. But if the number of the selected Elements is smaller than 12 no problem seemed to appear.Step 3: Generating Scripts for the Database Foreign Keys and TriggersFinally, to successfully finish the downgrade of the Database, the Triggers and the Foreign Keys of the DB must be produced. The procedure that should be followed is the one stated next:1. Right-Click at the SQL 2005 Database and Select from Tasks Menu the Generate Scripts Option. 2. Using the pop-up Dialog Box make sure that the check box Script All Objects in the selected Databases is not enabled and hit the Next Button. 3. Set all the Elements on the List to a False Value except the ones that follow: 1. Include IF NOT EXISTS , set to TRUE 2. Script Owner, set to TRUE 3. Script of SQL Version, set to SQL SERVER 2000 4. Script foreign keys, set to TRUE 5. 。
2.SQL2000数据库可以还原SQL2005的备份文件吗
其他地方找到的: sql2005中的备份要在sql2000中还原,首先在sql2005中还原,然后选择兼容sql2000(80),备份后再在sql2000种还原。
用mdf和ldf来备份数据库,首先要分离数据库,右键备份数据库-任务-分离,对数据库分离,数据库的readonly要为false。分离后,在sql的data目录下找到要备份的mdf和ldf数据库。
还原时选择附加数据库,选择对应的mdf和ldf文件,附加即可。要判断要附加的数据库是否为只读,如果是,要去掉只读属性。
要附加的数据库文件即mdf和ldf文件的安全设置中设置user用户完全控制权限,即为数据库文件的属性,设置成功后才可以附加。否则会抱错,要附加的数据库为只读。
要导出数据库脚本时,右键导出的数据库-任务-生成脚本以下是sql语句备份还原数据库: /*--备份数据库 --邹建 2003.10--*/ /*--调用示例 --备份当前数据库 exec p_backupdb @bkpath='c:\',@bkfname='db_\DATE\_db.bak' --差异备份当前数据库 exec p_backupdb @bkpath='c:\',@bkfname='db_\DATE\_df.bak',@bktype='DF' --备份当前数据库日志 exec p_backupdb @bkpath='c:\',@bkfname='db_\DATE\_log.bak',@bktype='LOG' --*/ if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_backupdb]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[p_backupdb] GO create proc p_backupdb @dbname sysname='', --要备份的数据库名称,不指定则备份当前数据库 @bkpath nvarchar(260)='', --备份文件的存放目录,不指定则使用SQL默认的备份目录 @bkfname nvarchar(260)='', --备份文件名,文件名中可以用\DBNAME\代表数据库名,\DATE\代表日期,\TIME\代表时间 @bktype nvarchar(10)='DB', --备份类型:'DB'备份数据库,'DF' 差异备份,'LOG' 日志备份 @appendfile bit=1 --追加/覆盖备份文件 as declare @sql varchar(8000) if isnull(@dbname,'')='' set @dbname=db_name() if isnull(@bkpath,'')='' set @bkpath=dbo.f_getdbpath(null) if isnull(@bkfname,'')='' set @bkfname='\DBNAME\_\DATE\_\TIME\.BAK' set @bkfname=replace(replace(replace(@bkfname,'\DBNAME\',@dbname) ,'\DATE\',convert(varchar,getdate(),112)) ,'\TIME\',replace(convert(varchar,getdate(),108),':','')) set @sql='backup '+case @bktype when 'LOG' then 'log ' else 'database ' end +@dbname +' to disk='''+@bkpath+@bkfname +''' with '+case @bktype when 'DF' then 'DIFFERENTIAL,' else '' end +case @appendfile when 1 then 'NOINIT' else 'INIT' end print @sql exec(@sql) go ---------------------------------------------------------------------- /*--恢复数据库 --邹建 2003.10--*/ /*--调用示例 --完整恢复数据库 exec p_RestoreDb @bkfile='c:\db_20031015_db.bak',@dbname='db' --差异备份恢复 exec p_RestoreDb @bkfile='c:\db_20031015_db.bak',@dbname='db',@retype='DBNOR' exec p_backupdb @bkfile='c:\db_20031015_df.bak',@dbname='db',@retype='DF' --日志备份恢复 exec p_RestoreDb @bkfile='c:\db_20031015_db.bak',@dbname='db',@retype='DBNOR' exec p_backupdb @bkfile='c:\db_20031015_log.bak',@dbname='db',@retype='LOG' --*/ if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_RestoreDb]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[p_RestoreDb] GO create proc p_RestoreDb @bkfile nvarchar(1000), --定义要恢复的备份文件名 @dbname sysname='', --定义恢复后的数据库名,默认为备份的文件名 @dbpath nvarchar(260)='', --恢复后的数据库存放目录,不指定则为SQL的默认数据目录 @retype nvarchar(10)='DB', --恢复类型:'DB'完事恢复数据库,'DBNOR' 为差异恢复,日志恢复进行完整恢复,'DF' 差异备份的恢复,'LOG' 日志恢复 @filenumber int=1, --恢复的文件号 @overexist bit=1, --是否覆盖已经存在的数据库,仅@retype为 @killuser bit=1 --是否关闭用户使用进程,仅@overexist=1时有效 as declare @sql varchar(8000) --得到恢复后的数据库名 if isnull(@dbname,'')='' select @sql=reverse(@bkfile) ,@sql=case when charindex('.',@sql)=0 then @sql else substring(@sql,charindex('.',@sql)+1,1000) end ,@sql=case when charindex('\',@sql)=0 then @sql else left(@sql,charindex('\',@sql)-1) end ,@dbname=reverse(@sql) --得到恢复后的数据库存放目录 if isnull(@dbpath,'')='' set @dbpath=dbo.f_getdbpath('') --生成数据库恢复语句 set @sql='restore '+case @retype when 'LOG' then 'log ' else 'database ' end+@dbname +' from disk='''+@bkfile+'''' +' with file='+cast(@filenumber as varchar) +case when @overexist=1 and @retype in('DB','DBNOR') then ',replace' else '' end +case @retype when 'DBNOR' then ',NORECOVERY' else ',RECOVERY' end print @sql --添加移动逻辑文件的处理 if @retype='DB' or @retype='DBNOR' begin --从备份文件中获取逻辑文件名 declare @lfn nvarchar(128),@tp char(1),@i 。
3.为什么sql2000的数据库还原不到sql2005上
From the pop-up Dialog Box, select the Source Db and Click at the Next Button. 3. At the next step you will have to choose the destination server and the destination Database for the Data to be exported. Then Click Next. 4. A List of all the Source Database's Elements will appear in the screen. Select one by one all the Elements you wish to move and for each one click at the button Edit Mappings (Located at the bottom right corner of the Dialog Box just under the Elements list). A new Dialog box will pop-up. Select the Delete rows in Destination Tables option and activate the Enable Identity Insert Option. (Remember to repeat this action for each of the selected Element from the list that will be moved.CAUTION!!! A malfunction of the SQL Server 2005 has been found. Not sure why, after multiple tries I have observed that when I tried to move more than twelve Elements at once, the Export Data Wizard of SQL Server 2005 seemed to disable the Enable Identity Insert Option that was activated over the Edit Mappings Dialog Box. But if the number of the selected Elements is smaller than 12 no problem seemed to appear.Step 3: Generating Scripts for the Database Foreign Keys and TriggersFinally, to successfully finish the downgrade of the Database, the Triggers and the Foreign Keys of the DB must be produced. The procedure that should be followed is the one stated next:1. Right-Click at the SQL 2005 Database and Select from Tasks Menu the Generate Scripts Option. 2. Using the pop-up Dialog Box make sure that the check box Script All Objects in the selected Databases is not enabled and hit the Next Button. 3. Set all the Elements on the List to a False Value except the ones that follow: 1. Include IF NOT EXISTS , set to TRUE 2. Script Owner, set to TRUE 3. Script of SQL Version, set to SQL SERVER 2000 4. Script foreign keys, set to TRUE 5. Script Triggers, set to TRUE 6. Then Hit the Next button 4. After finishing reading the Elements of the Database, a new list will appear at the Dialog Box. Make sure that you select ONLY THE TABLES of the Database and hit the Next Button. 5. At the screen that follows hit the Select All button and the Next. 6. Select the way the generated scripts should be saved (There are different selections. The most common one is Clipboard). Finally click the Next button till you reach the end. 7. Click Finish Button.After completing this procedure, we have to move to the SQL SERVER 2000 environment. Here, by using the Query Analyzer, we will have to run the scripts that were generated using the master database. Copy and Paste the script at the Query Analyzer and run it. After that the Foreign Keys and the Triggers of the Database will be created.After these steps the database should be fully functional under the SQL Server 2000 edition., the SQL Server 2005 Edition inserts the Views in a random place through the script, we will have to run the scripts that were generated using the master database. Copy and Paste the script at the Query Analyzer and run it. After that the Structure of the Database will be created.Be careful. Script foreign keys, to activate it and then Click the Next Button. 3. Right-click over the desired Database at 2005, has a basic knowledge of SQL Environment, moving the data follows. Right-click at the 2005 database you used to run the previous step and select Tasks and then choose the Export Data (option). 2. Delete all the elements created from the script and after you fix the code run it again.Step 2. Select the way the generated scripts should be saved (There are different selections. The most common one is Clipboard)! At first I thought I was being attacked, but soon I realized it was nothing like that. I then decided to downgrade to a SQL Server 2000 edition. Though I looked around the internet to find some information on how to do that, I got very disappointed when I realized that no actual documentation of any kind could be found for that. So I am posting this thread to inform you on the procedures I had to follow for this action. After completing the previous step successfully. Before beginning I must assume. Therefore, all the scripts that are referred to the Views MUST be moved to the end of the script!!, Choose Tasks and the Generate Scripts (Option), set to SQL SERVER 2000 4, set to FALSE 5, secondly that he has the two versions already installed (both 2000 and 2005), set to FALSE Then Hit the Next button4: Moving the data from 2005 to 20001. Set the following Elements to the following Values 1. Script Collation , set to TRUE 2. If the Query Analyzer shows some errors do not be bothered. Script Triggers. Script。
4.怎么让sql 2000的数据还原到2005上
select the Source Db and Click at the Next Button. 3. At the next step you will have to choose the destination server and the destination Database for the Data to be exported. Then Click Next. 4. A List of all the Source Database's Elements will appear in the screen. Select one by one all the Elements you wish to move and for each one click at the button Edit Mappings (Located at the bottom right corner of the Dialog Box just under the Elements list). A new Dialog box will pop-up. Select the Delete rows in Destination Tables option and activate the Enable Identity Insert Option. (Remember to repeat this action for each of the selected Element from the list that will be moved.CAUTION!!! A malfunction of the SQL Server 2005 has been found. Not sure why, after multiple tries I have observed that when I tried to move more than twelve Elements at once, the Export Data Wizard of SQL Server 2005 seemed to disable the Enable Identity Insert Option that was activated over the Edit Mappings Dialog Box. But if the number of the selected Elements is smaller than 12 no problem seemed to appear.Step 3: Generating Scripts for the Database Foreign Keys and TriggersFinally, to successfully finish the downgrade of the Database, the Triggers and the Foreign Keys of the DB must be produced. The procedure that should be followed is the one stated next:1. Right-Click at the SQL 2005 Database and Select from Tasks Menu the Generate Scripts Option. 2. Using the pop-up Dialog Box make sure that the check box Script All Objects in the selected Databases is not enabled and hit the Next Button. 3. Set all the Elements on the List to a False Value except the ones that follow: 1. Include IF NOT EXISTS , set to TRUE 2. Script Owner, set to TRUE 3. Script of SQL Version, set to SQL SERVER 2000 4. Script foreign keys, set to TRUE 5. Script Triggers, set to TRUE 6. Then Hit the Next button 4. After finishing reading the Elements of the Database, a new list will appear at the Dialog Box. Make sure that you select ONLY THE TABLES of the Database and hit the Next Button. 5. At the screen that follows hit the Select All button and the Next. 6. Select the way the generated scripts should be saved (There are different selections. The most common one is Clipboard). Finally click the Next button till you reach the end. 7. Click Finish Button.After completing this procedure, we have to move to the SQL SERVER 2000 environment. Here, by using the Query Analyzer, we will have to run the scripts that were generated using the master database. Copy and Paste the script at the Query Analyzer and run it. After that the Foreign Keys and the Triggers of the Database will be created.After these steps the database should be fully functional under the SQL Server 2000 edition.. At the pop-up Dialog Box click at the Script All Objects in the selected Databases check box, to activate it and then Click the Next Button. 3. Set the following Elements to the following Values 1.Step 2: Moving the data from 2005 to 20001. After completing the previous step successfully, moving the data follows, set to TRUE 2. Script Database Create. Script Collation , I got very disappointed when I realized that no actual documentation of any kind could be found for that, by using the Query Analyzer, we will have to run the scripts that were generated using the master database. The most common one is Clipboard). Finally click the Next button till you reach the end. 5. So I am posting this thread to inform you on the procedures I had to follow for this action. Before beginning I must assume, firstly that the user, who will attempt such thing, has a basic knowledge of SQL Environment, secondly that he has the two versions already installed (both 2000 and 2005), that a basic backup of the databases has been created and finally that all the 2005 SQL Server Users have been created at the SQL Server 2000 environment as well. Here.Step 1: Generating Scripts for the Database Elements and Structures1. Right-click over the desired Database at 2005, Choose Tasks and the Generate Scripts (Option). 2!! At first I thought I was being attacked. I first didn't know that and after a while from the upgrade I did from SQL Server 2000 to 2005 my SQL Services were starting to crash three or four times per DAY!, all the scripts that are referred to the Views MUST be moved to the end of the script. If the Query Analyzer shows some errors do not be bothered. Delete all the elements created from the script and after you fix the code run it again.Be careful, the SQL Server 2005 Edition inserts the Views in a random place through the script. Therefore. 2. From the 。
转载请注明出处51数据库 » downgradegenerated