Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

How to Test Connectivity for a Linked Server

By Chris Morton,

Hi i forgot to include this from my last post:

How to insert and update from remote linked server Created: 8/7/2007 1:10:01 AM

This script is part of that post but is also useful by itself.

This script test for connectivity to a linked server...


This code depends on:

USE [DIMSCONSOLIDATEDData]
GO
/****** Object:  UserDefinedFunction [dbo].[General_FXN_Alias]    Script Date: 08/07/2007 08:44:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:       
-- Create date:
-- Description:   
-- =============================================
CREATE FUNCTION [dbo].[General_FXN_Alias]
(
    @DistrictID int,
    @Table varchar(50) = 'sysobjects'
)
RETURNS varchar(90)
AS
BEGIN
    -- Declare the return variable here
   
    -- Add the T-SQL statements to compute the return value here
    

   
    RETURN (SELECT Alias from General_District where districtID = @districtID) + '.' + @Table

END

and

USE [DIMSCONSOLIDATEDData]
GO
/****** Object:  Table [dbo].[General_Error_Log]    Script Date: 08/07/2007 09:21:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[General_Error_Log](
    [ErrorID] [bigint] IDENTITY(1,1) NOT NULL,
    [ErrorMessage] [varchar](255) NULL,
    [DateTime] [datetime] NOT NULL,
    [Alias] [varchar](50) NOT NULL,
    [Sproc] [varchar](50) NOT NULL,
    [ErrorCode] [int] NULL
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

Total article views: 2549 | Views in the last 30 days: 4
 
Related Articles
SCRIPT

Generate Drop / Create Script for views, stored Procedures

This Script generates drop and create scripts for views or stored procedures.

FORUM

Automate "Generate Scripts" in SQL Job

I would like to create a SQL job that automatically runs the Generate Scripts process.

FORUM

Dynamic Stored Proc to generate Create Table Script ,taking table_name as parameter

Dynamic Stored Proc to generate Create Table Script ,taking table_name as parameter

FORUM

Generate Script File Name

Generate Script File Name

SCRIPT

Dynamically create drop user statistics scripts

Generate script to drop any unwanted user created statistics.

Tags
chris morton    
codrakon    
linked server    
miscellaneous    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones