• Peter, thank you so much for taking your good time to work on my problem, I am truly humbled by your knowledge.

    Peter Brinkhaus (1/13/2012)


    What's the data type of Column1 one in DB2? It looks like a structure containing 6 columns:

    Pos 1: CHAR(1) - 'B' = 0xC2 (EBCDIC) = 0x42 (ASCII)

    Pos 2-7: NUMERIC(11) Packed decimal - 0x00000012700C (0xC = plus sign)

    Pos 8: CHAR(1) - 'M' = 0xD4 (EBCDIC) = 0x4D (ASCII)

    Pos 9: NUMERIC(11) Packed decimal - 0x00000003673C (0xC = plus sign)

    Pos 15: CHAR(1) - 'N' = 0xD5 (EBCDIC) = 0x4E (ASCII)

    Pos 16-21: NUMERIC(11) Packed decimal - 0x00000000850C (0xC = plus sign)

    Your break down makes perfect sense now, as I could not get how a single field could actually be an array.

    When using the four part naming convention the entire structure is translated from EBCDIC to ASCII byte by byte.

    The four part naming convention is causing me some trouble, as I can not get it to work with the IBM provider. If I use the MSDASQL provider, I can use it if I leave level zero only unchecked, and omit the catalog. The problem here is that I cannot see the objects. If I use the IBM provider, I can not get 4 part name to work regardless of the level zero value. There is somewhat of a language barrier between the dba's and me, because they do not know SQL Server, and I don't know DB2, so I don't even get what the catalog is. I scripted out my linked server, and tweeked it a bit for others to easily use, maybe you could Identify what I am doing wrong?

    --==== Declare the local variables needed to make the connection. You will need to run this script

    -- every time your mainframe password changes.

    DECLARE @user VARCHAR(100),

    @pwd VARCHAR(100),

    @connection VARCHAR(100),

    @local VARCHAR(100),

    @LinkedServer VARCHAR(20),

    @dsn VARCHAR(20)

    --==== Set the values of the local variables

    SELECT @user = '#######' --<<<< change this to your EID

    SELECT @pwd = '#######' --<<<< change this to your mainframe password

    SELECT @connection = 'Password=' + @pwd + ';Persist Security Info=True;User ID=' + @user

    SELECT @local = '#######\' + @user --<<<< change to your domain

    SELECT @LinkedServer = '#######' --<<<< change to your preference

    SELECT @dsn = '#######' --<<<< change to your dsn

    --==== Drop the linked server if it already exists.

    IF EXISTS (SELECT srv.name

    FROM sys.servers srv

    WHERE srv.server_id != 0

    AND srv.name = @LinkedServer)

    EXEC master.dbo.sp_dropserver @server= @LinkedServer, @droplogins='droplogins';

    EXEC master.dbo.sp_addlinkedserver

    @server = @LinkedServer,

    @srvproduct = 'DB2',

    @provider = 'MSDASQL', -- can use 4 part name is catalog omitted, level zero only not checked

    --@provider = 'IBMDADB2', -- 4 part name does not work, don't know what is catalog

    @datasrc = @dsn,

    @provstr = @connection;

    EXEC master.dbo.sp_addlinkedsrvlogin

    @rmtsrvname ='MIRROR',

    @useself ='False',

    @locallogin = @local,

    @rmtuser = @user,

    @rmtpassword = @pwd;

    Again, thank you for your help.

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.