Insertion large number of Entities into SQL Server 2012 [duplicate] - sql-server

This question already has answers here:
How to do a Bulk Insert -- Linq to Entities
(4 answers)
Closed 9 years ago.
I'm on a project using Entity Framework 5 and SQL Server 2012. We have a need to insert a large number of rows at once (order of 100k entities). Basically we have a physics program that outputs a large amount of binary data that we then need to process and pull into a SQL 2012 DB. We're using EF5 as the ORM in other places in the application, but I'm doubtful of it's ability to handle this kind of insert in a timely fashion.
We're using a database-first approach where the POCOs generated from the model are passed around throughout the code-base as the primary DTOs.
I would also add that this insert involves multiple tables with foreign key relationships. Is this an issue with the various bulk insert methods out there.
Does anyone have any similar experience with this or a recommended approach?

I would look into the Bulk Insert that is available. Here is a link to some information on it: Bulk Insert. I would also look at SQL Compact Bulk, which was used Here .
Another link where a user submitted his code Stack Link.

Related

Script multiple CREATE TABLEs in SQL SSMS? [duplicate]

This question already has an answer here:
How do I generate scripts for all tables with single stroke in SQL Server 2000? [closed]
(1 answer)
Closed 3 years ago.
I have a database with many tables that have been periodically updated over the years (not by me). I would like to make CREATE TABLE scripts for all of the tables.
It appears Script table as... only works on a single table at a time. Is there a way to script out all of the tables in a database?
In SSMS, Right Click the Database, go to Tasks -> Generate Scripts.
In the second window, select Select specific database objects and tick Tables:
Choose where you want the results to to go, File, Clipboard or a new Query Window
Check all the settings are correct
Finish. Consume your file/clipboard.

Updating a table in SQL Server Management Studio [duplicate]

This question already has answers here:
How to auto daily execute queries SQL Server? [duplicate]
(3 answers)
Closed 3 years ago.
I am using SQL Server Management Studio v17.4
I have a view v_fetch_rates. I have created a table using the command
SELECT *
INTO RATES
FROM v_fetch_rates
My question is how do I update the table RATES on daily basis automatically? Is there a way to do it by existing view or do I need to write stored procedure for this?
I did some googling but it confused me even more.
I have never created a job before so any help/resources to refer would help a lot.
If the issue is that the view is slow (because of its definition or the amount of data it returns) and you want to materialized the data in order to improve performance you can simply create a indexed view.
The idea is simple - creating an index on the view forces the engine to materialized it. Of course, there are various limitations and requirements of having index view. You can find more information in the specified link.
If you just want to have the data in a table and populated in on daily basis, you can:
create simple stored procedure which is truncating the current table and populating the data again calling the view
create a complex routine, which will modify (insert/update/delete) data only if needed

Copy tables containing BLOB columns between Oracle Databases [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
On adhoc basis, we want to copy contents from 4 of our Oracle production tables to QA/UAT environments.
This is not a direct copy and we need to copy data based on some input criteria for filtering.
Earlier we were using Sybase database hence BCP utility worked with charm there. However, we have recently migrated to Oracle and need similar data copy requirement.
Based on the analyses till now, I have analyzed below options -
RMAN (Recovery Manager) - Cannot use as it does not allow us to copy selected tables or filtering on data.
SQLLDR (SQL Loader) – Cannot use this as we have BLOB columns and hence not sure how to create a CSV file for these BLOBS. Any suggesstions?
Oracle Data pump (Expdp/Imbdp) – Cannot use this as even though it allows copying selected tables it does not allow us to filter data using some query with joins (I know it allows to add query but it works only on single table). A workaround is to create temp tables with desired dataset and dmp them using EXPDP and IMPDP. Any suggesstions if I have missed anything in this approach?
Database Link – This is the best approach which seems possible in this use case. But needs to check if DBA will allow us to create links to/from PRD db.
SQL PLUS COPY - Cannot use this as it does not work with BLOB fields.
Can someone please advise on which should be the best approach w.r.t performance.
I would probably use a DATAPUMP format external table. So it would be something like
create table my_ext_tab
organization external
(
type oracle_datapump
default directory UNLOAD
location( 'my_ext_tab.dmp' )
)
as
<my query>
You can then copy the file across to your other database, create the external table, and then insert into your new table via an insert, something like:
insert /*+ APPEND */ into my_tab
select * from my_ext_tab
You can also use parallelism to read and write the files
Taking all your constraints into account, it looks like Database links is the best option. You can create views for your queries with joins and filters on the PROD environment and select from these views through the db links. That way, the filtering is done before the transfer over the network and not after, on the target side.

sql server 2008 r2 improve performance

I want to improve the performance of my SQL select query. I am using SQL Server 2008 R2.
I have a table Orders which has around 1.5 lacs of rows.
I have written a simple
select * from Orders
query which is taking around 8 seconds. Due to this the UI component is getting displayed in around 10-11 seconds.
Can anybody tell what could be issue? Is it due to no index is created on the table? If yes how we can improve the performance?
after edit---
I have posted query the above..which is a simple "select * from Orders".Orders is the table name.in which orderId is the primary key.i guess the DB will create a index for the primary key.I have also mentioned that there are not indexes created on any column in the table.the table as total 0.15 million records.i am running the query in the sql server management studio.even to my surprise the query is taking 8 seconds to show the results.
Thanks,
Hanmayya
I am not familiar with what unit "lacs" is, but you could look at the following to try to improve performance.
Try selecting only the fields that you need.
Remove any kind of formatting from the control. A friend of mine was encountering some issue with a Telerik grid when he was trying some non-standard configuration.
See if there is a problem with the server (is cpu/ram maxing out?)
Is there a problem with the network?
Do other servers have the same issue? You could compare configurations to see what the difference is.
Is the table fragmented? Not sure how much this would affect select performance though.
If you are not using any joins I do not think that putting an index would improve anything.
Just to update on the answer, I have implemented row index to fetch the data based on no of records to be displayed on page and the start index.

How to see what stored procs/functions/triggers rely on a column in a table? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Find a specific column entry in an unknown table in a database?
how to search Sql Server 2008 R2 stored procedures for a string?
Hello I'm trying to figure out a fairly complex SQL Server(2008 in 2000 compatibility) database. There are 3 columns in a table I'm particularly concerned with. I've searched the code of our application and it seems to make no direct usage of these 3 columns but I know somewhere in the database they are populated and used. So it must be in triggers, functions, and/or stored procedures.
What is the best way of figuring out where to look for the code that populates these 3 columns?
If you need to find database objects (e.g. tables, columns, triggers) by name - have a look at the FREE Red-Gate tool called SQL Search which does this - it searches your entire database for any kind of string(s).
It's a great must-have tool for any DBA or database developer - did I already mention it's absolutely FREE to use for any kind of use??

Resources