Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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: 2574 | 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

ARTICLE

A Standard Database Security Script Generator

A script generator for standard security compliance.

Tags
chris morton    
codrakon    
linked server    
miscellaneous    
 
Contribute