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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Check for information already contained in a table

Author  Topic 

krista80
Starting Member

29 Posts

Posted - 2011-01-28 : 12:10:00
Hi! My new problem is what query can I write that will allow me to check if information taken from a csv file (the account number type information) is already in the database table. If it is, I want those numbers not to be saved. If the numbers aren't the same I want those saved to another table. Any help would be greatly appreciated.

krista80
Starting Member

29 Posts

Posted - 2011-01-28 : 12:24:26
Is there WHERE syntax that would work in this situation? Something that will split up the matched numbers (do nothing with them) and save the unmatched numbers to another table?
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-01-28 : 12:31:40
What are you doing with the csv file?
Importing it into a staging table so you can run queries on it before moving tocan do things in the dataflow production.
Importing using ssis so you can do things in the dataflow?
Something else

Simplest would be the staging table option.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-01-28 : 12:54:22
In your previous post you were given several options to find out which ones aren't there (LEFT JOIN, NOT EXISTS, EXCEPT), you should look at Books On Line to see what these things are so you can then use them to solve your current problem (INNER JOIN, EXISTS, INTERSECT). Write the code you come up with and we'll help you from there.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

krista80
Starting Member

29 Posts

Posted - 2011-01-28 : 13:00:31
Ok. Thanks.
Go to Top of Page

krista80
Starting Member

29 Posts

Posted - 2011-01-28 : 14:31:35
Got it working! Thanks for the tips!
Go to Top of Page
   

- Advertisement -