I have written statement using OpenQuery and now want to join it onto my another query, so that when I run the view it returns a table with records from both selects. How would I go about this? These are the queries I currently have: Answer Why not just literally JOIN to it?
Tag: openquery
Insert data into a table from Open Query with variable
I am trying to using OPENQUERY to pull some data into a table. Here’s what my code looks like: I end up with the following error: An INSERT statement cannot contain a SELECT statement that assigns values to a variable. When I attempt to run the EXEC(@TSQL) without the INSERT it works like a charm, but I am unable to
insert value from join with If/Case from two tables, into a third table
So I have the following issue in creating a sql query. A linked server so am using an open query. (edit update: SQL Server) Two tables as per picture below: I need to insert value into a third table, the value to insert to the third table comes from the two tables above which I join via KEY ID. However,
SQL OPENQUERY, Incorrect syntax near ‘+’
I have this sql query: DECLARE @VAR varchar(8) SET @VAR = ‘20140202’ SELECT * FROM OPENQUERY([NMD],’SELECT * FROM NmdItemGroups01.dbo.InvTranDtl WHERE TranDate = ”’ + @VAR + ””) But when I run …
DELETE FROM Openquery
I’m doing a project at work regarding linked servers. As we need to pass the name of the linked server I came up with this approach: DECLARE @OPENQUERY nvarchar(4000), @TSQL nvarchar(4000), @…
How to test linkedserver’s connectivity in TSQL
I need to write a procedure to collect data from several remote servers, I use linkedservers and OPENQUERY to gather data from servers, but sometimes I lose connection to some servers or I simply can’t connect them (e.g. remote server is offline)- and OPENQUERY results in time-outs in these cases. So I wanted to check linkedservers connectivity first and then