Importing from Excel to Access Key Violations and Identical Formatting - database

first of all I'd like to say thanks. Although I'm still pretty new to it, I've learned nearly everything I know about Access from this site. This is one of the most helpful forums I've ever used.
I'm having a problem importing data to my Access database from my Excel spreadsheet. I keep getting a key violation saying a particular field (column) in each row was deleted. I have two tables on my database and two coinciding sheets on my spreadsheet. Both sheets have this particular field. Sheet1 is importing fine, but Access won't import anything from that field on sheet2. All the properties for this field are the same and the data preview during import verifies that the data is coming from both sheets in the same form.
From this source: http://www.utteraccess.com/forum/Key-Violations-Append-Q-t1918322.html
Key violations occur for 3 reasons:
1) when the record you are attempting to add to the table adds a duplicate value where the field does not allow duplicates
- This can't be it because every value in the field is unique and the field is set to allow duplicate values. And my primary key is the Access-generated replication ID.
2) when the record has a field value that is null and the field in the table is a required field
- the field on sheet1 is adding null values, and not all the values on sheet2 that won't add are null value. and the fields are set to accept null values.
3) Where a value is added that is not in a related table and referential integrity is set on the link between the tables
- I have no relationships set in my database yet.
I have done this import successfully before a few times and I've only made minor changes since then, the majority of which on the Excel file. Thanks for any replies, and thanks very much for any explanations.

I have found a good alternative solution to troubleshooting this problem. Instead of directly importing the data to the table I constructed in Access to match my Excel sheet, I imported the sheet by having Access create a new table. This table is automatically formatted to match the excel file that I am importing from.

Related

AzureSynapse pipeline how to add guid to raw data

I am new to AzureSynapse and am technically a Data Scientist whos doing a Data Engineering task. Please help!
I have some xlsx files containing raw data that I need to import into an SQL database table. The issue is that the raw data does not have a uniqueidentifer column and I need to add one before inserting the data into my SQL database.
I have been able to successfully add all the rows to the table by adding a new column on the Copy Data command and setting it to be #guid(). However, this sets the guid of every row to the same value (not unique for each row).
GUID mapping:
DB Result:
If I do not add this mapping, the pipeline throws an error stating that it cannot import a NULL Id into the column Id. Which makes sense as this column does not accept NULL values.
Is there a way to have AzureSynapse analystics read in a raw xlsx file and then import it into my DB with a unique identifier for each row? If so, how can I accomplish this?
Many many thanks for any support.
Giving dynamic content to a column in this way would generate the same value for entire column.
Instead, you can generate a new guid for each row using a for each activity.
You can retrieve the data from your source excel file using a lookup activity (my source only has name column). Give the output array of lookup activity to for each activity.
#activity('Lookup1').output.value
Inside for each, since you already have a linked service, create a script activity. In this script activity, you can create a query with dynamic content to insert values into the destination table. The following is the query I built using dynamic content.
insert into demo values ('#{guid()}','#{item().name}')
This allows you to iterate through source rows, insert each row individually while generating new guid every time
You can follow the above procedure to build a query to insert each row with unique identifier value. The following is an image where I used copy data to insert first 2 rows (same as yours) and inserted the next 2 rows using the above procedure.
NOTE: I have taken Azure SQL database for demo, but that does not affect the procedure.

Problem creating unique values to create a relationship in Power BI

I'm trying to join two tables together through a relationship but am having trouble.
My data is of a Building (type text) , which has Floors and Rooms which can both be a mix of text and number names (type any).
In order to create a relationship based on the Room column, I attempted to create a unqiue values table by referencing the Room_Mapping table, removing all by columns apart from Room, and removing duplicates.
However, when I try to join the two tables together based on the Room column, I keep getting the following message.
I have a feeling that this error is coming because the data type is a mix of text and numbers that it is getting confused because when I go to look at the data in Data view, I can see that the data for Phase and Room fields have been converted to Text type.
Please can any one help? I have attached a link to the workbook and data in the link below.
Room_Mapping Data and PBI Workbook
Many thanks in advance.
The Room1/ROOM1 Room2/ROOM2 are the cause of your problem. You can solve this by adding one extra step to your Query.
You do this by right-clicking the Room column and choose Transform > Capitalize Each Word.
The problem is that you have 4 very similar cells:
Room1
ROOM1
Room2
ROOM2
in original table and them are duplicated yet in the Room_UniqueValues Table.
Try to replace this values like this in the Room_UniqueValues Table:
And null by "null" in the original table, for example:
Tell me if this are ok please!

How do I automatically populate a new table in MS-Access with info from an existing table?

I am very new to MS Access and I am struggling with some things that seem like they should be the most basic. I have imported a table of data from Excel and have defined the data types for the fields. I have no problem there, but now I want to make a new table that has as a primary key one of the fields from the imported table. It looks like I can manually create this table, set the relationship, and then go back and type in each record associated with the new primary key, but this seems completely ridiculous. Surely there must be a way to automatically create one record for each unique instance in the matching field from the original table. Yet, I've scrolled through hundreds of pages of Access tutorials and Googled the question and found no satisfactory guidance.
Do I completely misunderstand what Access is all about? How do I create a new table with entries from a field on an existing table? What am I missing?
You don't specify which version of Access you are using, the suggestions listed below apply to 2010, but should be similar is other versions.
You can create new tables from existing tables using either a 'Make Table' option after selecting 'Create' -> 'Query Design', or you can manually create your table first, then use an 'Append' query.
Without knowing the design of your table it's hard to get more descriptive.
Are you populating your new table's primary key ahead of time, or relying on Auto Number to do it (preferred method)?

Trying to find name of TFS DB Table containing custom field data

I have a quick question, what is the name of the TFS 2010 database table that contains values for any custom fields.
I did a query against the TFS_Warehouse DB and the dbo.DimWorkItem table. However, I cannot find any of my custom work item fields under this table.
Can someone point me to the correct TFS 2010 table containing the custom field data? When I worked with Quality Center, the tables were pretty well defined so it was easy to do backend DB queries. TFS does not seem that intuitive.
Thanks
you have to add "reportable" to field definition.
Example - FIELD name="Scope" refname="xxx.Scope" type="String" reportable="dimension"
Wait few minutes and you'll see field in warehouse DB
look,
you need to go to your collection database, and to check a table called something like Fields.
there, you will find the new field properties and the type as well.
you can change the type to string and to be reportable.
go to the table of the WORKITEMLATEST, and check the field- you can see the name of the field like what was mentioned in the FIELDS table,.
open your work item normally, edit that field information, click save...
you can see your data updated in the WORKITEMLATEST table
BUT...
the problem is the STRING type is limited... I tried to add more text.. it keep telling me that number of character is over limit !

Is using multiple tables an advisable solution to dealing with user defined fields?

I am looking at a problem which would involve users uploading lists of records with various field structures into an application. The 2nd part of this would be to also allow the users to specify fields to capture information.
This is a step beyond anything ive done up to this point where i would have designed a static RDMS structure myself. In some respects all records will be treated the same so there will be some common fields required for each. Almost all queries will be run on these common fields.
My first thought would be to dynamically generate a new table for each import and another for each data capture field spec.Then have a master table with a guid for every record in the application along with the common fields and then fields that specify the name of the table the data was imported to and name of table with the data capture fields.
Further information (metadata?) about the fields in the dynamically generated tables could be stored in xml or in a 'property' table.
This would mean as users log into the application i would be dynamically choosing which table of data to presented to the user, and there would be a large number of tables in the database if it was say not only multiuser but then multitennant.
My question is are there other methods to solving this kind of varaible field issue, im i going down an unadvised path here?
I believe that EAV would require me to have a table defining the fields for each import / data capture spec and then another table with the import - field - values data and that seems impracticle.
I hate storing XML in the database, but this is a perfect example of when it makes sense. Store the user imports in XML initially. As your data schema matures, you can later decide which tables to persist for your larger clients. When the users pick which fields they want to query, that's when you come back and build a solid schema.
What kind is each field? Could the type of field be different for each record?
I am working on a program now that does this sorta and the way we handle it is basically a record table which points to a recordfield table. the recordfield table contains all of the fields along with the field name of the actual field in the database(the column name). We then have a recorddata table which is where all the data goes for each record. We also store a record_id telling it which record it is holding.
This is how we do it where if each column for the record is the same type, then we don't need to add new columns to the table, and if it has more fields or fields of a different type, then we add fields as appropriate to the data table.
I think this is what you are talking about.. correct me if I'm wrong.
I think that one additional table for each type of user defined field for the table that the user can add the fields to is a good way to go.
Say you load your records into user_records(id), that table would have an id column which is a foreign key in the user defined fields tables.
user defined string fields would go in user_records_string(id, name), where id is a foreign key to user_records(id), and name is a string, or a foreign key to a list of user defined string fields.
Searching on them requires joining them in to the base table, probably with a sub-select to filter down to one field based on the user meta-data, so that the right field can be added to the query.
To simulate the user creating multiple tables, you can have a foreign key in the user_records table that points at a table list, and filter on that when querying for a single table.
This would allow your schema to be static while allowing the user to arbitrarily add fields and tables.

Resources