sql-server-2016

SQL WHERE depending on day of week

て烟熏妆下的殇ゞ 提交于 2019-12-05 20:55:43
I have a requirement to check records up to differing dates, depending on which day of the week it is currently. On a Friday I need for it to look at the entire next week, until Sunday after next. On any other day it should check the current week, up until the coming Sunday. I have the below currently but it's not working due to syntax error. Is it possible to do a CASE WHEN inside a WHERE clause? WHERE T0.[Status] IN ('R','P') AND CASE WHEN DATEPART(weekday,GETDATE()) = '5' THEN T0.[DueDate] >= GETDATE() AND <= DATEADD(day, 15 - DATEPART(weekday, GetDate()), GetDate()) WHEN DATEPART(weekday,

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

大兔子大兔子 提交于 2019-12-05 19:30:16
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 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-2017 来源: https://stackoverflow.com/questions/41695344/how-can-i-create-named-instance-of-sql-server-on-ubuntu

Table-Valued Parameter without using a stored procedure

时光怂恿深爱的人放手 提交于 2019-12-05 14:22:10
It seems all I can find online are examples of table-valued parameters that require using a stored procedure. I recall doing this in the past without the stored procedure. Is that possible? This code keeps throwing an error about the type not being specified. SqlCommand cmd = new SqlCommand(@" UPDATE t1 SET t1.ScheduledStartUTC = t2.ScheduledStartUTC FROM ScheduleTickets AS t1 INNER JOIN @SetScheduledStart AS t2 ON t1.ScheduleId = t2.ScheduleId AND t1.PatchSessionId = t2.PatchSessionId ", c); cmd.Parameters.Add("@SetScheduledStart", SqlDbType.Structured).Value = SetScheduleTicketsDateDT; cmd

Passing JSON type as parameter to SQL Server 2016 stored procedure using ADO.Net in ASP.Net Core project

99封情书 提交于 2019-12-05 14:16:25
问题 Can someone give example how to pass JSON type as parameter to SQL Server 2016 stored procedure using ADO.Net in C# ASP.Net Core Web Api project ? I want to see example of SQL Server 2016 stored procedure and pass of JSON type in C# ASP.Net Core Web Api. 回答1: There is no json data type in sql sever you can simply send your json as varchar to stored procedure. If you want to map your json to table you can use use OPENJSON to convert data to rows and columns . CREATE PROCEDURE SaveJSON @pID int

Computed Columns In Azure SQL Server 2016 Temporal Tables

不想你离开。 提交于 2019-12-05 10:43:51
I am looking at creating temporal tables https://msdn.microsoft.com/en-us/library/mt604462.aspx in our database but I cant on a couple of tables that have computed columns. The error message returned is rather self explanatory "Computed column is defined with a user-defined function which is not allowed with system-versioned table" but I was hoping there was a way to exclude or ignore columns from being tracked? I have tried dropping the computed column creating the history table then adding the computed column back into the table but this didn't work. Any help is appreciated. Thanks Edit - I

SQL Server bug or feature? Decimal numbers conversion

喜欢而已 提交于 2019-12-05 10:00:41
问题 During development faced up with quite a strange SQL Server behavior. Here we have absolutely the same formula for absolutely the same number. The only difference is how we are getting this number (4.250). From table, temp table, variable table or hardcoded value. Rounding and casting is absolutely the same in all cases. -- normal table CREATE TABLE [dbo].[value] ( [val] [decimal] (5, 3) NOT NULL ) INSERT INTO [value] VALUES (4.250 ) SELECT ROUND(CAST(val * 0.01 / 12 AS DECIMAL(15, 9)), 9) AS

Where does one place the Always Encrypted Certificate on an IIS 7.5 web server?

隐身守侯 提交于 2019-12-05 08:21:34
We have a SQL Server 2016 database that employs Always Encrypted. Our recently published ASP.net web site attempts to pull data from this database, and when it does we get this error: Error: Failed to decrypt column 'EnSSd'. Failed to decrypt a column encryption key using key store provider: 'MSSQL_CERTIFICATE_STORE'. The last 10 bytes of the encrypted column encryption key are: 'B8-48-B3-62-90-0B-1D-A6-7D-80'. Certificate with thumbprint '97B0D3A64CADBE86FE23559AEE2783317655FD0F' not found in certificate store 'My' in certificate location 'CurrentUser'. Verify the certificate path in the

R in SQL Server: Output data frame into a table

最后都变了- 提交于 2019-12-05 05:32:49
问题 This probably has a simple answer but I cannot figure it out as I'm still getting a hang of working with R in SQL Server. I have a piece of code that reads in data from a SQL Server table, executes in R and returns a data frame. execute sp_execute_external_script @language=N'R', @script=N'inp_dat=InputDataSet inp_dat$NewCol=max(inp_dat$col1,inp_dat$col2) new_dat=inp_dat OutputDataSet=new_dat' @input_data_1=N'select * from IM_COMP_TEST_SQL2016.dbo.temp_table'; I want to insert new_dat into a

Deploy of a report with SSDT 2016 generates error

五迷三道 提交于 2019-12-05 02:56:35
I use VS2015 with SQL Server Data Tools; I have some Reporting Services (RDL) reports. I want to deploy them to a Reporting Server with SQL Server 2014 installed. In my report project I set the TargetServerVersion to "SQL Server 2008R2, 2012 or 2014" , but the deploment process fails with an error similar to: Report Definition invalid, because namespace .../2016/... invalid. It is solved. You "MUST" recompile your report project and immediately afterwards you can deploy your reports without any problem. 来源: https://stackoverflow.com/questions/37816216/deploy-of-a-report-with-ssdt-2016

System.OutOfMemoryException occurs frequently after Upgrading SQL Server 2016 to version 13.0.15700.28

主宰稳场 提交于 2019-12-05 00:32:14
I am running Windows 10 Pro 64 bit on a dev box that has multiple monitors, 16 gigs DDR4 RAM, 4 Ghz I7, GTX 970. I run SQL Management Studio with SQL Server 2016 Developer Edition along with VS 2015 Enterprise Update 3. Yesterday I upgraded Sql Management Studio 2016 to 13.0.15700.28 and it was like a poison pill for my machine. Now after an hour or two it will throw an out of memory except: An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown Now this is sometimes typical if you are doing very large return sets of over a few