My tips

A Mibuso.com weblog

SQL-Util to unlock NAV-db

After you have restored a NAV SQL database to your PC, you may need to unlock the database.

Here is my sql-script: SQL-tool to unlock NAV-DB (SQL-server)

This script creates a new user “TEMPUSER’ in SQL Server and NAV-database so you can log on to the NAV system.


--***************************************************************
--* Set a new user to a Dynamics NAV SQL-database
--*
--* Christer Berntsson, Sweden
--* Ver 2011-12-21
--*
--***************************************************************

use YourDatabase
go

--Create a new user in Your SQL-server
--Usersername must be upercase!
CREATE LOGIN [TEMPUSER]
WITH PASSWORD='1234!"#¤',
DEFAULT_DATABASE=[master],
DEFAULT_LANGUAGE=[us_english],
CHECK_EXPIRATION=OFF,
CHECK_POLICY=OFF

EXEC sys.sp_addsrvrolemember @loginame = N'TEMPUSER', @rolename = N'sysadmin'
GO
--Set User to NAV-database
INSERT INTO [dbo].[User]
([User ID] ,[Password] ,[Name] ,[Expiration Date])
VALUES
('TEMPUSER', '', '', '1753-01-01')

--Set ROLS
INSERT INTO [dbo].[Member Of]
([User ID] ,[Role ID] ,[Company])
VALUES
('TEMPUSER', 'SUPER', '')

January 26th, 2012 Posted by christer | SQL-Script | one comment

1 Comment »

  1. Great!!!

    Comment by Michael Schneider | 2012-01-27

Leave a comment

*
To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
Click to hear an audio file of the anti-spam word