I have been trying to find a solution to this for some time now. Was wondering if some1 had done is earlier and has a solution.
I have a 2 server machines.
Namely: ServerOne and ServerTwo
ServerOne (main server, On 1 machine.)
Table - Foofoo
ServerTwo (secondary server, on another machine)
Table - Booboo
I want to be able to link these two servers and work with them.
At the moment I do something like this.
NB. My Stored Procedure is on ServerOne
declare @server varchar(100)
Select @server=Servername from ServerOne.systemsettings where name='secondary'
-- @server is not equal to 'ServerTwo'
declare @str varchar(8000)
set @str = '
select *
from Foofoo f
join ' + @server + '.myDB.dbo.Booboo b on b.id = f.id '
exec(@str)
My problem is that this works fine but I do not like working with long strings and then executing them at the end.
I have also been told that SQL's performance on this is not entirely that well as normal select's would be.'
Another thing that could be used is SQl's own linked servers method but apparently out system was designed some time ago and a lot of things have been developed around the current technic.
Our server names also change quite frequently making hadcoding server names difficult.
Using the string exec convention also hides from sql when you do a dependency search of a particular table.
Is there a way I can save the server name on @server and then just add it to the select stmt without using the long stringing idea.
Any feedback with ideas and solutions will be greatly appreciated.
I'm having some weird problems with calling remote stored procedures.
Two servers, both windows 2000 sp2, both running sql 7 version 7.00.961.
Server A is actually a cluster, but server B is a development server and not a cluster.
First off, server B can link to server A, but server A can't link to server B. We get a can't create connection error. We've used the client network utility to specify tcp/ip for both. I'm using the link settings as SQL Server connection (rather than an odbc connection) mapped to the sa user id and password. The password is blank on server B though.
I can run a remote stored procedure on server A from server B fine. I get the proper response back too. I can select anything from any database on A from B without trouble.
But here's my problem: If I use exec @result=ServerA.MyDB.dbo.myproc from server B, @result is always null. If I run MyDB.dbo.myproc from server A directly, @result comes back with the proper value.
I tried using an OUTPUT argument but it has the identical results. If I run it on server A, it works. If I run it from server B, the output argument is null.
Just for grins, I tried setting the @result value to 0 before calling MyProc. It didn't come back null, but it came back as the same value I set it before calling the procedure.
I verified that the sqlagent user has full permissions to the temp directory. TMP and TEMP both point to the same ..localemp directory, and it has full permissions in that directory.
Does anyone have any idea of things I can try? Is there a known bug with cluster services? I don't think this is happening when server B links to another server that isn't clustered.
I am using the EXEC function in order to specify which view to access. However I can not get the datediff to work with it....does anyone have any clues?
I am using SQL Server 7 Beta 3 and I am having trouble with using a variable in an EXEC statement.
I have a stored procedure that is designed to retrieve a serial number from a table and then increment it by one(1) and return the original serial number to the calling function.
As long as the table name is hardcoded the following code works fine:
Following is the error message that I keep getting:
Server: Msg 170, Level 15, State 1 [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near `=`.
No amount of testing with different qoutes or doublequotes and such, have made any difference.
I have tried numerous variations on the above SELECT statement with the same end result of the error on the "=" sign.
I cannot seem to assign one variable to another using the "=" (equal sign) in an EXEC statement.
Does anyone have example code of using the equal sign to assign one variable to another in an EXEC statement or can someone point me in the right direction?
I am trying to make up a SQL string which will be executed with the Exec command
I want to add a return column that is not in the table, and the table columns:
something like Select @Ten As Ten, @Tablename.* From @Tablename ( where @Ten has an integer value. ) The statement was originally: select @SQL = 'select * from ' + @TempName exec (@SQL) which had no problem. Then I needed to add an extra column of static data to all the returned rows, and confusion !!!!!
What I'm trying to accomplish is to execute a SQL string via exec and inside it set the value of a local variable. I understand that I cannot do this the way I'm currently doing it because an Executed string runs in a scope of its own so local variables are invisible. And sure enough this is the error I get. So how do I make this work?
Code snip:
declare @ErrMessage as varchar(1000) set @Sql = 'if exists ( select * from ' + @TargetTable + ' where (' + @ValueField + '=' + '''' + @NewValue + '''' set @Sql = @Sql + ' and ' + @TagField + '= ' + '''' + @Tag + '''' + '))' + @CRLF set @Sql = @Sql + 'set @ErrMessage = ''Insertion could not be performed. ' + @NewValue + ' is already an entry in the table. '''
So what I want is check if a certain table has entries...what table? I don't know, there are tens that this check will apply to. And if that tavle has an entry that satisfies the where clause then assign the appropriate error message to @ErrMessage.
I understand sp_executesql might do the trick because it allows passing local params back and forth.
Any ideas on how to make this work? I appreciate the effort.
can anybody tell me about Linked Servers and their uses and how to add a linked server to my Sql Server 2005. any help on this would be highly appreciated.
I have been trying to Link two sql servers on two different machines over the Internet without any luck. Can someone point me to information about doing this with good examples?
I currently have a main SQL Server which had a column on the majority of the tables. This column also had a check contraint on it. I dropped the column and the constraint and I now get the following message when trying to query the tables through a linked server 'OLE DB provider 'SQLOLEDB' supplied inconsistent metadata. An extra column was supplied during execution that was not found at compile time.'.
Hi All, I have successfully linked a server and had SQL queries running OK for a few weeks, but today I get the following message....
"OLE DB provider 'SQLOLEDB' supplied inconsistent metadata. An extra column was supplied during execution that was not found at compile time." (Server: Msg 7353, Level 16, State 1, Line 1)
I've dropped the link and recreated it but I still get the same error message. Can anyone help???
I have a DTS package that requires me to link 2 servers and query both in order to get my set of records that I want to Transform. My query runs fine in QA. I copy and paste it into the SQL Query window of the transformation. I click Preview and all that happens is a quick flicker of the DTS window. When I go to Transformations, there are no source columns.
Here is a copy of my code that I'm trying to use: ------------------------------------------------------- declare@start_dteas datetime, @end_dteas datetime
SELECTT70.* FROM CRMDEV02.MDCORE.DBO.T70_MD_UNIVERSE_RELATIONSHIP_M A NGT AS T70 JOIN #RUNS ONT70.RUN_ID = #RUNS.RUN_ID
DROP TABLE #RUNS ------------------------------------------------------ Is there an issue with Linked Servers and DTS? Any help would be greatly appreciated.
Hi Gurus, I am looking for literature to find out Pros and Cons of Using DTS Verses Linked Servers in SQL 7.0.
My requirement can be done by either DTS or Linked servers. But I would like to know more about resorce utilisation of these tecniques before making a decission.
When I create linked server using integrated security and <they will be impersonated> option I get this: Server: Msg 18456, Level 14, State 1, Line 1 Login failed for user '' MS Technet says that SQL Server 7 doesn't allow double hops and to use mappings to standard security login to work around. @#%%~~@@#@#&^%@# Impersonating to version 6.5 works fine. Is there any way to link servers using ONLY integrated security? Any help would be much appreciated. Thanks
I have setup a linked Informix server in SQL7.0 and I am trying to create a simple View with the following SQL statement
SELECT doc_code FROM FOURSITE.foursite.informix.watdoc WHERE (order_no = [PV01963B ])
I am getting the following error:
--------------------------- SQL Server Enterprise Manager --------------------------- [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid use of schema and/or catalog for OLE DB provider 'MSDASQL'. A four-part name was supplied, but the provider does not expose the necessary interfaces to use a catalog and/or schema. --------------------------- OK Help ---------------------------
Hi. I'm working with SQL Server 7.0 and I've been reading about the linked server option. My question is, if it's possible to link a server with a SQLBase database 7.01.
I have download some drivers to my computer, the odbc driver for sqlbase and the sqlbase ole db driver as well, but when I try to add a new linked server in the enterprise, in the provider name option I can not see any provider name addressing to Centura or Sql base driver.
Has anybody an idea how to make this connection then? or the right way for doing it??
Thanks for any help can be offered. Regards, Elvia. :)
I have two 7.0 servers and I want to run a distributed query.
I did sp_addlinkedserver to link server B to server A and I did sp_addlinkedsrvlogin for a specific login. After adding login when I try to access a table on server B it says login failed
All the logins are NT authenticated (in both the servers, So both servers have same logins.)
Hi all I try to configure Linked Servers from the query analyze , and have some troubles. My steps are : 1. from the enterprise mennenger , add 2 new servers : srv1 , srv2 (both SQL7) 2. from the query analyzer of srv1.master: "sp_addlinkedserver 'srv2'" 3. from the query analyzer of srv1.master: "sp_addlinkedsrvlogin 'srv2',false,null,'sa','myPass'" 4. select * from srv2.pubs.srv2Table 5. I get the next error :"error 6 : Specified SQL srever not found."
This is my problem I have a Server A and Server B. There is a master table in Table A. I link Server A and Server B. When I look in Under Linked Server tables of B I can only C tables in Server A not the Server B 's Tables. Dpn't know what is happening. Could SOmebody help
I have two servers and they are linked servers. When I query a table on ON Box2 from Box1 The distributed query works fine but when I tried the oppisite it says 'SQL Server does not exist or access denied.' What could be the reason.
Recently, I had Microsoft review why our SQL Db was unexpectedly terminating. They pointed to our Oracle Linked servers. They recommended that we try to uncheck the enable allow in process option on the ODBC driver. We are currently using the Microsoft OLE Db provider for our Oracle connnections as we were unable to get the Oracle ones to work with a linked server. When we unchecked this allow in process option near the end of the day our website began getting out memory errors from ODBC. It appeared to have been because of this change. Does anyone have any insight as to why changing this option could have caused this?
Is there any limit to the number of linked servers i can add via EM?. where can i find more info on adding/configuring linked servers in MSSQL2k and the limitations/drawbacks if any?
We have a new 2005 server, and I am trying to link our old 2000 server so I can use the old databases in new server.
This is what I done: In 2005: EXEC sp_addlinkedserver oldServer --completed fine then: EXEC sp_addlinkedsrvlogin oldServer, 'false', NULL, 'Administrator', password --completed fine But whenI run the query I get the error:
OLE DB provider "SQLNCLI" for linked server "oldServer" returned message "Communication link failure". Msg 10054, Level 16, State 1, Line 0 TCP Provider: An existing connection was forcibly closed by the remote host. Msg 18456, Level 14, State 1, Line 0 Login failed for user 'Administrator'.
I have to link servers using sql server 2000 standard edition.... for anyone who has done this..... upon linking the servers using the other options radio button choice.... is it suppose to show all the databases for that server under the drop down.... its only showing tables and views... which i get an error 7339 or error 17:
can anyone assist...or lead me in the right direction..... thanks, jonathan