Query Perfornance for querying XML Column in SQL Server - sql-server

We are thinking of providing some advanced querying capabilities to application.
The application is in Retail domain and storing the core Entities in XML Column for all the main entities(Invoice, Order, Product etc) in the application.
The database is already > 10GB in size.
Will it be good choice to use query against XML Column in SQL Server, what are alternative to these as the core entity data is always stored as XML instead of RDBMS tables.

Related

How can I query the data stored in Azure Table Storage using T-SQL

We will be writing several hundred thousand rows of data to an Azure Table Storage Container. The data is made up of 4 columns, 1 of which contains a lot of JSON text which is the main column I'm interested in.
How can I query this data using T-SQL? I was hoping to join this with some existing data we currently hold in a table on SQL Server too.
I am new to Azure Storage and am trying to work out if I have to query the data directly or can I get it to my SQL Server to perform some more detailed querying? It is being stored on Azure to start with due to ease and cost.
Azure Table storage does not support SQL: https://db-engines.com/en/system/Microsoft+Azure+Table+Storage%3BMicrosoft+SQL+Server
If your store your data on blob storage you might be able to use Polybase to query data from your SQL Server https://learn.microsoft.com/en-us/sql/relational-databases/polybase/polybase-guide?view=sql-server-ver15

Table Partitions with Entity Framework Core

I have a large database that will use partitioned column-store tables in a redesign. Is it possible to specify the partition in the generated sql with Entity Framework Core 2.2?
This is for an Azure SQL hyperscale database with a table which currently contains about 3 billion rows. When using stored procedures to execute the requests performance is excellent but if the partition range is not specified in the query performance is less that optimal. I am hoping to move away from the inline sql we are currently using in the application layer and move to entity framework core. Being able to specify the partition for the tenant is our only blocker at the moment.
This is an example where clause in the stored proceduure
Select #Range = $PARTITION.TenantRange(#InputTenantId)
Select ..... FROM xxx where $PARTITION.TenantRange(TenantId) = #range
The above query would provide excellent performance but I am hoping I can make the same specification of the partition using entity framework.

ASP.net MVC - get data from SQL Server without knowing the data-structure

I would like to know how I can get data from SQL Server tables into my ASP.net MVC application without knowing the data-structure in advance.
Example:
a user uploads a .csv file into the application with an unknown data structure (can be 3 fields can be 50 fields with varying data types)
the .csv file gets stored into a SQL Server table
now I want the application to be able to display the data from these uploads in e.g. a HTML table without having to use a hardcoded model
Is it possible to display the data using a connection string and e.g. LINQ to SQL or EF? Best case would be where I can dynamically assign table names etc. into queries.
The models will still be used to access data belonging to the application logic, it's just the displaying of data from user-uploads that is not clear to me at this time.
EF and Linq2Sql will always require you to have a existing model associated to a database table.
If you really need that "dynamic" query, you can use a micro-ORM like dapper.Net to return your query to a dynamic type.
This solution won't save you from having generate the select sql query, by retrieving the list of fields from the table. Maybe you can use the sys tables from sql server (if that is the data base) for that. Like in here

Bulk replace of content of SQL Server tables

My ASP.NET MVC application has a number of web servers accessing a SQL Server database via Entity Framework 6. The database has 2 tables, with a one to many relationship between them.
Once a day, the entire contents of both tables needs to be replaced by a new dataset that is loaded over the Internet from a remote web service. The number of records may be in the tens out thousands. The records are not very big, with about 10 nvarchar and integer fields each.
I'm planning to have one web server load the dataset from the remote web service into the 2 SQL Server tables. It would need to remove the old content and efficiently load the new content. While this is happening, the other web servers have to be prevented from accessing the tables (probably by locking the tables).
I'm looking for fast options to accomplish this, and their pros and cons. If there is a NuGet package or Entity Framework command that does this for me, that would be ideal.
Load them into temporary tables and MERGE (merge statement) Them into the daily use tables.

Add user-defined module into Database Engine to pre-processing T-SQL queries

I write a module to translate 1 sql query into another query. When users send sql queries to DB-Engine, then DB-Engine will firstly forward these queries to my defined-module before processing sql syntax.
How can I integrate my-defined module to DB-Engine of SQL Server?
You can redirect queries for certain data to different tables using a partitioned view:
http://technet.microsoft.com/en-US/library/ms188299(v=SQL.105).aspx
In a nutshell, you tell the server some rules as to which values reside in which tables (usually based on primary or foreign key ranges for example). When you query using the partition field, the database can direct your query to the correct remote table. But you can still do queries over all the tables just as if they were held locally (except more slowly).

Resources