sql-server-2016

Duplicate in same row in different columns

与世无争的帅哥 提交于 2020-01-14 05:26:09
问题 i have a table like this: CREATE TABLE #my_table ( intID int IDENTITY (1, 1), num_1 varchar(100) NOT NULL, num_2 varchar(100) NOT NULL, num_3 varchar(100) NOT NULL, num_4 varchar(100), num_5 varchar(100), isDuplicate char(1) DEFAULT 'N' ) INSERT INTO #my_table (num_1, num_2, num_3, num_4, num_5) VALUES ('a', 'b', 'c', 'd', 'e') INSERT INTO #my_table (num_1, num_2, num_3, num_4, num_5) VALUES ('a', 'b', 'c', 'd', 'e') INSERT INTO #my_table (num_1, num_2, num_3, num_4, num_5) VALUES ('a', 'b',

How can I create named-instance of sql-server on ubuntu

↘锁芯ラ 提交于 2020-01-13 10:33:32
问题 I used the official tutorial to create a default instance https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-ubuntu but now I want to create a named-instance and can't find how to do that 回答1: SQL Server on Linux doesn't support the notion of "multi-instance", so there are no named instances on Linux. You can see that its Windows only feature here: https://docs.microsoft.com/en-us/sql/sql-server/install/work-with-multiple-versions-and-instances-of-sql-server?view=sql-server

Column encryption in ASP MVC app with SQL Server 2016 using .net Core / EF Core

别来无恙 提交于 2020-01-12 03:31:06
问题 I am trying to use the "Always Encrypted" feature in SQL Server 2016 to encrypt some columns. I used this post as a guide to set the columns as encrypted in SSDT. That part goes fine, it's when I attempt to query the data from the application that I get an error. According to the docs I need to add this: column encryption setting=enabled to my connection string. This does not appear to be supported in Entity Framework Core. I get this error: column encryption setting=enabled is not supported

How do I use SQL to PIVOT a table without an aggregate and without knowing column values?

时光总嘲笑我的痴心妄想 提交于 2020-01-07 09:49:11
问题 I am working on a legacy database and need to develop a SQL query to give to a customer. As a legacy database, it was not designed with this type of query in mind. I've simplified the two tables I need to select from to make an easier to understand example. I have a "long table", and need to make it "wide". I have tried working with PIVOT but have encountered two issues: There is nothing to aggregate- it's just a simple matrix transformation. I don't know the number of columns I need to add

SQL Server database audit selects, failed logins and executed code for entire database, all objects

柔情痞子 提交于 2020-01-07 03:12:05
问题 I want to track all failed logins to our production environment. Including all selects to all objects. Based on: https://www.simple-talk.com/sql/database-administration/sql-server-audit-magic-without-a-wizard/ and https://www.simple-talk.com/sql/database-administration/sql-server-security-audit-basics/ and in particular: https://blogs.msdn.microsoft.com/sreekarm/2009/01/05/auditing-select-statements-in-sql-server-2008/ It suggests I need to name each object, in the schema for me to be able to

SQL Server 2016 - Five Column to single row

牧云@^-^@ 提交于 2020-01-06 08:10:32
问题 I have the following data +--------+ | orders | +--------+ | S1 | | S2 | | S3 | | S4 | | S5 | | S6 | | S7 | | S8 | | S9 | | S10 | | S11 | | S12 | +--------+ I am required to return the result as follows - fit five rows in one column: +-----------------+ | Orders | +-----------------+ | S1,S2,S3,S4,S5 | | S6,S7,S8,S9,S10 | | S11,S12 | +-----------------+ There is nothing to group on or segregate these into rows. So I assigned a row_number and did mod 5 on the row_number. It almost works, but

FIFO closing price with multiple products and people

霸气de小男生 提交于 2020-01-06 07:02:34
问题 I have found the following solution to a problem I was trying to solve: https://stackoverflow.com/a/26778468/1626443 I want to have a single query that returns me the FIFO price closing price per investor and isin . The current query works, but I have to filter by the isin and investor (the top is the sample data): CREATE TABLE #CustomerOrderTable ( ID INTEGER NOT NULL, [investor] VARCHAR(255) NOT NULL, [isin] VARCHAR(255) NOT NULL, [datetime] DATETIME NOT NULL, [quantity] FLOAT NOT NULL,

Will the use of CURSOR improve the performance / speed of querying using PIVOT in SQL?

不想你离开。 提交于 2020-01-06 05:53:09
问题 Newbie here on EAV (Entity-Attribute-Value) model of DB in SQL. Just a background: I am using SQL Server 2016 . The use of EAV is kind of a requirement at work so I am learning to do it one step at a time. I recently learned how to do a dynamic PIVOT to return 800+ rows with 200+ columns in an EAV table. See details here: Converting 200+ rows to column in SQL Server using PIVOT As successful it was to return the data I need, the performance speed was too slow - it took about 30mins to query.

Create linked server in management studio to SAGE 50 US database using ODBC Data source administrator

假装没事ソ 提交于 2020-01-06 05:40:29
问题 I am trying to create a linked server to SAGE 50 using server in management studio but keep getting an error. I am hoping that someone has done this before and can provide some guidance.I set up and tested "ODBC data source administrator (64bit)" with as seen below and it works for Microsoft access when I used "External data - ODBC database" connection. I then added a linked server with the security tab set up like so using the same credentials that I used to add it to Access like so: And set

Variables make query performance worse

牧云@^-^@ 提交于 2020-01-06 04:41:18
问题 I have this query and the performance slows down drastically when I declare variables: DECLARE @StartDate DATETIME, @EndDate DATETIME SET @StartDate = '2018-08-13' SET @EndDate = '2018-08-19' SELECT * FROM [DIME_WH].[dbo].[FactOrderLines2] FL (nolock) WHERE DD_OrderDate >= @StartDate AND DD_OrderDate <= @EndDate This is much slower than this SQL statement: SELECT * FROM [DIME_WH].[dbo].[FactOrderLines2] FL (nolock) WHERE DD_OrderDate >= '2018-08-01' AND DD_OrderDate <= '2018-08-17' Both