Archive: create Database with NSIS


create Database with NSIS
Hallo,

I call msi for install SQL Server Express.
I have an mdf-file and backup-file of my database.
Is it possible create database with NSIS from mdf or backup-files or use sql-scripts?

Thank You.


Hi,

You have two possibilities.
One is use osql. This application is install with SQL SERVER. With this app you can exec sql scripts. For example:
::SET VARIABLES
set DBNAME=NAMEOFDATABASEBEINGRESTORED
set DBDIRECTORY=C:\Program Files\Microsoft SQL Server\MSSQL\Data

TITLE Restoring %DBNAME% Database

::PUT DATABASE IN SINGLE USER MODE TO ALLOW RESTORE
osql -E -d master -Q "alter database %DBNAME% set single_user with rollback immediate"

::RESTORE DATABASE
osql -E -d master -Q "restore database %DBNAME% from disk='%~dp0\%DBNAME%.bak' WITH MOVE '%DBNAME%_Data' TO '%DBDIRECTORY%\%DBNAME%_Data.MDF', MOVE '%DBNAME%_Log' TO '%DBDIRECTORY%\%DBNAME%_Log.LDF'"

::GRANT PERMISSION TO ASPNET USER
osql -E -d %DBNAME% -Q "sp_grantdbaccess '%COMPUTERNAME%\ASPNET'"
osql -E -d %DBNAME% -Q "sp_addrolemember 'db_owner', '%COMPUTERNAME%\ASPNET'"

::RESTORE TO MULTI USER
osql -E -d master -Q "alter database %DBNAME% set multi_user"

pause

The previous example you can find in:
http://weblogs.asp.net/jgalloway/arc...02/432088.aspx


About the second option is do when you start the first time your application.

I have one question to you about the <B>"I call msi for install SQL Server Express"</B>. How you call? I trying to find a example, but without success.

I hope this can help you.


Thanks, pafcosta!

osql was not with SQL Server Express.

I use Microsoft Component Installer 2.0 SDK
for install the needed komponents:
http://www.microsoft.com/downloads/d...displaylang=en

short futures:

The SDK provides support for installing any or all of the following components:

* Microsoft Windows Installer 2.0
* Microsoft Windows Installer 3.1
* Microsoft Data Access Components (MDAC) 2.8
* Microsoft .NET Framework 1.1 and language packs
* Microsoft .NET Framework 1.1 Service Pack 1
* Microsoft Visual J# runtime and language packs
* Microsoft .NET Framework 2.0 (x86) and language packs
* Microsoft Visual J# 2.0 runtime and language packs
* Microsoft DirectX 9.0c (December 2005 )
* Microsoft Report Viewer 2005 redistributable and language packs
* Microsoft Visual Studio 2005 Tools for the Microsoft Office System redistributable and language packs
* Microsoft SQL Server 2005 Express Edition redistributable

then you call yours NSIS - Setup in the file PSetup.ini.
This file belongs to the Microsoft Component Installer 2.0 SDK

PostInstallAction=your-nsis-setup.exe

or you can extract msi-files of sqlserver.exe
i think this option is /r or \r bat not sure.

and then call msi-files from NSIS-setup.

You can call MSI with the line:

Section -demo
ExecWait '"msiexec" /i "$EXEDIR\Demo.msi" /passive '
SectionEnd


New option to Install SQL SERVER Express
I found this in the internet yestarday.
Please see if this help you:
http://www.hoohee.com/PermaLink,guid...3a0b9e7ee.aspx

Thanks
Paulo Costa


You can use sqlcmd (osql replacement in sql2005) or use the MSSQL plugin


why I can't see the URL submitted by the users?
I'm Logged in


astolfo wrote
why I can't see the URL submitted by the users?
I'm Logged in
It's a spam prevention mechanism applied to new posters. (It's a pain, but I don't make the rules.) If you click the "reply" button, you can scroll down and see the URLs. Once you've posted enough times, your level changes and then you can submit URLs that others can actually see.

Here's the link for the Microsoft Component Installer 2.0 SDK:
http://www.microsoft.com/downloads/d...displaylang=en

Can anyone give code example to "create database" with NSIS from metadata.txt? Idea is that first create a database then input the metadata. Please help me with nsis code example.