How can I restore an .sql file?

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
draneb
Captain (CAPT)
Captain (CAPT)
Posts: 314
Joined: Sun Jun 12, 2005 4:07 pm
Location: Texas
Contact:

How can I restore an .sql file?

Post by draneb » Tue Sep 15, 2009 4:22 pm

I am moving hosting companies, switching from a shared hosting environment to a Windows 2008 VPS machine.

I used Microsoft Database Publishing Wizard to get an .sql file of the old database.
I want to execute that on the new server so that I can replicate the database but I can't figure out how.

Both databases are SQL 2005 and both are run on dedicated machines separate from the hosting. I have been using Microsoft Studio Management Studio Express to tinker around with things but I am lost...

The .sql file is about 250MB. I am just wasting days trying to search Google on how to do this. I thought I was ask you extremely intelligent folks how to accomplish this.

Thank you very much!
AC 7.0.3 build 13937

sdlong02
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 95
Joined: Mon Jan 19, 2009 2:33 pm

Re: How can I restore an .sql file?

Post by sdlong02 » Tue Sep 15, 2009 4:55 pm

Right click "Databases", choose "Restore Database", source should be "From device:" browse for database file

Directions are for SQL Server Management Studio, but they should be similar enough

User avatar
draneb
Captain (CAPT)
Captain (CAPT)
Posts: 314
Joined: Sun Jun 12, 2005 4:07 pm
Location: Texas
Contact:

Re: How can I restore an .sql file?

Post by draneb » Fri Oct 02, 2009 9:26 am

Hello,

That seems to only work with .bak files.

I was only able to get a .sql file using SQL Database Publishing Wizard. I do have Microsoft Studio Management Studio Express but the file is too large to copy and paste the contents into the SQL Query window.

Is there a command I can enter to execute the sql script from my hard drive or from the new server?

Thank you.
AC 7.0.3 build 13937

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: How can I restore an .sql file?

Post by jmestep » Fri Oct 02, 2009 10:26 am

You can click on the database in Mgmt studio, then do file-->open and search for the .sql file. It might work, but you also might get a not enough memory error.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
nickc
Captain (CAPT)
Captain (CAPT)
Posts: 276
Joined: Thu Nov 29, 2007 3:48 pm

Re: How can I restore an .sql file?

Post by nickc » Sat Oct 03, 2009 11:06 am

The "sqlcmd" (or older "osql") command line utilities are probably your best bet. Use "sqlcmd -?" to get full syntax.
Expect you would use something like "sqlcmd -E -S<ServerName> -d<DatabaseName> -i<NameOfYourBigSQLFile> -o<FileToSaveOutputResult>".

You don't indicate if the input is just data, or data+schema. You'll need to plan around what is in the .sql file and what is in the db you run it against; for instance if the target db is blank (schema included), does the file also contain user/login info, etc. - otherwise you'll have to create and map yourself once executed.

Too bad you couldn't get a bak file. Much simpler.

Cheers,
-Nick

Post Reply