Category Archives: MSSQL

Change SQL Collation

Steps for chaning Collation:

  1. Take backup of Databases and logins.
  2. Detach all databases execpt system databases. (All users databases)
  3. Find the SQL server installation path (Root of the CD)
  4. Run this command:
    Setup /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=MSSQLServer /SAPWD=Qwerty123 /SQLSYSADMINACCOUNTS=”administrator” /SQLCollation=SQL_Scandinavian_Cp850_CS_AS

/QUIET – Run it as a sillent installation

/action – We are running rebuilddatabase to change the server collation

/Instancename – withs instance do you want to change collation on.

/SAPPW -SA password for this instance

/SQLSYSADMINACCOUNTS – An administration account, normally the run you are running this from. The user should be administrator of the SQL Server

/SQLCollation – withs collation should you change to.

 

Ahsay restore Microsoft SQL (MSSQL) server database

If you want to restore a Microsoft SQL database, from a fuld backup, and put some transaction log file into it.  (This backup has backup by ahsay)

This is the why to do it:

  1. Start Microsoft SQL Server Management Studio
  2. Right click on Databases, and select restore database

  3. Type a database “To database”, and select from device , and press the butten with the 3 dots (…)

  4. Select file, and then click Add

  5. Select the database file you want to restore, and click ok

  6. Then select options, and click “Leave the database non-operational, and do not roll back uncommitted transactions. (Restore with NORECOVERY), then click OK
  7. Start a new query, and type this (Change it to yours database and files).
  8. RESTORE LOG RestoreTest
    FROM DISK = ‘F:\RestoreTest\2011-09-13(09-00-00)_LOG_RestoreTest_2011.bak’
    WITH NORECOVERYRESTORE LOG Farma_test
    FROM DISK = ‘F:\RestoreTest\2011-09-13(10-00-00)_LOG_RestoreTest_2011.bak’
    WITH NORECOVERY

    RESTORE LOG Farma_test
    FROM DISK = ‘F:\RestoreTest\2011-09-13(11-00-00)_LOG_RestoreTest_2011.bak’
    WITH NORECOVERY

    RESTORE LOG Farma_test
    FROM DISK = ‘F:\RestoreTest\2011-09-13(12-00-00)_RestoreTest_2011.bak’
    WITH NORECOVERY

  9. When you have takende the sekund last backup file, just type this:
  10. RESTORE LOG Farma_test
    FROM DISK = ‘F:\RestoreTest\2011-09-13(13-00-00)_RestoreTest_2011.bak’
    WITH RECOVERY

Limit SQL Server maximum memory SQL instance

  • Start SQL Server Management Studio
  • Connect to you SQL server instance
  • Start a “New Query”
  • And then put this into you SQLQuery1.sql window

sp_configure ‘show advanced options’,1
reconfigure with override
go
sp_configure ‘max server memory’, 4096
reconfigure with override
go

  • Then push the execute buttom, this will limit you SQL instance to 4096MB or 4GB. Please beware of, if you have multiple instance each instance you wan’t to limit

Limit SQL Server maximum memory SQL of WSUS

  • Start SQL Server Management Studio
  • Connect to \\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query
  • Start a “New Query”
  • And then put this into you SQLQuery1.sql window

sp_configure ‘show advanced options’,1
reconfigure with override
go
sp_configure ‘max server memory’, 256
reconfigure with override
go

  • Then push the execute buttom, this will limit you SQL of WSUS to 256MB, whitch should be enough.

Install SQL Express 2005 quiet and with DISABLENETWORKPROTOCOLS=0

First you need to download SQL Express 2005 setup files, there can be done from microsoft homepage.

Then when you have download the setup files, you need to extract it, it can be done by typing:
SQLEXPR.EXE -x

It then ask you a location to put the extract files.

Then you can run this

SETUP.EXE /qb ADDLOCAL=SQL_Engine,SQL_Data_Files INSTANCENAME=”dalbjerg” SECURITYMODE=SQL SAPWD=”SAPassword” DISABLENETWORKPROTOCOLS=0

This will install the database name dalbjerg, and with sa password SAPassword.