tags:

views:

348

answers:

4

Please help me to create a Export like Export and Import Opttion in in SQL Server 2005

+1  A: 

Here's an example.

gmcalab
+4  A: 

Are you looking for something like this or this?

EDIT: Here is another example.

Michel Kogan
Thank u. But i want Sql Server Database to Sql Server DatabaseYa thak u .Second one .But i unable to under stand code.Could u help me to get it in easy way
kiran
Thank u . Igot it
kiran
Excuse me? Neither your question nor comments make any sense to me.
Peter Lindqvist
Sounds to me like you want to be spoon fed everything instead of doing some trial and error. That is not what this site is here to do.
gmcalab
+1 for understanding and answering this question. :)
Peter Lindqvist
Sorry for that, i understand, what i want
kiran
@gmcalab I agree with you, but I just wanna help. @kiran you should improve your English skills.
Michel Kogan
Michel Kogan
A: 

SqlBulkCopy is the command that you want to use to import/export data to/from a SQL Server database. Here are a couple good articles with example code: www.codeproject.com/KB/database/Cs_CSV_import_export.aspx

www.davidhayden.com/blog/dave/archive/2006/05/31/2976.aspx

Bill W
Thanku u r Example is very useful for me
kiran
If one of the answers given gave you what you needed then you should "Accept" it. This will remove this question from the "Unanswered questions" list."To mark an answer as accepted, click on the check mark beside the answer to toggle it from hollow to green."
Bill W
A: 

Just send the needed sql statement to the server with a SqlCommand.ExecuteNonQuery().

For Backup:

BACKUP DATABASE [YourDatabaseName] TO  DISK = N'FileName' WITH NOFORMAT, INIT,  NAME = N'YourDatabaseName', SKIP, NOREWIND, NOUNLOAD,  STATS = 10

For Restore:

RESTORE DATABASE [YourDatabaseName] FROM  DISK = N'FileName' WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 10

Or if you like just use (like already mentioned by others) the SqlBulkCopy class.

Oliver