Slowlog

Hi Experts ,

Need your help, can i log slow queries in other file at some other location in sql server 2012. I need to create logfile on daily basis and send to dev team .

https://www.sqlshack.com/how-to-identify-slow-running-queries-in-sql-server/
Use these queries to cache stats in tables or files.

Hi Jotorre,

Thanks for your reply , but i want to record slow query in separate file . can this is possible with sql server 2012.

Sure, First figure out the query that will give you the statistics you want. Secondly decide how you want to write out the data, bcp, SSIS, …. Then schedule a SQL Server Job that runs periodically. What version of SQL Server are you using?

:grinning: got it .. You solve my problem , I am using Sql server 2012 , but very upset that sql server not provide this kind of feature to capture slow log in separate file like Mysql or mongodb. But Thanks for your suggestion you lighten my mind bulb. :grinning:

In SSMS there are a bunch of reports. Right click the server and select Reports->Standard Reports.

I created a view in master, SlowQueries.
At the Command Prompt I ran this:
bcp master.dbo.SlowQueries out "Slow.log" -S adm-12-sql1 -T -c

it will overwrite the file so you can append it to another file to keep the history.

echo Slow.log>>SlowHist.log

First, Find out the longest running query in sql server by going through the following link: https://www.mssqltips.com/sqlservertip/4401/find-long-running-sql-server-queries-using-profiler/