About Me
Monday, 27 January 2014
Saturday, 25 January 2014
Friday, 24 January 2014
HOW TO FIND LONGEST RUNNING QUERY IN SQL
SELECT DISTINCT TOP 10
t.TEXT QueryName,
s.execution_count AS ExecutionCount,
s.max_elapsed_time AS MaxElapsedTime,
ISNULL(s.total_elapsed_time / s.execution_count, 0) AS AvgElapsedTime,
s.creation_time AS LogCreatedOn,
ISNULL(s.execution_count / DATEDIFF(s, s.creation_time, GETDATE()), 0) AS FrequencyPerSec
FROM sys.dm_exec_query_stats s
CROSS APPLY sys.dm_exec_sql_text( s.sql_handle ) t
ORDER BY
s.max_elapsed_time DESC
GOThursday, 23 January 2014
How do I find the columns that depend on a specified CLR user-defined type or alias type?
USE <database_name>;
GO
SELECT OBJECT_NAME(object_id) AS object_name
,c.name AS column_name
,SCHEMA_NAME(t.schema_id) AS schema_name
,TYPE_NAME(c.user_type_id) AS user_type_name
,c.max_length
,c.precision
,c.scale
,c.is_nullable
,c.is_computed
FROM sys.columns AS c
INNER JOIN sys.types AS t ON c.user_type_id = t.user_type_id
WHERE c.user_type_id = TYPE_ID('<schema_name.data_type_name>');
GO
Tuesday, 21 January 2014
WHAT IS THE USE OF MSDB DATABASE
Hi ,
I was asked with a question about the use of taking backup of MSDB system database in SQL??
I am explaining the same for viewers:-
There are Four System databases in SQL server 2000 and later versions
Master DB : The use of this DB is most important coz if this DB corrupts then whole user databases are get into affect , atleast once in a month taking BU of Master DB is good practice
MSDB : what ever the Jobs/Plans/Alerts running on the User DBs are related with the database.....Usually if we take the backup of database these jobs/plans not get back up..So it is very very important that if we need to restore the jobs then u have to take the backup MSDB
I was asked with a question about the use of taking backup of MSDB system database in SQL??
I am explaining the same for viewers:-
There are Four System databases in SQL server 2000 and later versions
Master DB : The use of this DB is most important coz if this DB corrupts then whole user databases are get into affect , atleast once in a month taking BU of Master DB is good practice
MSDB : what ever the Jobs/Plans/Alerts running on the User DBs are related with the database.....Usually if we take the backup of database these jobs/plans not get back up..So it is very very important that if we need to restore the jobs then u have to take the backup MSDB
How to SELECT * INTO [temp table] FROM [stored procedure]
CREATE PROC getBusinessLineHistory
AS
BEGIN
SELECT * FROM sys.d
atabases
END
GO
sp_configure 'Show Advanced Options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
GO
SELECT * INTO #MyTempTable FROM OPENROWSET('SQLNCLI', 'Server=(local)\SQL2008;Trusted_Connection=yes;',
'EXEC getBusinessLineHistory')
SELECT * FROM #MyTempTable
Subscribe to:
Posts (Atom)








