|
|
#1 |
|
Junior Member
Join Date: Mar 2007
Posts: 2
|
Restore SQL database help
sorry guys i'm a noob. How do you restore a database with NSIS and where do i place the code?
|
|
|
|
|
#2 |
|
Member
Join Date: Mar 2007
Location: Italy
Posts: 99
|
you should use you SQL command line utility to execute a sqlscript
to run your SQL command line utility you can use the ExecWait statement If you are using MSSQL on windows machines you can use the MSSQL plugin |
|
|
|
|
#3 |
|
Junior Member
Join Date: Mar 2007
Posts: 2
|
I saw this code on one of the forum questions but it doesnt seem like something i'd use in NSIS code.
___________________________ ::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" exit |
|
|
|
|
#4 |
|
Member
Join Date: Mar 2007
Location: Italy
Posts: 99
|
Your example comes from a batch file I think.
NSIS code would be something like: MSSQL_OLEDB::SQL_Logon /NOUNLOAD "$SQLSERVER" "$SQLUSER" "$SQLPASSWORD" MSSQL_OLEDB::SQL_Execute /NOUNLOAD "alter database $DBNAME set single_user with rollback immediate" MSSQL_OLEDB::SQL_Execute /NOUNLOAD "restore database $DBNAME from disk='${PATH}\${DBNAME}.bak' WITH MOVE '${DBNAME}_Data' TO '${DATADIR}\${DBNAME}_Data.MDF', MOVE '${DBNAME}_Log' TO '${DATADIR}\${DBNAME}_Log.LDF'" MSSQL_OLEDB::SQL_Execute /NOUNLOAD "alter database ${DBNAME} set multi_user" You need MSSQL Plugin and replace variables as appropriate |
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|