Pages

Wednesday, August 31, 2011

Shrink SQL Server Database



Method 1

ALTER DATABASE DatabaseName SET RECOVERY SIMPLE
use DatabaseName
GO
CHECKPOINT
GO
DBCC SHRINKFILE(transactionloglogicalfilename,TRUNCATEONLY)
GO
ALTER DATABASE DatabaseName SET RECOVERY FULL

Method 2

USE DatabaseName
GO
ABCC SHRINKFILE(, 1)
BACKUP LOG WITH TRUNCATE_ONLY
ABCC SHRINKFILE(, 1)
GO

Saturday, April 30, 2011

PIVOT TABLE and SQL Query

Basic Example for PIVOT:
SELECT gid,
[1] AS cname1,
[2] AS Cname2,
[3] AS Cname3,
[4] AS Cname4,
[5] as Cname5
FROM
(SELECT gid,gpid,gpname,Name FROM test) s
PIVOT
(
MAX(Name)
FOR gname IN ([1],[2],[3],[4],[5])
) p
ORDER BY [gid]
GO

Thursday, March 31, 2011

"Your Computer could not connect to another console session on the remote computer because you already have a console session in Progress"

Use Remote Desktop when Windows Firewall is on Because Windows Firewall restricts communication between your computer and the Internet, you might need to change settings for Remote Desktop Connection so that it can work properly. Click to open Windows Firewall. In the left pane, click Allow a program or feature through Windows Firewall. Click Change settings. If you're prompted for an administrator password or confirmation, type the password or provide confirmation. Under Allowed programs and features, select the check box next to Remote Desktop, and then use the check boxes in the columns to select the network location types you want to allow communication on. Click OK.