My db server is is having continuous high CPU load for the past few days. While investigating this, I was looking at the currently executing requests using the query
SELECT session_id,
request_id,
Db_name(database_id),
start_time,
status,
command,
Substring(txt.TEXT, ( statement_start_offset / 2 ) + 1,
( ( CASE statement_end_offset
WHEN -1 THEN Datalength(txt.TEXT)
ELSE statement_end_offset
END
- statement_start_offset ) / 2 ) + 1) AS statement_text,
wait_type,
wait_time,
blocking_session_id,
percent_complete,
cpu_time,
reads,
writes,
logical_reads,
row_count
FROM sys.dm_exec_requests
CROSS APPLY sys.Dm_exec_sql_text([sql_handle]) AS txt
WHERE session_id <> @@SPID
AND session_id > 50
Most of the time I find that apart from the regular queries sent by application server, there are these weird S queries which seem to be consuming a decent slice of CPU time. e.g.

They do not appear on the SQL profiler. Anybody has ideas what are they and what should be done about them?
txt.text. Pretty sure yoursubstringcode will turn out to be at fault.statement_end_offset=0?