Is there any way use the values in a cell to query a SQL table and see if the value exists in the table? - sql

I have an Excel spreadsheet containing all of my company's Vendor Codes. When a new code is added to this spreadsheet, we then add it to a configuration table within our database which allows us to accept that vendor. Right now I'm going through my Excel Spreadsheet and reviewing each section of code to find out if it exists in the SQL Table.
Is there any way use the values in a cell to query my VendorConfig table and see if it exists?
Spreadsheet Columns: VendorID, VendorCode, Config

You could use the "get external data" command to bring a value into a cell to check against. Alternatively, here is a link to a web post that has a cool answer to this problem (NOTE: I haven't actually tried this code but, from a quick glance, it looks right): Add formula to excel to validate data

Related

Possibility of inserting manual columns between a Google Connected Sheet columns Powered by Big Query

I'm trying to insert a manual column in between a Big Query generated extract columns via Connected Sheet. Basically, I already have a Google Connected Sheet which is pulling from Big Query via SQL. Whenever I try to insert a manual column in between columns generated by the query though, it automatically moves the manual column to the very end on the right or to the very end on the left. I don't want this. I want to be able to insert a manual column in between a Big Query generated column in a Google Sheet.
Is it not possible to do this? Or is there another way to be able to pull something like this off? I can't find any videos or specific documentation on if it's possible.
See below answer to questions:
Is it not possible to do this?
As per this documentation:
Direct access to BigQuery datasets and tables is still controlled within BigQuery. A user with Sheets-only access can perform analysis in the sheet and use other Sheets features, but the user will not be able to perform the following actions:
Manually refresh the BigQuery data in the sheet.
Schedule a refresh of the data in the sheet.
Hence, you cannot manually create a column when you use Connected Sheets when accessing Bigquery Data. The main function of Connected sheets in this use case is to analyze and visualize data from Bigquery, and not to manipulate data.
Is there another way to be able to pull something like this off?
Option 1: extract from Sheets the data from Bigquery
Then you can see that the Insert function is enabled. You may insert another column in this extracted sheet:
Option 2: Download the sheet as an excel file and insert column in between once downloaded:

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

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.

Access - Create Select Statement via Excel Template

to export data from an Access 2010 Database I would like to use an Excel template as seen below.
In the first row I can define columns that are in the database. In the second line I can define exactly 1 filter which will be used in the "where" statement.
When pressing a button in Access, a query that is based on the defined columns and filters should be executed and the result will be exported to the Excel.
I am honest, I am not that skilled in VBA. What would be the best point to start from.
Your question is way too broad and as such it should not even be here, but let me give you some points to look at.
First you'll need to get your data from the Excel file. If you are not skilled with VBA, then the easiest way would be opening it through VBA using an Excel.Application object and Workbooks.Open method, and get your values from your Range.
Create an SQL Select statement from your values.
Do not use just a SELECT query, make it a SELECT INTO query (a "make table query" as Access likes to call it). That way your results will be inserted into a (new) table, making it easier to output.
Export your new table to Excel. There are several ways to do this, search for DoCmd.OutputTo or DoCmd.TransferSpreadsheet.

Using VBA to create a dynamic query after importing a SQL database table in MS Excel

This is a problem that has stumped me for a couple of days, and one I've been trying to work on. Unfortunately I very new to working on this stuff, and don't have a lot of resources trying to solve this problem, so if I am unclear or you have a question please post a comment about it.
The problem I am trying to tackle is this:
After getting external data from a SQL Server and having a table in a spreadsheet, say the is called Products, and has columns for productid (column A), productname (column B), supplierid (column C), and categoryname (column D). Is there a way to define a cell, say E1 where you use can use VBA to create a dynamic query. In this dynamic query you would enter some value of categoryname where it would query the table, and give you the results?
It is possible to perform a dynamic query without using any VBA.
Base your table on "From Microsoft Query" (under the "Get External Data" group on the Data tab). Build your query using the Query Wizard, selecting the table columns of interest. On the "Query Wizard - Filter Data" tab, where you would normally say a particular column must have a specific value, instead of the specific value, use just a question mark (for any and all columns that need to be used to filter). When you return your data to Excel, you will be prompted to "Enter Parameter Value" for each ? you used. Just click OK at this stage.
When the Excel "Import Data" dialog appears, click "Properties...". On the Definition tab click the button labelled "Parameters...". For each parameter, choose to "Get the value from the following cell" and to "Refresh automatically when cell value changes". Click the red arrow button (to select a cell) and click in the cell where each parameter will get its value from.
It's a good idea to have a label alongside each cell, and maybe special formatting for the data entry cell. The results table can be on the same worksheet as the parameter entry cells, when you enter a value in the entry cell, a new query will be run and the result will be displayed.
Here is a link that might help.
It goes into using VBA to filter.
I found it a while ago when I looked for something similar, hope it helps.