Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

SQL Query that causes Deadlock often

$
0
0

Hi

We are getting deadlocks, some of the queries are repeatedly causing deadlock. The tables involved are system tables. I am kind of new to SQL server. I am not sure why would someone running this queries, I ran this query in different db but I am not getting any result set back.

My question is what the purpose of the query and why would be running.

Any help would much appreciated.

Query 1:

(@_msparam_0nvarchar(4000),@_msparam_1nvarchar(4000),@_msparam_2nvarchar(4000))

SELECTSCHEMA_NAME(sp.schema_id)

AS[Schema], sp.name AS[Name],  sp.object_idAS[ID],

 CASEWHENsp.type=N'P' THEN 1 WHENsp.type=N'PC'

 THEN 2 ELSE 1ENDAS [ImplementationType],  CAST(casewhen sp.is_ms_shipped= 1

 then 1 when (select major_idfromsys.extended_properties

  wheremajor_id=sp.object_idand    minor_id= 0 and class= 1 andname= N'microsoft_database_tools_support') isnotnull

   then 1 else 0endAS bit)AS [IsSystemObject],

  CAST(CASEWHENISNULL(smsp.definition,ssmsp.definition)ISNULL

  THEN 1 ELSE 0ENDAS bit)AS [IsEncrypted]FROM sys.all_objectsASsp

   LEFTOUTERJOINsys.sql_modulesASsmsp ONsmsp.object_id=sp.object_id

 LEFTOUTERJOIN sys.system_sql_modulesASssmsp ONssmsp.object_id=sp.object_idWHERE (sp.type=@_msparam_0 )

Query: 2

(@_msparam_0nvarchar(4000))

SELECTSCHEMA_NAME(udf.schema_id)AS[Schema],udf.nameAS[Name],udf.object_idAS[ID],

(casewhen'FN' =udf.typethen 1

 when'FS'= udf.type then 1

 when'IF'= udf.type then 3

 when'TF' =udf.typethen 2

 when'FT' =udf.typethen 2

 else 0 end)AS[FunctionType],

 CASEWHEN udf.type IN('FN','IF','TF')THEN 1

 WHENudf.typeIN('FS','FT')THEN 2

 ELSE 1 ENDAS[ImplementationType],

 CAST( casewhenudf.is_ms_shipped= 1 then 1

 when ( selectmajor_idfromsys.extended_propertieswheremajor_id =udf.object_idand

 minor_id= 0andclass = 1 andname=N'microsoft_database_tools_support')isnot nullthen 1

 else 0 endASbit)AS[IsSystemObject],CAST(CASEWHENISNULL(smudf.definition,ssmudf.definition)ISNULL THEN 1

 ELSE 0 ENDASbit)AS[IsEncrypted],CAST(OBJECTPROPERTYEX(udf.object_id,N'IsSchemaBound') ASbit) AS ....

Thanks


VR




Viewing all articles
Browse latest Browse all 12963


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>