Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to Export a Database

Author  Topic 

palaparu
Starting Member

20 Posts

Posted - 2010-10-28 : 12:31:33
How to Export a Database

source db : 5 tables each with 1 million rows
Destination : 5 tables each with top 10,000 rows

can any one help

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-10-28 : 12:40:11
one time shot? use import/export wizard.

if it needs to run periodically, use SSIS and schedule it via sql agent job
Go to Top of Page

palaparu
Starting Member

20 Posts

Posted - 2010-10-28 : 12:50:28
just i need only top 10,000 rows only in destination not 1 million rows
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-10-28 : 13:02:44
[code]

DECLARE @n int ; SET @n = 10000
DECLARE @fn varchar(50) ; SET @fn = 'D:\'

SELECT 'bcp SELECT TOP ' + CONVERT(varchar(25),@n) + ' * FROM '
+ TABLE_CATALOG + '.' + TABLE_SCHEMA + '.' + TABLE_NAME
+ ' queryout '
+ @fn + TABLE_CATALOG + '_' + TABLE_SCHEMA + '_' + TABLE_NAME + '_' + CONVERT(varchar(25),@n)+'.dat'
FROM INFORMATION_SCHEMA.Tables
WHERE TABLE_TYPE = 'BASE TABLE'

[/code]


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx





Go to Top of Page
   

- Advertisement -