Read a .ini file

  • I have a sp which will insert data into a table which is on different machine. I use the sp_addlinkedserver and the machine name to insert a record.

    But i dont want to use this method.

    I will store the machine name or server name in an *.ini file. I will open the ini file read the content and pick the appropriate machine name. Is this possible. Pls advice. Hope my question is clear?

    Suresh


    Suresh

  • Take a look at BOL on the topic "OPENROWSET". I think this is what you are referring to. Ad hoc queries on different servers.

    Darren


    Darren

  • Hi there

    Try this from a MS script I have been using for some time that deals with an INI file...

    set @i = 'C:\ActivityTrace.ini'

    if exists (select * from dbo.sysobjects where id = object_id(N'[_t1]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

    drop table [_t1]

    create table _t1 ([c1] nvarchar(512))

    exec ('bulk insert _t1 FROM '''+@i + '''')

    <etc>

    select @job_name = cast(rtrim(ltrim(substring(c1,charindex('=',c1,1)+1,len(c1)))) as sysname) from _t1 where left(c1,3) = '@jo'

    Cheers

    Chris K

    http://www.chriskempster.com


    Chris Kempster
    www.chriskempster.com
    Author of "SQL Server Backup, Recovery & Troubleshooting"
    Author of "SQL Server 2k for the Oracle DBA"

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

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