Skip to main content

Posts

Showing posts with the label substring

How To Identify The Long Running Queries in SQL?

These queries can help you  To Identify The Long Running Queries in SQL. 1.SELECT creation_time ,last_execution_time ,total_physical_reads ,total_logical_reads ,total_logical_writes , execution_count , total_worker_time , total_elapsed_time , total_elapsed_time / execution_count avg_elapsed_time ,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1, ((CASE statement_end_offset WHEN -1 THEN DATALENGTH(st.text) ELSE qs.statement_end_offset END - qs.statement_start_offset)/2) + 1) AS statement_text FROM sys.dm_exec_query_stats AS qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st where total_elapsed_time >= 800000000 ORDER BY total_elapsed_time / execution_count DESC; 2.DBCC opentran(This command will display the longest running transactions on the database) and select * from sys.dm_tran_active_snapshot_database_transactions(this command will display the transactions about replication and mirroring and snapshot isolated related transactions)

convert time 24 To 12 in asp.net

 If you want to convert time  24 format  To 12  am pm form in asp.net then you can try following method. You can write this method in common class in asp.net program then you can call this function by passing time variable in function parameter. public static string convert24To12(string time) { if (time.IndexOf(":") == -1) return time; string appendstring = "AM"; string strHr = time.Substring(0, time.IndexOf(":")); string strMin = time.Substring(time.IndexOf(":") + 1); int intHr = Convert.ToInt16(strHr); if (intHr > 12) { appendstring = "PM"; intHr -= 12; } if (intHr == 12) { appendstring = "PM"; } else if (intHr == 0) { intHr = 0; } return ((intHr < 10) ? "0" : "") + intHr + ":" + strMin + "