sql statement

I am checking a csv file that will give me about 300 entries that I need to match up in an sql database.  Is there a way to put this in one statement?  Or better to run 300 statements in a loop?  If one statement works, how do I write that?

I would have 300 serial numbers and need to make sure a column on each one of these entries had a "Y" in it.  Most of these will have a "Y" in it.  If the serial number does not exist I need to create a new row for this.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

do you need to check the csv file or the database?
If itis the csv file, give canwe have a coupleof lines' sample posted?
If it is a one time thing, I would not bother very much about writing the best code for this purpose. Just use code that you are best familiar with and get it done.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chadmanvbAuthor Commented:
This will run every every hour or as needed to keep the SQL database updated with this csv file.

So far I have just have a loop to read the csv file and get all the lines I need to find, but I'm not sure how to make the update to SQL.  This is what I have so far.

 '*******************READ CSV***********************************
        Dim workStationsRead As New StreamReader(workstationstext)
        Dim workStationsList As String = workStationsRead.ReadToEnd()

        'find available workstations
        Dim workStationListSplit() As String = Regex.Split(workStationsList, "\r\n")

        For Each FileLine As String In workStationListSplit

            If FileLine.StartsWith(";") Then

                'skip all comment lines
            ElseIf FileLine.Trim = "" Then
                'skip blank lines

                    Dim cols
                    cols = Split(FileLine, ",")
                    Dim WorkstationExclude As String = (cols(12)) 'this determines if the workstation will be checked.
                    If WorkstationExclude = "Y" Or WorkstationExclude = "y" Then
                        'these should all have remote access enabled.  Check the database to make sure

'***********need help here building the large sql statement****************
'***or I could just use a single sql statement here*******************

                        'skip other workstations
                    End If
                Catch ex As Exception
                End Try

            End If


I would insert the CSV to a temp table on the server and then do table comparisons in a stored procedure which would be way faster


chadmanvbAuthor Commented:
I just ran individual queries for each iteration of the loop.  It took less than 1 second.  Code, I'm sure that would be faster, but this seemed to be faster than I thought
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.