sql-server-2014

SSIS Package Works in VS but not in SSIS because of ODBC Data Flow Task Error

萝らか妹 提交于 2019-12-24 01:06:40
问题 We have a test package that was designed using VS2017 that has one "Data Flow Task" object with "ODBC Source" and "ODBC Destination" objects within it. The package is simply trying to move records from table 'Table_1' to table 'Table_2' in the same SQL Server 2014 database named 'Test'. When we execute the package from VS2017, it runs successfully. However, when we import that package into SSIS, and then run the package directly from there, we get the following error messages (see screen

SQL server 2014: different performances (huge “number of executions”) with same VMs

泪湿孤枕 提交于 2019-12-24 00:57:00
问题 I have 2 identical VM (16 vCPU,RAM:64GB) with the same database, same tables and views and same number of lines. View1 has 4.7M lines. On VM1 (UAT) a SELECT TOP 1000 .. FROM View1 answers in less than 1 s. On VM2 (PROD) the same query answers in 4 minutes. I've checked properties of database, tables, view1 and didn't find any difference between VM1 and VM2. I've checked statistics but it shows that nothing has to be refeshed. The plan of execution on VM2 shows: estimated number of executions

Extended event session on SQL Server 2014 to capture stored procedure calls and arguments passed

本秂侑毒 提交于 2019-12-23 23:18:04
问题 I have an application which generates certain reports while values are entered and generate button is clicked on an application. I know to which database this application is connecting, but don’t know which stored procedure is getting called. The database is having 100s of stored procedures. So I need to track which stored procedure is called and what arguments are passed while clicking each button on the application. Guys, please could you help me to create an extended event session which

Script Out Server Properties and Database Properties

落爺英雄遲暮 提交于 2019-12-23 19:04:03
问题 MSSQL 2014 If possible, can someone provide the tsql to extract the settings from the pages of Server Properties and Database Properties? Thanks 回答1: You are looking for DATABASEPROPERTY and SERVERPROPERTY. Just list them in a SELECT statement like: SELECT [Service_Name] = @@SERVICENAME ,[Server Name] = SERVERPROPERTY('ServerName') ,[Physical_Net_BIOS_Name] = SERVERPROPERTY('ComputerNamePhysicalNetBIOS') ,[Edition] = SERVERPROPERTY('Edition') ,[Product_Version] = SERVERPROPERTY(

SQL Server Default value for columns

拥有回忆 提交于 2019-12-23 18:13:49
问题 When you use default value for a column in SQL Server Management Studio table designer, SSMS change your default and stand Parenthesis around of that (In all editions and all versions of SQL Server). For example if you set 0 as default value, this default changed to (0) . I don't know why sql server use parenthesis, and is there a practical reason. Thanks in advance. 回答1: There are certain types of objects, such as DEFAULT s and CHECK constraints that SQL Server doesn't store the original,

Date range with minimum and maximum dates from dataset having records with continuous date range

天大地大妈咪最大 提交于 2019-12-23 15:28:16
问题 I have a dataset with id ,Status and date range of employees. The input dataset given below are the details of one employee. The date ranges in the records are continuous(in exact order) such that startdate of second row will be the next date of enddate of first row. If an employee takes leave continuously for different months, then the table is storing the info with date range as separated for different months. For example: In the input set, the employee has taken Sick leave from '16-10-2016

defaults using Getdate and DateAdd are not working

淺唱寂寞╮ 提交于 2019-12-23 04:28:53
问题 I set up a table yesterday with the following code. the code ran with no error messages reported and the table appeared correctly set up in object explorer. Create Table PriceTable (Airport_IACO_Code Varchar (4) NOT NULL, Airline_IACO_Code Varchar (3) NOT NULL, FlightDate Date NOT NULL Default Getdate(), DepTime Time NOT NULL Default DATEADD(hour, 6, GETDATE()), Price Smallmoney, RouteDiscontinuedOrCommences Varchar (15), ) GO However on checking the table today the FlightDate which has the

Trimming any Leading or trailing characters

自作多情 提交于 2019-12-23 02:28:07
问题 I have a table where I have some raw data. My requirement is to trim any leading or trailing spaces and operator characters in the given string column. Examples of operator characters include + - . > < = : ;" Examples: Value +Payment should be trimmed to Payment Value ->300 Write should be trimmed to 300 Write 回答1: You can try this: DECLARE @tbl TABLE(YourString VARCHAR(100)); INSERT INTO @tbl VALUES('+Payment'),('->300 Write'),('-:<Test,:%'); SELECT SUBSTRING(YourString,A.posFirst,A.posLast

Unpivoting multiple columns

给你一囗甜甜゛ 提交于 2019-12-23 01:55:07
问题 I have a table in SQL Server 2014 called anotes with the following data and I want to add this data into another table named final as ID Notes NoteDate With text1, text2, text3, text4 going into the Notes column in the final table and Notedate1,notedate2,notedate3,notedate4 going into Notedate column. I tried unpivoting the data with notes first as: select createdid, temp from (select createdid,text1,text2,text3,text4 from anotes) p unpivot (temp for note in(text1,text2,text3,text4)) as unpvt

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

杀马特。学长 韩版系。学妹 提交于 2019-12-23 00:23:17
问题 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| --