Create Log file and attach Data file in SQL Server

You can attach a SQL Server data file(.mdf) which has no log file(.ldf) associate with the data file. Use the following SQL Query with the correct path of the data file.  CREATE DATABASE MyDB ON (FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\MyDB_Data.mdf')  -- change the drive and file path FOR ATTACH_REBUILD_LOG ;

Access to a SQL Server in some other Domain from SQL Server Management Studio

Senario in brief: My normal working domain is DomainA. But i have to connect to a sql server in DomainB. Administrators have given me remote desktop connection to the server which has sql server in DomainB but not to direct access from my SQL Server management studio.Following is the solution. runas /netonly /user:DomainB\sqladmin "C:\Program Files (x86)\Microsoft …

SQL Server function to get Business Unit Guid by Name

This will be very useful when you are migrating data to CRM database from some other system database. Specially when filling base tables we should give business unit guid to it.You can use following function and I have given the way that you should use it in your data migration scripts.CREATE FUNCTION dmfx_GetBusinessUnit(        @businessUnitName …