I run the query
SELECT so.name, p.*
FROM sys.partitions p
INNER JOIN sys.sysobjects so ON p.object_id = so.id
WHERE partition_number > 1
OPTION (RECOMPILE);
and I get the 170 rows as result, like
ifts_comp_fragment_1336391830_19755845 ....
As I understand that are FTS internal partitions.
How can I delete all of FTS partitions?
Which DMV do I have to join with sys.dm_os_waiting_tasks to get the database ID?
You can try something as follows:
SELECT TOP 100 w.session_id, e.database_id, D.name
FROM sys.dm_os_waiting_tasks w
LEFT JOIN sys.dm_exec_sessions e ON w.session_id = e.session_id
LEFT JOIN sys.databases d ON e.database_id = d.database_id
I want to check which index stats that hasn't been updated on tables that has page count of 500 mb and more.
I have this script:
SELECT OBJECT_NAME(object_id) AS [ObjectName]
,[name] AS [StatisticName]
,STATS_DATE([object_id], [stats_id]) AS [StatisticUpdateDate]
FROM sys.stats
order by StatisticUpdateDate desc
Its not giving me all the info I want. Can someone be able to modify my script or show me how to get where I want to be?
Thanks in advance.
Here is a solution for 500 pages even if I think 500Mb is more reasonable finter:
with cte as
(
select p.object_id,
object_name(p.object_id) as obj,
sum(total_pages) as tot_pages
from sys.partitions p join sys.allocation_units au
on au.container_id = p.hobt_id
group by p.object_id
)
SELECT c.* ,
OBJECT_NAME(st.object_id) AS [ObjectName]
,[name] AS [StatisticName]
,STATS_DATE(st.[object_id],
[stats_id]) AS [StatisticUpdateDate]
FROM sys.stats st join cte c
on st.object_id = c.object_id
where tot_pages >= 500;
What is the SQL Server system table that contains information about stored procedure parameters with it's information like datatype, name, lenght, null or not?
thanks
You can query sys.procedures and sys.parameters...
select pr.name, p.*
from sys.procedures pr
inner join sys.parameters p on pr.object_id = p.object_id
And join to types too...
select pr.name, p.*, t.name, t.max_length
from sys.procedures pr
inner join sys.parameters p on pr.object_id = p.object_id
inner join sys.types t on p.system_type_id = t.system_type_id
You can also use
select * from INFORMATION_SCHEMA.PARAMETERS
You can also use
select * from INFORMATION_SCHEMA.ROUTINES \G;
SELECT
p.name AS [SP Name], qs.execution_count,
ISNULL(qs.execution_count/DATEDIFF(Second, qs.cached_time, GETDATE()), 0) AS [Calls/Second],
qs.total_worker_time/qs.execution_count AS [AvgWorkerTime], qs.total_worker_time AS [TotalWorkerTime],
qs.total_elapsed_time, qs.total_elapsed_time/qs.execution_count AS [avg_elapsed_time],
qs.cached_time,
isr.ROUTINE_DEFINITION
FROM sys.procedures AS p
INNER JOIN sys.dm_exec_procedure_stats AS qs
ON p.[object_id] = qs.[object_id]
Inner Join INFORMATION_SCHEMA.ROUTINES as ISR
on p.name = isr.SPECIFIC_NAME
WHERE qs.database_id = DB_ID()
and
isr.ROUTINE_DEFINITION like '%XXXX%' -- name of something you are looking for in the stored procedure
ORDER BY qs.execution_count DESC OPTION (RECOMPILE);
For those using SQL 2000
SELECT * FROM [dbName]..sysobjects WHERE xtype = 'P'
and
SELECT * FROM [dbName]..sysComments
Join them by id
This shows information about stored procedures and user-defined functions. It will include procedures/scalar functions without parameters, but will include parameter information if available.
SELECT
O.Name ProcedureName,
P.parameter_id Position,
P.Name ParameterName,
P.max_length MaxLen,
P.is_output IsOutput,
P.has_default_value HasDefaultValue,
P.default_value DefaultValue,
P.is_nullable IsNullable,
T.name TypeName,
T.max_length TypeMaxLen,
O.type_desc TypeDescription
FROM SYS.OBJECTS O
LEFT JOIN SYS.PARAMETERS P ON O.object_id = P.object_id
LEFT JOIN SYS.TYPES T ON P.system_type_id = T.system_type_id
WHERE type_desc LIKE 'SQL_%'
ORDER BY O.Name, P.parameter_id, P.Name
Can anybody help me on this?
How to get the database level permission users list for a particular database in SQL Server 2005?
Simple Google search, with query taken from the first result:
select dp.NAME AS principal_name,
dp.type_desc AS principal_type_desc,
o.NAME AS object_name,
p.permission_name,
p.state_desc AS permission_state_desc
from sys.database_permissions p
left OUTER JOIN sys.all_objects o
on p.major_id = o.OBJECT_ID
inner JOIN sys.database_principals dp
on p.grantee_principal_id = dp.principal_id
Modified slightly to include the database name as well:
select dp.NAME AS principal_name,
dp.type_desc AS principal_type_desc,
o.NAME AS object_name,
p.permission_name,
p.state_desc AS permission_state_desc,
d.[name] as database_name
from sys.database_permissions p
left OUTER JOIN sys.all_objects o on p.major_id = o.OBJECT_ID
inner JOIN sys.database_principals dp on p.grantee_principal_id = dp.principal_id
left outer JOIN sys.sysdatabases d on d.sid = dp.sid