i use sql server 2008 for publisher and sql server 2005 express for subscriber ,
when i insert to a table from my subscriber this error occur :
Msg 21079, Level 16, State 1, Procedure sp_getpublisherlink, Line 52
The RPC security information for the Publisher is missing or invalid. Use sp_link_publication to specify it.
Msg 20512, Level 16, State 1, Procedure sp_MSreplraiserror, Line 8
Updateable Subscriptions: Rolling back transaction.
Msg 3609, Level 16, State 1, Line 1
The transaction ended in the trigger. The batch has been aborted.
when insert to table from publisher all thing is ok .
Try creating the link on the subscriber. Run this on your subscriber database.
sp_link_publication #publisher = '{publisher instance name}'
, #publisher_db = '{published database name}'
, #publication = '{publication name}'
, #security_mode = '1'
, #login = '{sql server login account to connect publisher}'
, #password = '{password}'
, #distributor = '{distributor instance name}'
Related
Looking for pointers on how to resolve this issue.
I have a linked server setup.
This query works in SSMS, I get rows back.
SELECT tbl.[Col1]
,tbl.[CoL2]
FROM [LINKEDSERVER].[CATALOG].[SCHEMA].[TABLENAME] tbl
But trying to do the same in SSMS with OPENQUERY fails
SELECT [Col1]
FROM OPENQUERY([LINKEDSERVER],
'SELECT tbl.[Col1]
,tbl.[CoL2]
FROM [LINKEDSERVER].[CATALOG].[SCHEMA].[TABLENAME] tbl'
) As Whatever
The messages are as follows:
OLE DB provider "SQLNCLI11" for linked server "SERVER" returned
message "Deferred prepare could not be completed.". Msg 8180, Level
16, State 1, Line 1 Statement(s) could not be prepared. Msg 7202,
Level 11, State 2, Line 1 Could not find server 'SERVER' in
sys.servers. Verify that the correct server name was specified. If
necessary, execute the stored procedure sp_addlinkedserver to add the
server to sys.servers.
The server name SERVER does appear when I check select * from sys.servers
OPENQUERY from here against other linked servers is successful.
Because when you use OPENQUERY you send the query you want to run on the remote server. The error is being thrown by the remote server. Take out the linked server name in the query. Something along these lines.
SELECT [Col1]
FROM OPENQUERY([LINKEDSERVER],
'SELECT tbl.[Col1]
,tbl.[CoL2]
FROM [CATALOG].[SCHEMA].[TABLENAME] tbl'
) As Whatever
This sentence its use with another server but , its ok try this:
EXEC SP_SERVEROPTION 'SERVER\INSTANCIA' ,'DATA ACCESS',TRUE
SELECT * FROM OPENQUERY(YOURSERVER,'SELECT * FROM TABLE').
And its done. :)
I have 3 SQL Servers, and I'm getting strange behavior with OpenRowset.
Given:
Server 1 = 192.168.1.1,
Server 2 = 192.168.1.2,
Server 3 = 192.168.1.3,
Server 4 = 192.168.1.4
SQL:
SELECT a.*
FROM OPENROWSET('SQLOLEDB',
'Data Source=192.168.1.1;Persist Security
Info=True;uid=sa;pwd=password',
'SELECT * FROM dfs_database.dbo.dfs_vehicledata ') AS a;
Here is the strange part: if I run the above SQL statement on servers .3 and .4, everything works fine.
However, if I run the SQL statement on server .2, I get:
OLE DB provider "SQLNCLI11" for linked server "(null)" returned message "Deferred prepare could not be completed.".
Msg 8180, Level 16, State 1, Line 7
Statement(s) could not be prepared.
Msg 208, Level 16, State 1, Line 7
Invalid object name 'dfs_database.dbo.dfs_vehicledata'.
So what could make one relationship not work when the others work fine? Any ideas? They are all SQL Server express, and all report having SQLNCLI11 providers.
Using OpenRowSet it look like this:
sp_configure 'Show Advanced Options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
GO
OPENROWSET('SQLNCLI',
'Server=ipHere\ExtentionNameifHas;Database=DBName;Uid=userName;PWD=Password;'
,'SET FMTONLY OFF;SET NOCOUNT ON;SELECT * FROM
dfs_database.dbo.dfs_vehicledata'
From the error log try changing the OLE DB provider name from 'SQLOLEDB' to 'SQLNCLI11' and also
check the location of the object. Make sure to give the full location with database, table etc.
I try to do a across database query in AZURE SQL elastic pools but it's not working.
My stored procedure is:
CREATE PROCEDURE [dbo].[CreateNewSurveyQuestion]
#QuestionString varchar(MAX)
AS
INSERT INTO CTRL_Survey(SurveyQuestion)
VALUES (#QuestionString)
--create new survey in new qm
EXEC sp_execute_remote
N'QCentralDS',
N'INSERT INTO [dbo].[SurveyTbl]([Question], [IsActive], [CreateDate])
VALUES(#QuestionStringValue, 1, GETDATE())'
, N'#QuestionStringValue varchar(300)'
, #QuestionStringValue = #QuestionString
EXEC stored procedure [not working with error message below]
EXEC [dbo].[CreateNewSurveyQuestion]
#QuestionString = N'Add a new question'
Error message:
Msg 64, Level 20, State 0, Line 1
A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The specified network name is no longer available.)
I am sure all EXTERNAL DATA SOURCE are correct. And I can run this part in my SQL Server Management Studio successfully.
EXEC sp_execute_remote
N'QCentralDS',
N'INSERT INTO [dbo].[SurveyTbl]([Question], [IsActive], [CreateDate])
VALUES(#QuestionStringValue, 1, GETDATE())'
, N'#QuestionStringValue varchar(300)'
, #QuestionStringValue = #QuestionString
Is there any issue with this mode of work, or exists another way to do it?
I really don't care what I do with this test database...it's for sandbox testing (attached to a production server instance)! All I'm trying to do is KILL all connections, drop and create test_db, if not asking for to much....and restore with some test data.
I've tried USE [MASTER] RESTORE DATABASE test_DB WITH RECOVERY GO , but got this error:
Msg 3101, Level 16, State 1, Line 1
Exclusive access could not be obtained because the database is in use.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
Also, tried
USE [master] ALTER DATABASE test_DB SET SINGLE_USER WITH ROLLBACK IMMEDIATE;, and got error:
Msg 5061, Level 16, State 1, Line 1
ALTER DATABASE failed because a lock could not be placed on database 'test_DB'. Try again later.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
Also did
select min(spid) from master..sysprocesses where dbid = db_id('test_DB'), but my result set returned NULL
Below is my code:
--- Kill Connections
USE [master]
DECLARE #cmdKill VARCHAR(50)
DECLARE killCursor CURSOR FOR
SELECT 'KILL ' + Convert(VARCHAR(5), p.spid)
FROM master.dbo.sysprocesses AS p
WHERE p.dbid = db_id('test_DB')
OPEN killCursor
FETCH killCursor INTO #cmdKill
WHILE 0 = ##fetch_status
BEGIN
EXECUTE (#cmdKill)
FETCH killCursor INTO #cmdKill
END
CLOSE killCursor
DEALLOCATE killCursor
--Drop and Create
USE [master]
GO
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'test_DB')
DROP DATABASE [test_DB]
GO
USE [master]
GO
CREATE DATABASE [test_DB] ON PRIMARY
( NAME = N'test_db_Data', FILENAME = N'\\some_place\d$\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\test_DB.mdf' , SIZE = 125635136KB , MAXSIZE = UNLIMITED, FILEGROWTH = 20%)
LOG ON
( NAME = N'test_db_Log', FILENAME = N'E:\SQLLogs\test_DB.ldf' , SIZE = 1064320KB , MAXSIZE = UNLIMITED, FILEGROWTH = 20%)
GO
ALTER DATABASE [test_db] SET ....
A database cannot be taken offline if there are still open connections to it.
Also, make sure your connection is not using that DB (USE master) then use the WITH ROLLBACK IMMEDIATE option of the ALTER DATABASE to take it offline.
Do you know who is connected?
SELECT
DB_NAME(dbid) as 'DBName'
, loginame as 'Login'
, COUNT(dbid) as 'Connections'
FROM
sys.sysprocesses
WHERE
dbid > 0
GROUP BY
dbid
, loginame
I’m trying to send an email from a scheduled SQL Agent job using sp_send_dbmail and receive the following error:
Msg 22050, Level 16, State 1, Line 0
Error formatting query, probably invalid parameters
Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 504
Query execution failed: Msg 15404, Level 16, State 19, Server MyServer, Line 1
Could not obtain information about Windows NT group/user 'MyDomain\sqlagent', error code 0x5.
Here is the code from the job step:
DECLARE #SQL NVARCHAR(400)
SELECT #SQL = 'SELECT COUNT(staff_id) FROM Staff'
EXEC msdb.dbo.sp_send_dbmail
#recipients = 'me#myemail.com',
#subject = 'Email Alert',
#body = 'Test',
#query = #SQL,
#execute_query_database = 'MyDB'
SQL Agent is running under a domain account [MyDomain\sqlagent]. I granted this user db_owner permission in the MyDB database in addition to adding it as a member of the DatabaseMailUserRole in msdb. Still no luck. If I remove the #query and #execute_query_database parameters it will send a ‘test’ email. However, I need to attach the results from the query.
Any help is appreciated, thanks.
I've run into some strange errors with AD in the past. I would recommend checking that the account you are running this under has it's attributes readable within AD. The quickest way to do that would be to run
exec xp_logininfo 'MyDomain\sqlagent'
and seeing if you get the same error. If you do, check the security properties of the domain account [right click the user in Active Directory > Properties > Security tab] and set Read permissions for Authenticated Users.
This worked for me.
'SELECT columnname from YourDatabase.SchemaName.tablename'
I found this answer here.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/7869b033-80f1-4594-a77e-fb6dce582fb4/error-msg-when-sending-email-using-spsenddbmail?forum=transactsql