insert/update fox pro dbf file

  • How can I use sql server (store procedure) to update/insert fox pro .dbf files ???

    Can anyone help?

    Thx

  • You could set up a linked server to the foxpro database and use

    update openquery(linkservername, 'select colname from tablename where keyname = keyvalue')

    set colname = 'updatevalue'

    Far away is close at hand in the images of elsewhere.
    Anon.

  • And how can I set up a lined server to my .DBF file ?

    I need to make some dynamic updated, can I do it ?

  • These links will help, plus check Books Online

    HOWTO: Add a FoxPro Database to SQL Server as a Linked Server

    http://support.microsoft.com/default.aspx?scid=kb;en-us;199131

    HOWTO: Do SQL Server 7.0 Distributed Queries With FoxPro .dbf Files

    http://support.microsoft.com/default.aspx?scid=kb;en-us;199131

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Cool, it's working...

    But I need to make dynamic querys like:

    select * from openquery(linkedserver,@SQL)

    but with openquery I cannot use variables...

    How can I make dynamic querys?

     

  • I use dynamic sql and sp_executesql

    SET @sql2 = 'select * from openquery(' + @linkedserver + ',''' + @sql + ''')'

    EXEC sp_executesql @sql2

    Make sure you understand the risks with dynamic sql (injection etc). There are articles on this forum that discuss this subject.

    Make sure you have the correct number of single quotes (see example above). If the query in @sql has quoted data then you have to use two quotes, eg

    set @sql = 'select col1 from tablea where col2 = ''''X'''''

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Can I use INSERT command to insert rows in my .DBF file ?

    Can you post me an example?

  • Have not tested, but try this

    insert openquery(linkedservername, 'select col1,col2,col3 from tablename where 1=0') values (col1value,col2value,col2value)

    Far away is close at hand in the images of elsewhere.
    Anon.

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

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