linked-server

SQL Server 2000 - Linked Server

大兔子大兔子 提交于 2019-11-29 08:47:14
For our application, we using SQL Server 2000 & MySQL. I want to update the MySQL database if any modifications in SQL Server 2000. For this, I have created the Linked Server for MySQL. It works fine, but inside the trigger it shows the error message like [OLE/DB provider returned message: [MySQL][ODBC 3.51 Driver]Optional feature not supported] Msg 7391, Level 16, State 1, Procedure , Line 6 The operation could not be performed because the OLE DB provider 'MSDASQL' was unable to begin a distributed transaction." And this is my trigger, alter trigger upd_test_enum on mtest for insert as begin

How can I connect to an external database from a sql statement or a stored procedure?

烈酒焚心 提交于 2019-11-29 06:43:53
When running a SQL statement or a stored procedure on a database, can you connect to an external database and pull data from there? something like: SELECT a.UserID, b.DataIWantToGet FROM mydb.Users as a, externaldb.Data as b You'll need to setup a Linked Server instance . Then you can reference the external database as though it were a SQL Server database. Yep -- there's two methods: either use the function OPENROWSET , or use linked servers. OPENROWSET is useful for ad-hoc single statements, but if you're going to be doing this regularly, read up on linked servers as they allow you to do

Can you have a Foreign Key onto a View of a Linked Server table in SQLServer 2k5?

淺唱寂寞╮ 提交于 2019-11-29 04:43:51
I have a SQLServer with a linked server onto another database somewhere else. I have created a view on that linked server create view vw_foo as select [id], [name] from LINKEDSERVER.RemoteDatabase.dbo.tbl_bar I'd like to to the following alter table [baz] add foo_id int not null go alter table [baz] with check add constraint [fk1_baz_to_foo] foreign key([foo_id]) references [dbo].[vw_foo] ([id]) go But that generates the error: "Foreign key 'fk1_baz_to_foo' references object 'dbo.vw_foo' which is not a user table." If I try and put the foreign key directly onto the table using the following

Insert Data From One Server To Another?

只愿长相守 提交于 2019-11-29 04:33:45
If I want to run this sort of query in SQL Server, how can I do the same query from one server I am connected to to another? I tried adding "[ServerName1]." before "[DatabaseName1].[dbo]..." and "[ServerName2]." before "[DatabaseName2].[dbo]..." but that didn't seem to work. INSERT INTO [DatabaseName1].[dbo].[TableName] ([FieldName]) SELECT [FieldName] FROM [DatabaseName2].[dbo].[TableName] Is this possible? HLGEM Yes you would use the server-name before the whole rest of object-name like: myserver.mydatabase.dbo.mytable However you first have to set up linked servers. Look up linked servers

Calling Oracle stored procedure with output parameter from SQL Server

巧了我就是萌 提交于 2019-11-28 23:26:39
I have an Oracle linked server in SQL Server 2008 R2. I need to execute Oracle stored procedures (with output parameter in first, and input parameter in second procedure): CREATE OR REPLACE PROCEDURE my1.spGetDate(CurrentDate OUT VARCHAR2) IS BEGIN -- set output parameter, no select statements END; CREATE OR REPLACE PROCEDURE my1.spDeleteOldRecords(CurrentDate IN VARCHAR2) IS BEGIN -- conditional delete from oracle table, no select statements END; I didn't found any complete documentation on this question, only simple examples with parameterless select/nonselect procedures, and want to know,

error when insert into linked server

不羁的心 提交于 2019-11-28 08:29:29
I want to insert some data on the local server into a remote server, and used the following sql: select * into linkservername.mydbname.dbo.test from localdbname.dbo.test But it throws the following error The object name 'linkservername.mydbname.dbo.test' contains more than the maximum number of prefixes. The maximum is 2. How can I do that? I don't think the new table created with the INTO clause supports 4 part names. You would need to create the table first, then use INSERT..SELECT to populate it. (See note in Arguments section on MSDN: reference ) The SELECT...INTO [new_table_name]

Why do I get the error “Xml data type is not supported in distributed queries” when querying a linked server for non-xml data?

一曲冷凌霜 提交于 2019-11-28 05:12:05
I have two SQL Servers (running SQL Server 2008) named DATA01 and DATA02 . DATA02 has a linked server definition LINK , that points at DATA01 , with suitable user mapping set up. On DATA01 there is a database MyDatabase containing these two tables: CREATE TABLE T_A ( Id int ) CREATE TABLE T_B ( Id int, Stuff xml ) When I run this command from DATA02 , I get data returned as expected: SELECT Id FROM LINK.MyDatabase.dbo.T_A; However, when I run this command from DATA02 , I get an error: SELECT Id, Stuff FROM LINK.MyDatabase.dbo.T_B; The error is Xml data type is not supported in distributed

Stored Procedure and populating a Temp table from a linked Stored Procedure with parameters

依然范特西╮ 提交于 2019-11-28 03:51:59
问题 I have a Stored Procedure (SP) in which I pass in one value. In this SP, I am trying to create/populate a Temp Table from the result of another SP that is on a Linked/remote server. That is I am trying to executute an SP in my SP and populate a temp table which my query will use. I have tried using the following syntax, but it does not work as it seems openquery does not like the "+" or the @param1 parameter. select * into #tempTable from openquery([the Linked server],'exec thelinkedSPname '

Distributed Transaction on Linked Server between sql server and mysql

半腔热情 提交于 2019-11-28 03:45:00
问题 I have a table say Table1 on SQL Server 2014 and MySQL both. Table1 ID INT,Code VARCHAR(100) I created a linked server MyLinkedServer in SQL Server using "Microsoft OLEDB Provider for ODBC". **Linked Server ** EXEC master.dbo.sp_addlinkedserver @server = N'MyLinkedServer', @srvproduct=N'MyLinkedServer', @provider=N'MSDASQL', @datasrc=N'MyLinkedServer' EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'MyLinkedServer',@useself=N'False',@locallogin=NULL,@rmtuser=N'username',@rmtpassword='######

How to find a text inside SQL Server procedures / triggers?

天涯浪子 提交于 2019-11-28 02:33:26
I have a linkedserver that will change. Some procedures call the linked server like this: [10.10.100.50].dbo.SPROCEDURE_EXAMPLE . We have triggers also doing this kind of work. We need to find all places that uses [10.10.100.50] to change it. In SQL Server Management Studio Express, I didn't find a feature like "find in whole database" in Visual Studio. Can a special sys-select help me find what I need? KM. here is a portion of a procedure I use on my system to find text.... DECLARE @Search varchar(255) SET @Search='[10.10.100.50]' SELECT DISTINCT o.name AS Object_Name,o.type_desc FROM sys.sql