Tuesday, March 1, 2016

Terminal Server Has Exceeded the Maximum Number of Allowed Connections

Open command prompt.

To check which session to reset, see below command line:

query session /server:[server name]

Sample:

query session /server:MyServer2003

Output:








Then, check the ID to be reset and use the command line below:

reset session [ID] /server:MyServer2003

Sample:

reset session 3 /server:MyServer2003

Note: There will be no output after you run this command. Afterwards, try logging in to the server again.

Wednesday, January 6, 2016

Assembly Trust Issues and Set Trustworthy ON in SQL Server 2008

Simply use below query:

USE <dbname>;
EXEC sp_configure 'clr enabled' ,1
GO

RECONFIGURE 
GO 
EXEC sp_configure 'clr enabled'   -- make sure it took 
GO 

USE <dbname>
GO 

EXEC sp_changedbowner 'sa' 
USE <dbname>
GO 

ALTER DATABASE <dbname> SET TRUSTWORTHY ON;

Get Monday Date of the Current Week in SQL Server 2008

Simply copy the query below:

SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0)

Current Week:
  • Monday Date - SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0)
  • Tuesday Date - SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0) + 1
  • Sunday Date - SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0) + 6

In getting the Monday Date from the previous week, use SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0) - 7