OPENROWSET

  • Is there a way to use a variable in an openrowset string?? ie

    DECLARE @a varchar(50)

    set @pth = 'C:\myDB.mdb'

    SELECT a.[ID],isnull(a.[Address line 1],''),isnull(a.[Address line 2],''),isnull(a.[Address line 3],''),

    isnull(a.State,''),isnull(a.Postcode,''),isnull(a.[Postal address line 1],''),isnull(a.[Postal address line 2],''),

    isnull(a.[Postal address line 3],''),isnull(a.[Postal State],''),isnull(a.[Postal address postcode],''),a.Expr1,a.Expr2,

    a.Expr3,a.Expr4,a.Expr5

    FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',

    @pth ;'Admin';'', 'SELECT Member.[ID], Member.[Address line 1],

    Member.[Address line 2], Member.[Address line 3], Member.State, Member.Postcode, Member.[Postal address line 1],

    Member.[Postal address line 2], Member.[Postal address line 3], Member.[Postal State], Member.[Postal address postcode],

    61 AS Expr1, "" AS Expr2, "" AS Expr3, 0 AS Expr4, "" AS Expr5

    FROM Member;')

    AS a

    The only way it works is with the EXECUTE statement. Is there other syntax I can use.

    Bruce

  • According to the "Remarks" section in the product documentation:

    "OPENROWSET does not accept variables for its arguments."

    - Troy King


    - Troy King

  • Thanks Troy. I'll keep working with the execute method.

    Bruce

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply