Category "sql-server"

C# EFCore.BulkExtensions The MERGE statement conflicted with the FOREIGN KEY constraint

Parent: public class Currency { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string? Name { get; set; }

SQL How To Display Month Difference Between Return And Purchase Date

I need help with writing the query that will say month difference between return and purchase dates, see the example below. Product PurchaseDate (dd/mm/yy) Ret

Write a query identifying the type of each record in the TRIANGLES table using its three side lengths

Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the following statements for each record in

EF Core - generic way to merge child records based on current db state and equality

I have a scenario where during an Update request of a parent entity, I have a collection of children entities in my dto, and want to merge them in the DB so tha

more VARBINARY columns in result set fo SQL Server R sript

In my R script for MS SQL Server I try to return one column VARBINARY() and one VARCHAR(). However, server allow only one column when VARBINARY is returned: T

Schema compare - Unexpected exception caught during population of source model: Object reference not set to instance object

I've been running a schema compare in a database project in Visual Studio 2017, when I do this I get the following message in the Error List tab: Unexpected

EF Core 3, optimize lots of Include/ThenInclude

I have a query like this return await _ctx.Activities .Include(a => a.Attributes) .Include(a => a.Roles) .Include(a =

ERROR: Unsupported PIVOT column type: text

I'm trying to perform a PIVOT but getting an error. I'm trying to see which patients have more than one Interval session. The column is a text type. I attempted

How do I add an error message to my stored procedure when 0 rows are affected?

I am trying to learn how to use transactions and error handling. Got stuck with custom error messages. The stored procedure generates badges for AdventureWorks

Could SSMS shows actual execution plan in Azure Synapse?

I'm studying of Azure Synapse. In dedicated SQL pool database, 'actual execution plan' of SSMS was disabled. In serverless pool database, SSMS says 'set statist

What is the most effective way to exclude blank records in a SQL Server query

I am trying to run a query to return all rows that are not null. But, I am not able to get that done. How is this possible? Please assist.

Select item that is different in each of group by a column

I have this sample table +--------+-------------+ | DBName | Description | +--------+-------------+ | A | Car | | A | Boat | | B

OUTPUT $action in SQL server, casing the updated rows output for a specific column

I am making merge upserts to my data warehouse. I don't need to keep the history on this particular object, so I'm using a type i slowly changing dimension. I'm

How to deal with SQL server error: The database cannot be opened because it is version 904. This server supports version 852 and earlier [closed]

While connecting to SQL Server database by attaching to an MDF file, the following error is returned: The database cannot be opened because it

Smarter SQL UPDATE between two tables (bill and bill rows)

I have these two SQL tables: Bills (BillId, Folio, Date, ProductId) BillsRows (BillRowId, BillId, ProductId, Lot, Quantity, Price) ProductId is optional in Bil

SQL Server : run a script on all databases

I have a SQL script with a function (function drops at the end of the script) and temporary table definitions and variables to process the data that gives me on

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

I want to establish a MSSQL Connection from Ubunutu 18.04. It was quite hard to get this set up, but know it works so far that I can use sql_srv class or pdo cl

Cannot connect to SQL Server except with domain admin account

I am running into an issue where my .net application (C#) will not connect to SQL Server when ran by a domain user. Exception is: The underlying provider faile

Find average and then use that value to calculate other values

I have a query with a few columns. I need to find the avg of a particular column and then use the average value to calculate other values. I am finding avg with

SqlException (0x80131904): Cannot open database "DBName" requested by the login

I have the following connection string in ASP.NET Core, but I get the following error: Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot open dat