sql-server-2014

SQL Pivot with dynamic generated columns, aggregate function and columns without aggregation

旧时模样 提交于 2019-12-07 04:01:06
问题 I have got the following query: WITH preEKBE AS( SELECT EKPO . MANDT, EKPO . EBELN, EKPO . EBELP, DD07T.DDTEXT AS c_Meaning, EKBE . VGABE, EKBE . DMBTR, EKBE . MENGE, COUNT(VGABE) OVER(PARTITION BY EKBE . EBELN, EKBE . EBELP, ZEKKN) AS c_COUNT, CONVERT (varchar(10),MIN(EKBE . BLDAT) OVER ( PARTITION BY EKBE . EBELN, EKBE . EBELP, EKBE . VGABE),104) AS c_EBKE_BLDAT_First, CONVERT (varchar(10),MIN(EKBE . BUDAT) OVER ( PARTITION BY EKBE . EBELN, EKBE . EBELP, EKBE . VGABE),104) AS c_EKBE_BUDAT

Parse #Hashtag Comments From SQL Server Record

倾然丶 夕夏残阳落幕 提交于 2019-12-06 14:29:19
问题 I am trying to pull all "#" comments from a text field in a SQL Server 2014 database. I am using the code I found on this MSDN thread to find multiple hashtags in one record and have modified it slightly to fit my needs, but I seeing some unexpected results in my result set. My T-SQL so far: IF OBJECT_ID('tempdb..#hashtag') IS NOT NULL DROP TABLE #hashtag; IF OBJECT_ID('tempdb..#numbers') IS NOT NULL DROP TABLE #numbers; IF OBJECT_ID('tempdb..#hashtagcounts') IS NOT NULL DROP TABLE

SQL Server: how to populate sparse data with the rest of zero values?

馋奶兔 提交于 2019-12-06 12:07:24
I have data reporting sales by every month and by every customer. When I count the values, the zero-values are not reported because of the sparsa data format. Suppose customer 1-4. Suppose only customers 1-2 have recordings. Straight table has customerIDs on rows and months on the columns such that |CustomerID|MonthID|Value| -------------------------| | 1 |201101 | 10 | | 2 |201101 | 100 | and then they are reported in Crosstab format such that |CustomerID|201101|201102|2011103|...|201501| --------------------------------------------- | 1 | 10 | 0 | 0 |...| 0 | | 2 | 100 | 0 | 0 |...| 0 | | 3

SQL Server 2014 Service Broker does not activate the procedure that receives messages from the queue

落花浮王杯 提交于 2019-12-06 09:20:01
The situation is closely related to SQL Service Broker - communication scenario - migration from SQL 2008 R2 to SQL 2014 and to SQL Service Broker -- one central SQL and more satelite SQL... beginner wants to understand details . After migration from SQL Server 2008 R2 Standard Ed. to SQL Server 2014 Standard Ed., the same code does not work. The firewall was set to allow the communication. The sys.transmission_queue (on both sender and receiver servers) keeps empty, and the GenericQueue (my identifier for the queue) receives the messages. However, the procedure attached by (to the receiving

Using SQLBulkCopy - Significantly larger tables in SQL Server 2016 than in SQL Server 2014

☆樱花仙子☆ 提交于 2019-12-06 09:18:34
I have an application that uses SqlBulkCopy to move data into a set of tables. It has transpired recently that users that are using SQL2016 are reporting problems with their harddrives being filled with very large databases (that should not be that large). This problem does not occur in SQL2014. Upon inspection it appears that running TableDataSizes.sql (script attached) showed large amounts of space in UnusedSpaceKB. I would like to know if a) There is some bug in SQLServer 2016 or if our use of SQLBulkCopy has "clashed" with a new feature. I note that there has been some changes to Page

C# & SQL Server - best way to delete multiple Rows in “one go” using a stored procedure

拟墨画扇 提交于 2019-12-06 09:02:12
问题 I know there's many of the same subjected question here in SO, my question is if I want to delete say around 1K rows rather few, given a List<int> of RecordID , I could avoid using a DataTable , and send the list translated into a statement: string ParmRecordsToDelete_CsvWhereIN = "(" for(int CurIdx=0; CurIdx < RecIdsToDelete.Count; CurIdx++) { ParmRecordsToDelete_CsvWhereIN += RecIdsToDelete[CurIdx] + ", "; //this method to create passed parameter //logic to remove on last Coma on last Index

Counting Values based on distinct values from another Column

走远了吗. 提交于 2019-12-06 08:52:49
I need to calculate how many orderlines there are based on the orderlineNo being distinct. Each OrderNo is different BUT the OrderLineNo is the same for each order. i.e. 9 lines on a order then order lines number will go from 1 - 9. The same if on another order there are 3 orderlines they will go from 1 - 3 But in orderlineno there could be orderline numbers that are the same - for this I only want to count it once Example: OrderNo OrderLineNo 987654 1 987654 2 987654 2 987654 3 987654 4 987654 5 987654 6 987654 7 The total order lines here is 7. There are two order lines with 2 and I want

Casting 0 as DATE and DATETIME

余生长醉 提交于 2019-12-06 08:14:01
I just happened to stumble upon this and couldn't find any technical explanation: In SQL Server 2014: SELECT CAST('' AS DATETIME); 1900-01-01 00:00:00.000 SELECT CAST(0 AS DATETIME); 1900-01-01 00:00:00.000 SELECT CAST('' AS DATE); 1900-01-01 SELECT CAST(CAST(0 AS DATETIME) AS DATE); 1900-01-01 SELECT CAST(0 AS DATE); Msg 529, Level 16, State 2, Line 4 Explicit conversion from data type int to date is not allowed. Why does the CAST from an empty string to DATE and DATETIME work, but from 0 it only works as DATETIME ? I'm interested in a technical explanation I think it's a matter of what

Installing SQL Server 2014 Express package as ClickOnce prerequisite

北城以北 提交于 2019-12-06 07:23:20
I'm using clickOnce and deploying an installer with it. I have tried various settings. Using SQL Server 2008 Express and SQL Server 2012 Express as prerequisite is all ok (I've dowloaded them and set the option of clickonce "download prerequisites from the same path of app"). Now I'm trying to do the same thing with SQL Server 2014 Express. Since the SQL Server 2014 Express package isn't alredy done line 2008 and 2012 versiones, I'm trying to create it. I have done and it seems to work, but while installing it gives error number -2054422506 . It is a very generic error and I don't understand

Can't install SQL Server 2014 on WIndows 7 - HRESULT 0x8007370B

烈酒焚心 提交于 2019-12-06 04:18:52
问题 I keep receiving the following errors: TITLE: Microsoft SQL Server 2014 Setup ------------------------------ The following error has occurred: An error occurred during the installation of assembly 'Microsoft.VC80.ATL,version="8.0.50727.6229",publicKeyToken="1fc8b3b9a1e18e3b",processorArchitecture="amd64",type="win32"'. Please refer to Help and Support for more information. HRESULT: 0x8007370B. For help, click: http://go.microsoft.com/fwlink?LinkID=20476&ProdName=Microsoft%20SQL%20Server