Use an Excel Cell as a Input Data for filtration to a SQL Server View - sql

I have a basic view in SQL Server which includes these columns,
"Lot Number" , "Time" , "Code" , "Name" , "Barcode"
Now I need a Excel file which will have EXACTLY the same columns and the same information.
What I want to do is, in the Excel file when I write a number to "lot number" section, the other columns will fill itself automatically based on the SQL Server view. Basically I'll be using "lot number" cell as a filtering.
The problem is that, this is a ERP system database. I don't want to extract all the information to Excel file, there are millions of rows. Excel should be blank, I will write the lot number first, then refresh the Excel file and the other columns should be filled in automatically. I will refresh the Excel every 1 min automatically and only 1 row is enough.
So I need a procedure in SQL Server (or in Excel) to receive data from the Excel cell, then use that data for filtration in a view and return the data to the same Excel.
Now I'll show you my set up, waiting for your ideas.
This Screen shot is the SQL Server view in "192.168.2.100" server. My SQL knowledge is pretty basic, I create views by schematics not by codes.
And this is the Excel file that I connected. As you can see I can extract all the data. (I deleted code-name-barcode cells. they are not empty, because these are official information).
Obviously this is not I want. When I put the lot number I want other data to came automatically. At least when I refresh the Excel file. Excel is in "192.168.2.116\\barkod\\Tyvek_Mdr.xls" . It is in a shared network.
So I have been researching but still I couldn't find the best solution. If someone can help me I'd really appreciate it.

Related

Search SQL table using excel to return only matching values

I have a large table in my SQL database with a few million rows so I can't just load it into excel. I'd like to setup a data connection in Excel to the database which I can do now, but I want to be able to open the excel sheet, type my search parameter in a cell and then have the matching rows returned from the database table into the excel sheet.
Does anyone know if that's possible? I can't find a way to do it without manually adjusting the search term in the connection properties because I don't know how to pass along what I typed in the cell to be the search term.
Ok figured it out, microsoft has a great guide for it here:
https://support.microsoft.com/en-us/office/create-a-parameter-query-in-microsoft-query-c67d9af7-c8a0-4bf7-937c-087cb25f7ad3

Filter certain SQL data formatted in one column into a new column

Before I begin I found this to be most relevant with the research I have done.
How to split the data from one column into separate columns using the contents of another column in SQL
Attached are pictures of my progress so far. How can I display this information such as it is shown in the excel file without disrupting the GROUP BY filter in my Query?
It's a Fishbowl Database, newest version. I am running the queries through Flamerobin which you see in the picture. Trying to organize the query to display correctly so I can format it into 'iReports' and export it into an excel spreadsheet like the one shown. Maybe there is some part of this that would better be done in excel?
Notice the numbers for Qty are different, that's ok right now.
My reputation is too low to post pictures I am sorry. Here are the two JPGs in my Dropbox. I really appreciate the help.
https://www.dropbox.com/sh/r2rw5r2awsyvzs9/AAAXXg27CMPOYtZFqPX3Dx6la?dl=0

In SQL how do I update a table with a similar table?

In my current Database I have a table whose data is manually entered or comes in an excel sheet every week. Before we had the "manual entry option", the table would be dropped and replaced by the excel version.
Now because there is data that only exists in the original table this can not be done.
I'm trying to find a way to update the original table with changes and additions from the (excel) table while preserving all rows not in the new sheet.
I've been attempting to simply use an insert query and an update query /but/ I can't find a way to detect changes in a record.
Any suggestions? I can provide the current sql if you'd find that helpful.
Based on what I have read so far, I think I can offer some suggestions:
It appears you have control of the MS Access. I would suggest adding a field to your data table called "source". Modify your form in the access database to store something like "m" for manual entry in the source field. When you import the excel, store an "e" for excel in the field.
You would need to do a one time scrub of the data to mark existing records as manual entries or excel entries. There are a couple of ways you can do it through automation/queries that I can explain in detail if you want.
Once past these steps, your excel process is fairly simple. You can delete all records with source = "e" and then do a full excel import. Manual records would remain unchanged.
This concept will allow you to add new sources and codes and allow you to handle each differently if needed. You just need to spend some time cleaning up your old data. I think you will find it worth it in the end.
Good Luck.

sorting BIG excel data

Right so, I have been given a LOT of "consumer data" to sort, 3 excel files, each containing multiple worksheets, up to 7 worksheets, each up to 1M rows (max worksheet size in excel 2013 is just over 1 rows)
I need to pull out of these all people within a region, so have a list of post codes in this region (say 30 post code areas)
How can I achieve this most easily?
If the data was in SQL server, i'd just write a long SQL statement selecting all where postcode LIKE 'B75'% OR 'B74'% etc etc.
But in excel I can only run a "filer" on one worksheet at a time... (I think)
Is it going to be easiest to throw all the data into sql server, or have I overlooked a method?
First solution is to let Excel do the task of sorting for you. You need to add filters to columns and select Sorting options.
Other solution is to Export Data to SQL Table(s). To do this, Open SQL Management Studio, Right Click on Database to which you want to export data to and Select "From Excel File". Do this for each Excel file you have. After importing all data in Database, sort Data using SQL Query.
Second Solution is reliable but first solution is faster. You need to decide which one you should select.

Querying Data Using Existing Spreadsheet

I have a spreadsheet that lists customers, their supervisor information, and special feature codes that are listed on their account at the time the report was created.
I need to add a column to this sheet that lists the last active date that these codes were populated on the customer account.
I'm aware of how pull the info when the features were last active. However, I need to base my query based on these specific accounts and codes. What family of SQL Clauses can I use to read these preexisting values and return a corresponding date value?
Your question is a bit ambiguous. How are you populating the spreadsheet? Are you using an ETL application like SSIS or creating an Excel output from a SQL query in your database?
If you are populating an existing Excel spreadsheet, then create in that spreadsheet a new column called "Last Active Date" in preparation for populating it from the source.
If you are pulling the data from a database source, then there may be an associated history or archive table where you can find the pre-existing codes along with their corresponding dates. Here your database administrator and/or developer will be better equiped to assist you in navigating the database architecture. If the codes are no longer available in the source database, then no special SQL CLAUSE will assist. You cannot retrieve that which does not exist.