Home » Script (Page 5)
Category Archives: Script
MSSQLFUN – Year 2012 Review
The WordPress.com stats helper monkeys prepared a 2012 annual report for this blog. Here’s an excerpt: 600 people reached the top of Mt. Everest in 2012. This blog got about 2,000 views in 2012. If every person who reached the top of Mt. Everest viewed this blog, it would have taken 3 years to get … Continue reading
How to find current/particular transaction level?
There is 2 ways of finding current / particular transaction level :- 1) SELECT CASE transaction_isolation_level WHEN 0 THEN ‘Unspecified’ WHEN 1 THEN ‘ReadUncomitted’ WHEN 2 THEN ‘Readcomitted’ WHEN 3 THEN ‘Repeatable’ WHEN 4 THEN ‘Serializable’ WHEN 5 THEN ‘Snapshot’ END AS TRANSACTION_ISOLATION_LEVEL FROM sys.dm_exec_sessions where session_id = @@SPID 2) DECLARE @UserOptions TABLE(SetOption varchar(100), Value … Continue reading
Script to get details of permissions on Database objects
Script to get details of permissions on Database objects Script to get details of permissions on Database objects SELECT [UserName] = ulogin.[name], [UserType] = CASE princ.[type] WHEN ‘S’ THEN ‘SQL User’ WHEN ‘U’ THEN ‘Windows User’ WHEN ‘G’ THEN ‘Windows Group’ END, [DatabaseUserName] = princ.[name], [Role] = null, [PermissionType] = perm.[permission_name], [PermissionState] = perm.[state_desc], [ObjectType] … Continue reading
Procedure xp_cmdshell expects parameter ‘command_string’ of type ‘varchar’.
You can’t use varchar(max) with xp_cmdshell. Try a finite number (0 to 8000). varchar(max) is having capacity of 2GB & works as TEXT data type in background.
Query Execution Plan from XML to Graphical View
Convert Your SQL Server Query Execution Plan from XML to Graphical View 1) We can get queries execution plan from below query SELECT QS.*, CP.* FROM SYS.DM_EXEC_QUERY_STATS AS QS CROSS APPLY SYS.DM_EXEC_SQL_TEXT(SQL_HANDLE)AS ST CROSS APPLY SYS.DM_EXEC_QUERY_PLAN(PLAN_HANDLE) AS CP 2) Column query_plan is having execution plan in XML form 3) When we click hyperlink in query_plan … Continue reading