There are certain scenarios where we need to access an object (table, SP, etc) of remote server's database.
In such cases, we need to add that remote server as a Linked server in our SQL Server.
We can add a linked server by following path in Object Explorer of your SQL Server's Management Studio:
Server Objects >> Linked Servers; Right-click and add new linked server, and provide details of remote server you wish to link.
But if your remote server is a 32-bit SQL Server 2000, and your host server is 64-bit SQL Server 2005/2008, then generally you would be getting a following error while accessing any object (i.e. Table, SP, etc) of that remote server.
Query Execeution failed. Could not obtain the schema rowset "DBSCHEMA_TABLES_INFO" or similar message.
if you follow some articles over internet, they have suggested to execute some critical scripts to your remote server. This script file is of some 700KB, and performs lots of drop and create operation. This does not sound to be a good solution honestly.
The actual problem here is that, when you try to query an object of a remote sql server, it executes sp_tables_info_rowset in background. This happens without any issue if both the hosting and remote SQL server are of similar type.
But when you try to query an object of a remote sql server from a 64-bit connection, it attempts to execute sp_tables_info_rowset_64 sp, which obviously not a part of SQL Server 2000 installation.
So the simple workaround is to create this SP on remote SQL Server's master database, and this will simply a wrapper of sp_tables_info_rowset SP that already exist in remote SQL Server's master database.
Following is the script to create this SP:
Execute it in master database of remote sql server.
CREATE PROCEDURE sp_tables_info_rowset_64
@table_name sysname,
@table_schema sysname = null,
@table_type nvarchar(255) = null
AS
DECLARE @Result int
SET @Result = 0
EXECUTE @Result = sp_tables_info_rowset @table_name, @table_schema, @table_type
Once done, you should be able to query the database hosted on that remote server without any trouble.
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2012
(49)
-
▼
April
(24)
- Get only Date part for SQL Server DateTime value
- Membership in ASP.NET MVC 4 (System.Web.Providers)
- Binding two or more types of objects (models) to s...
- Implement Custom Validation in ASP.NET MVC
- Simple client-side Validations using ASP.NET MVC
- Investigation: Values do not retain in model while...
- Data Binding to RadioButton in a View in MVC
- Investigation: SelectedIndexChanged not firing for...
- Investigation: ExecuteNonQuery() always returns -1
- Development and Deployment - Troubleshooting, Inve...
- Print Page Content to printer (or virtual print ou...
- Show long text in Tooltip
- Auto login into Team system with your authorized c...
- Visual Studio .NET - Some handy shortcuts
- Write custom events for User Controls in ASP.NET
- SQL Query to return each date of month in each dif...
- How to debug ASP.NET Windows Service
- FIX: Add a 32-bit SQL Server 2000 as a Linked serv...
- Difference between integer Cast and Convert in C#
- Optimizing SQL Code by replacing IF..ELSE with CAS...
- Check Authentication Mode in ASP.NET
- How to validate a page using Java script
- SQL Query - To search for a column (by column name...
- C#.NET - Difference between Convert.ToString(), .T...
-
▼
April
(24)
Thanks Nirman
ReplyDeleteexplanation and solution is excellent
much appreciated
Wow, that's what I was looking for.. Thanks Nirman for sharing this info.. You certainly saved some hours :)
ReplyDelete