Store wait_stats automatically and query it whenever required I'm learning wait_stats and came up with thought. Is it possible to store wait stats in a table or create a stored procedure or query which will return wait_stats % when we execute query or stored procedure? if yes I would like to have query and stored procedure.
You could get a monitoring tool like Idera SQL Diagnostic Manager or Dell Spotlight to do all of that for you. If you want to go the manual route and get the wait stats yourself you can check out sp_BlitzFirst from Brent Ozar. You can use that to store wait stats in a table. If you click through the link they give you directions on how to set it up to log to a table.