Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
msrnivas
Starting Member
4 Posts |
Posted - 2004-12-07 : 23:46:08
|
| Hi I am using Linkedservers in my SP.When i execute my SP giving below error.Pl advice how to set these options.thanksHeterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options tobe set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query. |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-12-08 : 00:09:09
|
guess you need to follow what sql tells you --------------------keeping it simple... |
 |
|
|
msrnivas
Starting Member
4 Posts |
Posted - 2004-12-08 : 02:33:32
|
| Hi JenSorry i am not getting what you are saying. my SP like below When i execute my qry with local table its fine ,if i specify linked server tablename(test.sales_DB.dbo.sales) its giving specified error.So where i have to set the values in my SP. CREATE PROCEDURE x AS DECLARE @TSQL varchar(8000), @VAR char(2) SELECT @TSQL = 'SELECT * FROM test.sales_DB.dbo.sales' EXEC (@TSQL) GO |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-12-08 : 02:36:47
|
| you need to issue inside your spcreate proc x asset ansi_nulls onset ansi_warnings on.....set ansi_warnings offset ansi_nulls offalso, don't use dynamic sql, just execute your query as is--editi think you just need thiscreate proc xasSELECT field1,field2,field3... FROM [test].[sales_DB].[dbo].sales--don't use * to retrieve data, enumerate the fields.--------------------keeping it simple... |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-12-08 : 02:43:08
|
this is from BOL, how to query using linked servers.quote: OPENQUERYExecutes the specified pass-through query on the given linked server, which is an OLE DB data source. The OPENQUERY function can be referenced in the FROM clause of a query as though it is a table name. The OPENQUERY function can also be referenced as the target table of an INSERT, UPDATE, or DELETE statement, subject to the capabilities of the OLE DB provider. Although the query may return multiple result sets, OPENQUERY returns only the first one.SyntaxOPENQUERY ( linked_server , 'query' ) Argumentslinked_serverIs an identifier representing the name of the linked server.'query'Is the query string executed in the linked server.RemarksOPENQUERY does not accept variables for its arguments.ExamplesThis example creates a linked server named OracleSvr against an Oracle database using the Microsoft OLE DB Provider for Oracle. Then this example uses a pass-through query against this linked server.Note This example assumes that an Oracle database alias called ORCLDB has been created.EXEC sp_addlinkedserver 'OracleSvr', 'Oracle 7.3', 'MSDAORA', 'ORCLDB'GOSELECT *FROM OPENQUERY(OracleSvr, 'SELECT name, id FROM joe.titles') GO
--------------------keeping it simple... |
 |
|
|
|
|
|
|
|