Tuesday, June 30, 2009

How to Enable Session Cookies

Netscape Navigator:
1.Click the Edit menu and select Preferences.
2.Click on Advanced in the list of topics on the left side of the window. The right side of the window should now display a series of checkboxes.
3.Find the box labeled Accept all cookies and make sure it is checked.
4.Click OK.

Microsoft Internet Explorer For Windows - Version 6.xx
1.Click on the Tools menu and select Internet Options.
2.Click the Privacy tab at the top of the window.
3.Make sure that the slider is set at a level not higher than Medium.
4.The bottom of the slider section of the Security window contains several buttons. Click on the one marked Advanced.
5.In the new window under the Cookies section, check the box labeled "Override automatic cookie handling".
6.Now you will see the other settings that are enabled and can be configured.
7.Under the First-party Cookies section, click the Accept button.
8.Under the Third-party Cookies section, click on the Block button.
9.Check the box labeled "Always allow session cookies."
10.Click on OK.

Sunday, June 21, 2009

To Kill SQL Server Connections for a database

Disclaimer: Snagged & Sharing

1. Manual way:

Get all processes attached to the database
SELECT spid FROM master..sysprocesses WHERE dbid = DB_ID(@DatabaseName)
and AND spid != @@SPID

Note : @@SPID is your connected instance Service Process id "SPID"

and Perform Kill operation
EXEC('KILL '+RTRIM(@spid) )

2. Create Script

Use Master
Go

Declare @dbname sysname

Set @dbname = 'name of database you want to drop connections from'

Declare @spid int
Select @spid = min(spid) from master.dbo.sysprocesses
where dbid
= db_id(@dbname)
While @spid Is Not Null
Begin
Execute ('Kill ' + @spid)
Select @spid = min(spid) from master.dbo.sysprocesses
where dbid
= db_id(@dbname) and spid > @spid
End


3. Use Stored procedure


CREATE PROCEDURE dbo.clearDBUsers
@dbName SYSNAME
AS
BEGIN
SET NOCOUNT ON

DECLARE @spid INT,
@cnt INT,
@sql VARCHAR(255)

SELECT @spid = MIN(spid), @cnt = COUNT(*)
FROM master..sysprocesses
WHERE dbid = DB_ID(@dbname)
AND spid != @@SPID

PRINT 'Starting to KILL '+RTRIM(@cnt)+' processes.'

WHILE @spid IS NOT NULL
BEGIN
PRINT 'About to KILL '+RTRIM(@spid)
SET @sql = 'KILL '+RTRIM(@spid)
EXEC(@sql)
SELECT @spid = MIN(spid), @cnt = COUNT(*)
FROM master..sysprocesses
WHERE dbid = DB_ID(@dbname)
AND spid != @@SPID
PRINT RTRIM(@cnt)+' processes remain.'
END
END
GO