August 19, 2013 at 5:40 am
Hi,
I have a Excel sheet with usernames, I would like to loop through the usernames and see what info exists in the database, based on each username. Where do I start?
Regards
August 19, 2013 at 6:57 am
hristo1977 (8/19/2013)
Hi,I have a Excel sheet with usernames, I would like to loop through the usernames and see what info exists in the database, based on each username. Where do I start?
Regards
Unfortunately, you haven't specified what your tables look like in the database but here is a stab in the dark.
You might be better off importing the usernames into a table in the database with ssis or some such and then just do a join with the username value to the tables you require.
August 19, 2013 at 7:08 am
You havn't provide much information but I am suggesting you a solution that you can follow to accomplish your task:
you can first import all the username from excel sheet into a temporary sql user table using SSIS or BULK INSERT...
after storing data in user table you can write a cursor and extracts info that you required..
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
August 19, 2013 at 7:10 am
I would advise against trying to use data while it's in Excel. Import the list you want to process (I like BULK INSERT, but SSIS or other methods will work as well) into a SQL Server table and work with it from there.
Once you get it there, you'll be in business and will be able to use the list to query against.
August 20, 2013 at 10:28 am
If this does not need to be automated, I have assembled simple queries in text by creating an Excel formula like this in an extra column:
=CONCATENATE("Select * From Logins Where user_name = '",B2,"'")
Replicate the formula to all the rows you want to look at, then copy and paste the text from that column into SSMS
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply