Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Server 2005 Query

Author  Topic 

dayjaa3
Starting Member

4 Posts

Posted - 2012-09-07 : 16:27:48
I receive a flat file which I am importing with SSIS. The problem is the file does not contain a needed field(ssn). I have to query another table to find the ssn information. As an example, I receive a file with about 250 records. These records have firstname, lastname, and dob. I need to use this information to query the other table to find the SSN and add that to a new table. So for each record I must find the corresponding SSN located in the other table. Does anyone have a good idea about how to approach this?

Thanks in advance.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-09-07 : 16:29:12
Import the data into a staging table and then join to the table that has the SSN. Using that query you can then import into your actual table.

So the staging table would match the layout of the file.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

dayjaa3
Starting Member

4 Posts

Posted - 2012-09-07 : 16:37:03
How would the query look for this? Select e.ssn, t.dob,tfirstname, tlastname from Eligibility e
JOIN Test t on e.id = t.id. How would I use each dob, firstname, lastname as parameters?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-09-07 : 16:57:33
Your file doesn't include the id, right? So I guess you have to tell us how you would link them together.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

dayjaa3
Starting Member

4 Posts

Posted - 2012-09-10 : 08:38:04
I need to use the FirstName, LastName and Dob from the flat file to find the ssn. So whereever the 3 criteria match a record I would pull that ssn
Go to Top of Page

dayjaa3
Starting Member

4 Posts

Posted - 2012-09-10 : 08:51:48
I think the issue that I'm having is how to use multiple sets of parameters. For example in C# i would have an array and say foreach "set of firstname, lastname and dob" select the corresponding ssn and then i would put the results in an array. I'm not understanding how to say this in tsql.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-09-10 : 12:39:24
You would join on all 3 columns then.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -