Ads

17 December 2023

Failed to initialize sqlcmd library with error number -2147467259.

This error has too many options to fix, one of them is below resolution - 

In our case we were using a dynamic query which will send some results over the email with help of dynamic execution. when the query was executed using sp_send_mail it used to fail.

Failed to initialize sqlcmd library with error number -2147467259.

After couple of hours identified that query results using linked server was causing the issue. 

An error occurred during Service Master Key decryption There is no remote user ' ' mapped to local user '(null)' from the remote server ' '. (Microsoft SQL Server, Error: 33094)

To fix this we need to run 

        ALTER SERVICE MASTER KEY FORCE REGENERATE

Once the above command executed linked server started working properly. The dynamic query started to work smoothly, which inturn resolved the issue. 



22 November 2023

SSRS not starting - unable to connect to the report server

 After the windows upgrade few cases WMI RS integration will be corrupted, during that time we get the error "Unable to connect to the Report Server "




Solution : 

Based on the SQL Server Version the MOF file will be located in different locations, in our case it was on D drive.

1. Open CMD prompt with elevated privileges

2. Run below command 


mofcomp "D:\SQL Server Files\MSRS13.MSSQLSERVER\Reporting Services\ReportServer\bin\\reportingservices.mof"


=============== This will fix the issue =================



26 April 2023

SQL Server DB Object, Job and DB Owner Details

 -- Below will provide the Job Owner Details

SELECT s.name AS JobName, l.name AS JobOwner, s.enabled

FROM msdb..sysjobs s

LEFT JOIN master.sys.syslogins l ON s.owner_sid = l.sid

WHERE l.name IS NOT NULL and l.name in ('Domain\User' )

ORDER by l.name

 

-- Below will provide DB Owners

SELECT name,

        suser_sname( owner_sid ) AS DBOwnerName

FROM master.sys.databases

WHERE suser_sname( owner_sid )in  ('Domain\User' )

 

--- Below will provide Each Object Owners 

;with objects_cte as

(

    select

        o.name,

        o.type_desc,

        case

            when o.principal_id is null then s.principal_id

            else o.principal_id

        end as principal_id

    from sys.objects o

    inner join sys.schemas s

    on o.schema_id = s.schema_id

    where o.is_ms_shipped = 0

    and o.type in ('U', 'FN', 'FS', 'FT', 'IF', 'P', 'PC', 'TA', 'TF', 'TR', 'V')

)

select

    cte.name,

    cte.type_desc,

    dp.name

from objects_cte cte

inner join sys.database_principals dp

on cte.principal_id = dp.principal_id

where dp.name in  ('Domain\User' ) or dp.name <>'dbo'