Fix orphaned sql users

Creating-Updating DB

  • Then open query window and execute following stored procedure

SQL 2005 Full version

Useful script

Otherwise to associate user to login try the following:


Install SQL instance on domain controller

Installing SQL instance is not recommended and will usually fail (when starting the service section in the wizard). If this happens you can try the following:

This usually occurs when the master.mdf or the mastlog.ldf gets corrupt . In order to solve the issue go to the following path C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL , there you will find a folder ” Template Data ” , copy the master.mdf and mastlog.ldf and replace it in C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Data folder . Thats it . Now start the MS SQL service and you are done

It will reset the sa password.


Default sa passwords.

SQL Server 2008/R2 Express
User:  sa
Password:   [blank password – leave field empty to connect]

SQL Server 201x Express
User:  sa
Password: Password123

SQL Server 20xx Web or Standard
User: sa
Password:   will be the same as your administrator or root user password at the time the VDS was provisioned.


Login via management studio and run the following to change sa password:




Otherwise you can you use the following link to do it properly.

How to Install Microsoft SQL on a Domain Controller

Operating system error 5(Access is denied.).

When creating backup need to set the permissions of the folder. Set the security permissions to allow ‘Authenticated Users’ to have read write permissions to the folder. Then run backup scripts again.



Get the Top 10 of each distinct column value


Clear sql buffer and cache

Numbers Table

Rebuild indexes

Adding a foreign key

Adds foreign key in tblDisplay for lnkclientID which exists in tblClient as IDClient


Adding weak Link

Adds a weak link (lnkAddressID) between tbl_SUB_SubscriptionContract and tbl_SUB_Address. Conditions accepted:

– ID has to exist in tblAddress

– 0 values accepted



The DateAdd() Functions adds/subtracts a specific interval to a specified date



Using the DateAdd function in a loop to add 1 month to each date