SQL Server Tables Relationship in Access - sql-server

I connected a sql server through ODBC and lined sql tables. I manually created my relationships in my database but, when I do that, my other tables are not editable. My drop downs I created won't allow me to select it or my text box doesn't let me type in it.
How am I supposed to create a relationship so I can use Access as a front-end to enter in data into the database?

If you are linking to tables that exist already in SQL Server, then you don't need to worry about creating relationships in Access.
If you want to edit data in the SQL Server tables, make sure that you have a primary key on each table, and if possible a field with at "timestamp" data type.

Related

Insert data into SQL tables manually using the related columns in Management Studio

I am trying to insert data into some related table in SQL Server 2008R2 and I am trying to figure out whether there is an easier way to insert data manually (visually) using the related columns and not the IDs. If you check the two snapshots of the tables and table WFUserGroup basically I am trying to see if I can have a bound query (like in MS ACCESS) where I can see the Name column instead of the ID and the name of the Group instead of the group_id
I know that with a TRANSACTION block and INSERT INTO statements I can create a new user in WFUser table and then relate it to a group in the WFUserGroup table, but I am telling myself there should be an easier way. Anyone knows a workaround?
Tables:
Using Edit Top 200 Rows Feature:
You could use a flat file with data in a .csv or excel and use the Import feature in SQL server.
how to navigate, right click on the database and tasks--> Import then the wizard to select the necessary file and tables.
I do see that there are primary key and foreign keys so you have to make sure that its considered in your files you are going to import.

How to handle foreign key while importing data from Excel into SQL Server

I have raw data in an Excel sheet. I develop a database in SQL Server with foreign key constraints, now I want to import data from my Excel sheet into my SQL Server database (with multiple tables with foreign key constraints).
Please guide me how can I handle foreign key while importing data into my database? I am new to SQL Server database, any tutorial link will be helpful.
Thanks in advance.
You can't rely on a data which is being exported using Excel. I suggest you following approach.
Dump the data into a intermediate table without any constraint.
Validate the data before moving to the main table. For this you can use where exists clause to check if the data is present in the foreign key table or not.
Records which are failed in validation, you can report them back to the user.
If you can use SQL Server Integration Services, a lookup transformation would do the work for you. This is an example:
http://www.learnmsbitutorials.net/ssis-lookup-transformation-example.php
We also offer an Excel Add-In to import and update data in SQL Server from Excel.
It has the possibility to create drop-down lists in Excel for foreign key relations. The user will then select a text item in Excel (fetched from the foreign key table) and the corresponding key value will be inserted into the table in SQL Server.
More details are available here: https://sqlspreads.com

Column check SQL Server

I have a lot of views and tables connected in Microsoft SQL Server. I want to check all the useless columns I have in the native tables. Is there a way to perform an automatic check if a column in a table is used or not in other tables?
Create a database diagram in SQL Server Management Studio. From here you can analyze how the tables/columns are related or not. Info here
Do a business model analysis and see which values are used, which are deprecated and start from there.
If you do any changes on the database, these changes have to be projected in any code connecting to that database.
Do not remove columns in tables just by looking at a database diagram. You would destroy any object-relational mapper.

Database export Access to SQL server: indexes and keys?

I have exported a number of Microsoft Access database tables to a SQL Server 2012 using ODBC. Subsequently, I have linked to the data sources by creating linked tables.
Now here's the issue.
When I verify the tables in SQL Server itself, I notice only the database tables, columns and their respective datatypes are present. There are no key or indexes to be found. Still, in my Access database they were all defined. Also, I noticed that Access requests to choose a field(s) that uniquele identify each record to ensure data integrity and to update records. These then become the Primary Keys I understand, but why not use the PK that are already present?
What would be the easiest and most efficient way to also migrate the other field properties like indexes, keys, constraints? As otherwise, I would need to define all those manually and this would be very time-intensive.
Many thanks for your help!
As you have discovered, the keys and indexes and not copied over if you simply export an Access table to SQL Server using External Data > Export > More > ODBC Database:
However, the indexes, keys, and relationships are copied over to SQL Server if you use the "Upsizing Wizard", which is invoked via Database Tools > Move Data > SQL Server:
Note: The "Upsizing Wizard" was removed from Access 2013, so users of Access 2013 (and newer) will need to use the "SQL Server Migration Assistant for Access" instead. For more information look here.

Entity Framework 4, can I have 2 tables from different db servers in the same model?

With Entity Framework 4, can I have 2 tables from different db servers in the same model?
I have table X from SQL Server A and Table Y from Server B.
Is it possible to have different connection string per table under one model or do I need to have different dbml files?
No you can't. Whole EDMX file have single connection string. Moreover EF don't allow fully qualified names of tables. Defining table TableA a from linked server MyServer.MyDatabase.dbo will probably in SQL query result in something like [MyServer.MyDatabase.dbo].[TableA] and it will throw exception.
If you want support tables from two servers in a single model, try to link your second server to the first server and create a view for each table from the second server in your current database on the first server.
IIRC you might be able to fully qualify the table name in the DBML if they are linked servers. I don't have anything to test on, I know you can do it in Linq2Sql on Different databases on the same server.

Resources