2014-09-18

TSQL - MSDTC on server is unavailable.

Go to "Services", and start the "Distributed Transaction Coordinator" service.

TSQL - Stored procedure results insertion into table at linked server - No columns or permissions

ISSUE:

The OLE DB provider "SQLNCLI11" for linked server "LINKED_SERVER_NAME_HERE" indicates that either the object has no columns or the current user does not have permissions on that object.



USE THIS METHOD:


insert THESIS.dbo.ExposureCFLM
(
       Field1
       , Field2
       , Field3
)
execute(
 '
       set fmtonly off
       exec DATABASE_NAME_HERE.dbo.STORED_PROCEDURE_NAME_HERE
              @prm1=222
                     , @prm2 = ''aBC''
       ;
') at LINKED_SERVER_NAME_HERE;


 00

TSQL - Server is not configured for RPC

exec sp_serveroption
       @server='me'
       , @optname='rpc'
       , @optvalue='TRUE'
;

exec sp_serveroption
       @server='me'
       , @optname='rpc out'
       , @optvalue='TRUE'
;



TSQL - Restore database from .mdf, recreating the log

CREATE DATABASE THESIS ON
    (FILENAME = N'C:\MSSQL\PATH...\DATABASE_FILE.mdf')
    FOR ATTACH_REBUILD_LOG
;


2014-09-06

TSQL - Add self-referencing linked server (windows authentication)

exec sp_addlinkedserver
       @server='me'               -- here you can specify the name of the linked server
       , @srvproduct=''    
       , @provider='sqlncli'      -- using SQL Server native client
       , @datasrc='(local)' -- add here your server name
       , @location=''
       , @provstr=''
       , @catalog='THESIS'
;





-- Using MSDASQL... not optimal.
exec sp_addlinkedserver
       @server = 'me'
       , @srvproduct=''
       , @provider='MSDASQL'
       , @provstr='DRIVER={SQL Server}; Server=(local); Initial Catalog=master; Integrated Security=SSPI;'
;



Use this command instead, if using SQLEXPRESS...

exec sp_addlinkedserver
       @server = 'selfSQLEXPRESS'
       , @srvproduct=''
       , @provider='MSDASQL'
       , @datasrc=NULL
       , @location=NULL
       , @provstr='DRIVER={SQL Server}; Server=(local)\SQLEXPRESS; Initial Catalog=master; Integrated Security=SSPI;'
;


TSQL - Enable OPENROWSET

Symptom:
Msg 15281, Level 16, State 1, Line 1
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', search for 'Ad Hoc Distributed Queries' in SQL Server Books Online.



Fix:
sp_configure 'show advanced options',1
reconfigure with override
go

sp_configure 'Ad Hoc Distributed Queries',1
reconfigure with override
go


If after this you still get an error about name pipes, enable them.
https://www.blackbaud.com/files/support/infinityinstaller/content/installermaster/tkenablenamedpipesandtcpipconnections.htm