sqlserver2005中如何备份数据库中的某几张表?
------解决方案--------------------
建新一个库,用导入导出工具导出你要备份的表到新建的库,再备份刚建的库。
------解决方案--------------------
把这几张表导入另外的一个新建的数据库 然后备份
------解决方案--------------------
- SQL code
/*--备份指定表到另一数据库 备份指定数据库中的指定表列表到一个新的数据库--邹建 2003.12--*//*--调用示例 --备份数据当前数据库的所有内容 exec p_backupdatabase --备份当前数据库的指定表 exec p_backupdatabase @tblist='tb,tb1,tb2'--*/if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_BackupDataBase]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)drop procedure [dbo].[p_BackupDataBase]GOCREATE PROCEDURE p_BackupDataBase@s_dbname sysname='', --要备份的数据库名,如果不指定,则备份当前数据库@d_dbname sysname='', --备份生成的数据库名,如果不指定,则为:@s_dbname+'_bak'@tblist varchar(8000)='' --要备份的表名列表,如果不指定,则表示所有用户表ASdeclare @sql varchar(8000),@err_msg varchar(1000)--参数检测if isnull(@s_dbname,'')='' set @s_dbname=db_name()if isnull(@d_dbname,'')='' set @[email protected]_dbname+'_bak'if exists(select 1 from master..sysdatabases where [email protected]_dbname)begin set @err_msg='备份的数据库 [[email protected]_dbname+'] 已经存在!' goto lb_exitendif not exists(select 1 from master..sysdatabases where [email protected]_dbname)begin set @err_msg='要备份的数据库 [[email protected]_dbname+'] 不存在!' goto lb_exitend--创建备份的数据库set @sql='create database [[email protected]_dbname+']'exec(@sql)--备份表declare @tbname sysnameset @sql='declare tb cursor forselect name from [[email protected]_dbname+']..sysobjects where status>0 and xtype=''U'''+case isnull(@tblist,'') when '' then '' else ' and name in('''+replace(@tblist,',',''',''')+''')' endexec(@sql)open tbfetch next from tb into @tbnamewhile @@fetch_status=0begin set @sql='select * into [[email protected]_dbname+']..[[email protected] +'] from [[email protected]_dbname+']..[[email protected]+']' exec(@sql) fetch next from tb into @tbnameendclose tbdeallocate tblb_exit: if @err_msg<>'' raiserror(@err_msg,1,16)go