Showing posts with label T-SQL. Show all posts
Showing posts with label T-SQL. Show all posts

T-SQL to list processes and their running sql

select sp.spid, sp.status, sp.blocked, sp.hostname, db_name(sp.dbid), object_name(objectid), qt.text
from sys.sysprocesses sp
cross apply sys.dm_exec_sql_text(sp.sql_handle) qt
where sp.status <> 'sleeping'

Credits to Phil Hendry

OPENROWSET with Microsoft.Jet.OLEDB.4.0

I came across this error when trying to alter a procedure containing an OPENROWSET with Microsoft.Jet.OLEDB.4.0 on SQL Server 2005:

alter procedure Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".

I was surprised to see this when just trying to alter a procedure.  I found the solution was to edit the following registry key value:

HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\<Instance>\Providers\Microsoft.Jet.OLEDB.4.0\AllowInProcess to 0