Wednesday, August 27, 2014
Total user Database size in GB's
Operating System Requirements to install SQL Server 2012
SQL Server 2012 edition
|
Operating system
|
SQL Server 2012 x64 Enterprise,
Business Intelligence, and Web |
Windows Server 2008 R2 SP1 Datacenter, Enterprise, Standard, and Web or above
Windows Server 2008 SP2 Datacenter, Enterprise, Standard, and Web or above |
SQL Server 2012 x86 Enterprise,
Business Intelligence, and Web |
Windows Server 2008 R2 SP1 Datacenter, Enterprise, Standard, and Web or above
Windows Server 2008 (x64 and x86) SP2 Datacenter, Enterprise,Standard, and Web or above |
SQL Server 2012 x64 Standard
|
Windows Server 2008 R2 SP1 Datacenter, Enterprise, Standard,Foundation, and Web or above
Windows Server 2008 SP2 Datacenter, Enterprise, Standard, and Web or above Windows 7 SP1 x64 Ultimate, Enterprise, and Professional Windows Vista SP2 x64 Ultimate, Enterprise, and Business |
SQL Server 2012 x86 Standard
|
Windows Server 2008 R2 SP1 Datacenter, Enterprise, Standard,Foundation, and Web or above
Windows Server 2008 (x64 and x86) SP2 Datacenter, Enterprise,Standard, and Web or above Windows 7 SP1 (x64 and x86) Ultimate, Enterprise, and Professional Windows Vista SP2 (x64 and x86) Ultimate, Enterprise, and Business |
SQL Server 2012 x64 Developer,
Express, Express with Tools, and Express with Advanced Services |
Windows Server 2008 R2 SP1 Datacenter, Enterprise, Standard,Foundation, and Web or above
Windows Server 2008 (x64) SP2 Datacenter, Enterprise, Standard,and Web or above Windows 7 SP1 (x64) Ultimate, Enterprise, Professional, Home Premium, and Home Basic Windows Vista SP2 (x64) |
SQL Server 2012 x86 Developer,
Express, Express with Tools, and Express with Advanced Services |
Windows Server 2008 R2 SP1 Datacenter, Enterprise, Standard,Foundation, and Web or above
Windows Server 2008 (x64 and x86) SP2 Datacenter, Enterprise,Standard, and Web or above Windows 7 SP1 (x64 and x86) Ultimate, Enterprise, Professional, Home Premium, and Home Basic Windows Vista SP2 (x64 and x86) Ultimate, Enterprise, Business, Home Premium, and Home Basic |
Tuesday, August 26, 2014
Restoration of N number of backup files at a time
Wednesday, August 13, 2014
Shrink Database Log file in SQL Server
Method 1 : This script will shrink the all log files of specific database by change the recovery modle to simple and again it rever back the recovery model
DECLARE @tbl TABLE
(
ID INT IDENTITY(1,1),
DBNAME NVARCHAR(1000),
[FileName] NVARCHAR(1000)
)
INSERT INTO @tbl
SELECT DB_NAME(DbID),st.NAme from sys.sysaltfiles ST INNER JOIN Sys.databases SB on ST.dbid = sb.database_id where sb.name = 'TEST2008' AND FileName LIKE '%ldf' and sb.state = 0
DECLARE @MinID INT , @MaxID INT,@DBName NVARCHAR(1000),@FileName NVARCHAR(1000),@RecoveryModel NVARCHAR(1000),@SQL NVARCHAR(MAX)
SELECT @MinID = MIN(ID),@MaxID = MAX(ID) FROM @tbl
WHILE(@MinID <=@MaxID)
BEGIN
SELECT @DBName = DBNAME,@FileName=[FileName] FROM @tbl where ID = @MinID
SELECT @RecoveryModel = recovery_model_desc FROM sys.databases where name = @DBName
SELECT @SQL= N'USE ['+ @DBName+']'+CHAR(10)+CHAR(10)
+CASE WHEN @RecoveryModel <> N'SIMPLE' THEN N'ALTER DATABASE ['+@DBName+'] SET RECOVERY SIMPLE WITH NO_WAIT'ELSE N''END+CHAR(10)+
+N'DBCC SHRINKFILE('+@FileName+',1)'+CHAR(10)
+CASE WHEN @RecoveryModel <> N'SIMPLE' THEN N'ALTER DATABASE ['+@DBName+'] SET RECOVERY '+@RecoveryModel+N' WITH NO_WAIT'+CHAR(10) ELSE N'' END
+CHAR(10)
PRINT @SQL
EXEC SP_EXECUTESQL @SQL
SELECT @MinID = @MinID +1
END
Method 2: This script will shrink the all databases log files, depends on the size of log file by change the recovery modle to simple and again it rever back the recovery model
DECLARE @tbl TABLE
(
ID INT IDENTITY(1,1),
DBNAME NVARCHAR(1000),
[FileName] NVARCHAR(1000)
)
INSERT INTO @tbl
SELECT DB_NAME(DbID),st.NAme from sys.sysaltfiles ST INNER JOIN Sys.databases SB on ST.dbid = sb.database_id where Size > 100000 AND FileName LIKE '%ldf' and sb.state = 0
DECLARE @MinID INT , @MaxID INT,@DBName NVARCHAR(1000),@FileName NVARCHAR(1000),@RecoveryModel NVARCHAR(1000),@SQL NVARCHAR(MAX)
SELECT @MinID = MIN(ID),@MaxID = MAX(ID) FROM @tbl
WHILE(@MinID <=@MaxID)
BEGIN
SELECT @DBName = DBNAME,@FileName=[FileName] FROM @tbl where ID = @MinID
SELECT @RecoveryModel = recovery_model_desc FROM sys.databases where name = @DBName
SELECT @SQL= N'USE ['+ @DBName+']'+CHAR(10)+CHAR(10)
+CASE WHEN @RecoveryModel <> N'SIMPLE' THEN N'ALTER DATABASE ['+@DBName+'] SET RECOVERY SIMPLE WITH NO_WAIT'ELSE N''END+CHAR(10)+
+N'DBCC SHRINKFILE('+@FileName+',1)'+CHAR(10)
+CASE WHEN @RecoveryModel <> N'SIMPLE' THEN N'ALTER DATABASE ['+@DBName+'] SET RECOVERY '+@RecoveryModel+N' WITH NO_WAIT'+CHAR(10) ELSE N'' END
+CHAR(10)
PRINT @SQL
EXEC SP_EXECUTESQL @SQL
SELECT @MinID = @MinID +1
END
Kill all user SPIDs in a SQL Server Database
Using this script you can kill all the SPID connected to TEST2008 database
DECLARE @DB SYSNAME
SET @DB = 'Test2008' -- Here you need to give the database name where you need to kill all connection
DECLARE @SPID VARCHAR(4), @cmdSQL VARCHAR(10)
IF OBJECT_ID('tempdb..#KilledSpidsInfo ') IS NOT NULL
BEGIN
DROP TABLE #KilledSpidsInfo
END
SELECT * into #KilledSpidsInfo FROM master.dbo.sysprocesses
WHERE SPID > 50
AND SPID != @@SPID
AND DBID = DB_ID(@DB)
select * from #KilledSpidsInfo
DECLARE cCursor CURSOR
FOR SELECT CAST(SPID AS VARCHAR(4)) FROM master.dbo.sysprocesses
WHERE SPID > 50
AND SPID != @@SPID
AND DBID = DB_ID(@DB)
OPEN cCursor
FETCH NEXT FROM cCursor INTO @SPID
WHILE @@FETCH_STATUS = 0
BEGIN
SET @cmdSQL = 'KILL ' + @SPID
EXEC (@cmdSQL)
FETCH NEXT FROM cCursor INTO @SPID
END
CLOSE cCURSOR
DEALLOCATE cCURSOR
Monday, August 11, 2014
change server level collation for a SQL Server Instance
Cannot access the specified path or file on the server. Verify that you have the necessary security privileges and that the path or file exists
If you received below error while attaching a .mdf file in cluster environment please follow below steps to resolve the issue ERROR Ca...
-
Problem Cannot drop the user 'dbo'. Rename failed for User 'dbo'. (Microsoft.SqlServer.Smo) Cannot alter the user &...
-
If you received below error while attaching a .mdf file in cluster environment please follow below steps to resolve the issue ERROR Ca...
-
If SQL Server agent not started and if you find below error in event viewer Error Details Log Name : Applicatio...