Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. import HOST file into a table

import HOST file into a table

Scheduled Pinned Locked Moved Database
databasetools
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    solutionsville
    wrote on last edited by
    #1

    I would like to import my HOST file into a DB Table and the periodically run a script to verify if all the entries are the same, changed, deleted, etc.

    P 1 Reply Last reply
    0
    • S solutionsville

      I would like to import my HOST file into a DB Table and the periodically run a script to verify if all the entries are the same, changed, deleted, etc.

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      solutionsville wrote:

      I would like to import my HOST file into a DB Table and the periodically run a script to verify if all the entries are the same, changed, deleted, etc.

      Good for you. Did you have a question that you wanted to ask?

      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

      S 1 Reply Last reply
      0
      • P pmarfleet

        solutionsville wrote:

        I would like to import my HOST file into a DB Table and the periodically run a script to verify if all the entries are the same, changed, deleted, etc.

        Good for you. Did you have a question that you wanted to ask?

        Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

        S Offline
        S Offline
        solutionsville
        wrote on last edited by
        #3

        Hello Paul. I guess I was kinda vauge... Mind is elsewhere. Funeral today. I want to write an SQL script that looks at the Windows HOSTS File and reads the IP / host name into two columns of a table. I next want to write a SQL Script that I can run as a job and validate the entries in the hosts file and if they have changed then modify the table data. I will also send a diff email to myself noting any changes(the email piece I have figured out). Thanks,

        P 1 Reply Last reply
        0
        • S solutionsville

          Hello Paul. I guess I was kinda vauge... Mind is elsewhere. Funeral today. I want to write an SQL script that looks at the Windows HOSTS File and reads the IP / host name into two columns of a table. I next want to write a SQL Script that I can run as a job and validate the entries in the hosts file and if they have changed then modify the table data. I will also send a diff email to myself noting any changes(the email piece I have figured out). Thanks,

          P Offline
          P Offline
          pmarfleet
          wrote on last edited by
          #4

          solutionsville wrote:

          I guess I was kinda vauge... Mind is elsewhere. Funeral today.

          Sorry to hear that.

          solutionsville wrote:

          I want to write an SQL script that looks at the Windows HOSTS File and reads the IP / host name into two columns of a table.

          You could write a small .NET program to read the contents of your HOSTS file into SQL Server. Use the System.IO.File.ReadAllLines() to load the contents of the file into an array. Then do some string manipulation to separate the IP address and host name for each entry. Then use ADO.NET to load the data into your database.

          solutionsville wrote:

          I next want to write a SQL Script that I can run as a job and validate the entries in the hosts file and if they have changed then modify the table data.

          You could achieve this by using SQL Server AGent to set up a job that runs periodically.

          solutionsville wrote:

          I will also send a diff email to myself noting any changes(the email piece I have figured out).

          You can write code in T-SQL to send mail. Have a look at this article[^]. You could invoke this from your SQL Server Agent job. Hope this helps. -- modified at 10:12 Tuesday 27th November, 2007 I forgot to include the link to the email article. I've put it in now.

          Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

          S 1 Reply Last reply
          0
          • P pmarfleet

            solutionsville wrote:

            I guess I was kinda vauge... Mind is elsewhere. Funeral today.

            Sorry to hear that.

            solutionsville wrote:

            I want to write an SQL script that looks at the Windows HOSTS File and reads the IP / host name into two columns of a table.

            You could write a small .NET program to read the contents of your HOSTS file into SQL Server. Use the System.IO.File.ReadAllLines() to load the contents of the file into an array. Then do some string manipulation to separate the IP address and host name for each entry. Then use ADO.NET to load the data into your database.

            solutionsville wrote:

            I next want to write a SQL Script that I can run as a job and validate the entries in the hosts file and if they have changed then modify the table data.

            You could achieve this by using SQL Server AGent to set up a job that runs periodically.

            solutionsville wrote:

            I will also send a diff email to myself noting any changes(the email piece I have figured out).

            You can write code in T-SQL to send mail. Have a look at this article[^]. You could invoke this from your SQL Server Agent job. Hope this helps. -- modified at 10:12 Tuesday 27th November, 2007 I forgot to include the link to the email article. I've put it in now.

            Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

            S Offline
            S Offline
            solutionsville
            wrote on last edited by
            #5

            Thanks Paul.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups