Thursday 20 December 2012

Attach mdf file without ldf file in Database

Please execute the following statement from sql server management studio

 CREATE DATABASE TestMyDb ON
(FILENAME =N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2EXPRESS\MSSQL\DATA\TestMyDb.mdf')
FOR ATTACH_REBUILD_LOG
GO


Please note:-
Where TestMyDb is the mdf file
And keep the file in the default location of the sql server.

Friday 14 December 2012

SET LANGUAGE (Transact-SQL)



          

SET LANGUAGE { [ N ] 'language' | @language_var } 
        
[N]'language' | @language_var
Is the name of the language as stored in sys.syslanguages. This argument can be either Unicode or DBCS converted to Unicode. To specify a language in Unicode, use N'language'. If specified as a variable, the variable must be sysname.
The setting of SET LANGUAGE is set at execute or run time and not at parse time.
SET LANGUAGE implicitly sets the setting of SET DATEFORMAT.
Requires membership in the public role.
The following example sets the default language to Italian, displays the month name, and then switches back to us_english and displays the month name again.
DECLARE @Today DATETIME
SET @Today = '12/5/2007'

SET LANGUAGE Italian
SELECT DATENAME(month, @Today) AS 'Month Name'

SET LANGUAGE us_english
SELECT DATENAME(month, @Today) AS 'Month Name' 
GO


Thursday 6 December 2012

How to check db internal version

Execute the following command from sql server management studio Query window:-
select DATABASEPROPERTY((select DB_Name()),'Version')
------------------------------------------------------------------------------------------------------------
SELECT SERVERPROPERTY('productversion') as [Product version],
SERVERPROPERTY ('productlevel') as [Product level] ,
SERVERPROPERTY ('edition') as [Edition],
DATABASEPROPERTYEX((select DB_Name()),'Version') as [Internal Version Number]
,DATABASEPROPERTY((select DB_Name()),'Version') as [Internal Version Number--Deprecated]
,(select DB_Name()) as DBName,
(SELECT COMPATIBILITY_LEVEL FROM SYS.DATABASES WHERE NAME = (select DB_Name())) as compatibilityLevel

How to check sql server db version from backup file


Execute the following command from sql server management query window:-
restore
headeronly from disk='E:\Client\Sactech\RBK\Database\RBKPAYLITE_051212' 
 
Where  'E:\Client\Sactech\RBK\Database\RBKPAYLITE_051212'  is the backup file name with path.