Update microsoft excel single cell to database - sql-server

i already pull data from sql server, with 2 blank column.
my requirement is :
when user enter value into a single cell in these 2 columns, it will update database base on primary key (specific column's value in same row).
would it able to do like this?
Thanks a lot!

If updating cell by cell is really a requirement, I suggest you create a procedure in SQL Server that accepts the cell value as a parameter. However, it would probably be better to wait until all relevant cells have been completed and ask the user to click a button to update. You will need to do a good deal of checking to ensure that data is not sent twice. It is also possible to work from the SQL server end.

Related

Linked SQL Server's table shows all fields as #Deleted, but when converted to local, all information is there

My company has a really old Access 2003 .ADP front-end connected to an on-premise SQL Server. I was trying to update the front-end to MS Access 2016, which is what we're transitioning to, but when linking the tables I get all the fields in this specific table as #Deleted. I've looked around and tried to change some of the settings, but I'm really not that into SQL Server to know what I'm doing, hence asking for help.
When converting the table to local, all the info is correctly displayed, so it begs the question. Also, skipping to the last record will reveal the info on that record, or sorting/filtering reveals some of the records, but most of the table stays "#Deleted"...
Since I know you're going to ask: Yes, I need to edit the records.. Although the snapshot method would work for people trying to view the info, some of us need to edit it.
I'm hoping someone can shed some light on this,
Thanks in advance, Rafael.
There are 3 common reasons for this:
You have bit fields in SQL server, but they are null. They should be assigned a default of 0.
The table in question does NOT have a PK (primary key).
Last but not least you need (want) to add a timestamp column. Keep in mind that this is really what we call a “row version” column (so it not a date/time column, but a timestamp column). Adding this column will help access determine if a record been changed, and this is especially the case for any table/form in Access that allows editing of “real” number data types (single, double). If access does not find a timestamp column, then it reverts to a column by column comparison to determine table changes, and due to how computers handle “real” numbers (with rounding), then such comparisons often fail.
So, check for the above 3 issues. You likely should re-run the linked table manager have making any changes.

How to copy a record from Excel and paste into SSMS V 17 to update existing record

Folks,
I am a novice, really a business user (not techie), in SSMS v 17. I used to update a MS Sql Server database in Azure using Excel add-in (Devart), but then Active Directory Multifactor Authentication was introduced at the organization and I cannot use Devart any longer. I am forced to use SSMS v 17.5 to make updates to the database through that grid.
I found a few old (circa 2008) solutions for creating new records using Copy Paste from Excel. Similarly, is there a way to "update" an existing record in the database by copying a row from Excel and pasting into that "grid"? I have some 60+ and 70+ year olds in the team, and would really like a simple solution that could cater to all ages. Right now, we scroll right and left, furiously, inside the grid trying to ensure that we are updating the correct row of record.
I sincerely appreciate your guidance in this regard.
One way you can do this, though I do not recommend is:
1) Right click the table you want to edit, select edit top 200 rows.
2) Right click the screen that pops up, go to Pane -> SQL
3) Change this to show the records you want to edit and column in the order you want and it should work.
Big problem here and why I wouldn't suggest this, is if anything is wrong you could really mess stuff up, also it will lock the rows you are looking at which could affect other things. A better "work around" would be to create an excel function and use a template. Example : ="Update "&B1&" Set "&C1&" = '"&D1&"' where ID = "&A1 ... Essecially letting Excel write the dynamic sql. In this case B1 would be the table to update, Cell C1 would be the column to update, D1 would be the new value and A1 would be the unique identifier. I do this often when someone sends me a list of 1000 items and I need to put them in a temp table or something.

Query SQL database from Excel

I'm attempting to create a MS Query to return data from a SQL database based on a value from a cell in Excel. I have actually successful accomplished this, but only for 1 row. I cant figure out how to get it to copy-down to other rows.
I've created a connection as follows:
Notice that the SQL statement includes a parameter. The parameter is set to point to a specific cell:
I guess this makes sense as I'm only looking to return 1 value per row:The problem is that I have multiple lines to return values for. How do I return a value per row for multiple rows?
I've tried changing the cell reference in the Parameters dialog box, but this does not work as the Excel Table is designed to grow dynamically.
Excel data connections works in a way that every connection has only one SQL Query. So in order to do what you'r looking for, you will need to have many connections, and that's not the "best practice".
However, there are two ways you can solve this situation:
1. Make a single connection with all of the data and create a pivot table based on it. Then use VLOOKUP/INDEX to gather the data to your requested cells.
2. If the data is too big, you can use VBA code to create a smaller Query based on the cells you mentioned and then continue as described on the first option.
Good luck.

Preventing 'The data has been changed' error when using Me.Refresh with ODBC linked tables

In my Access application's data entry form I'm using Me.Refresh to show the user the new value of a calculated field based on data they entered in a non-calculated field. The purpose is to give them the deadline for doing a job next.
This Access app is using linked SQL Server 2012 tables via ODBC. The calculated field is in the underlying SQL Server table, not part of the Access Record Source query because I want to store the calculated value in the actual data, not just as an interface element.
The calculation is very simple:
nextjob = jobdate + 79
So I have the field for jobdate set to run Me.Refresh after update. All well and good.
The problem is that if the user updates jobdate, triggers the refresh by moving to another field, then returns to the jobdate field and changes the date they entered Access throws a "The data has been changed by another user" error.
I tested the method using native Access tables and the problem does not occur. However the data needs to stay on the server, so moving to native tables is not a solution for me.
There are several possible solutions.
1- If it's always jobdate + 79, don't store it at all, use a view that has the calculated field.
2- Use Me.Requery instead of Me.Refresh. If the form shows multiple records, you must navigate back to the current record, you can use Me.Bookmark for that.
3- Move the calculation into the Access frontend - make nextjob an ordinary column and set it in the form, so it isn't another user (the server) that updates the data.

Manual Entered Data On Excel Ms Query Is Misaligned After Refresh

I have done an MS SQL Query in excel.
I have added extra colums in the excel sheet which I want to enter manual
data in.
When I refresh the data, these manually inputted columns become misaligned
to the imported data they refer to.
Is there any around this happening.
I have tried to link the imported data sheet to a manual data sheet via
vlookup but this isn't working as there are no unique fields to link together.
Please help!
Thanks
Excel version is 2010.
MS SQL version is 2005.
There is no unique data.
Because excel firstly looks like this.
when we entered a new order in to database Excel looks like this
Try this: in the External Data Range Properties, select "Insert entire rows for new data".
Not sure, but worth a try. And keep us updated of the result !
edit: And make sure you provide a consistent sort order.
There is no relationship to the spreadsheets external data and the columns you are entering. When refreshing typically the data is cleared and updated though there are other options in the external data refresh menu you could play with. You could play around with the External data options in the menu to see if changing the settings on what happens with the new data would help.
If you want your manually entered data to link to the data in the embedded dataset, you have to establish the lookup with a vlookup or some formula to find the rows info and show it.
Basically you are thinking the SQL data on the spreadsheet is static, but it isn't unless you never refresh it or disconnect it from the database
note that Marcel Beug has given a full solution to this problem in a more recent post in this forum # Inserting text manually in a custom column and should be visible on refresh of the report
he has even taken the time to record an example in a video # https://www.youtube.com/watch?v=duNYHfvP_8U&feature=youtu.be

Resources