sql-server-2016

How to find which Program or User executed Query using Query Store in SQL Server 2016+

二次信任 提交于 2019-12-24 05:02:25
问题 After enabling query store, how to find who executed the query. For example, in case of trace collection, there is TRC file which will get the hostname and program details for query and in case of Extended-Events, we have XEL file which will get the hostname and program details. We tried code SELECT des.program_name, des.host_name, * FROM sys.query_store_query_text qt -- Query Text JOIN sys.query_store_query q ON qt.query_text_id = q.query_id -- Query Data JOIN sys.query_store_plan qp on qp

How to find which Program or User executed Query using Query Store in SQL Server 2016+

半世苍凉 提交于 2019-12-24 05:02:21
问题 After enabling query store, how to find who executed the query. For example, in case of trace collection, there is TRC file which will get the hostname and program details for query and in case of Extended-Events, we have XEL file which will get the hostname and program details. We tried code SELECT des.program_name, des.host_name, * FROM sys.query_store_query_text qt -- Query Text JOIN sys.query_store_query q ON qt.query_text_id = q.query_id -- Query Data JOIN sys.query_store_plan qp on qp

Converting JSON to table in SQL Server 2016

我们两清 提交于 2019-12-24 03:02:17
问题 I'm working on a Web project where the client application communicates with the DB via JSONs. The initial implementation took place with SQL Server 2012 (NO JSON support and hence we implemented a Stored Function that handled the parsing) and now we are moving to 2016 (YES JSON support). So far, we are reducing processing time by a significant factor (in some cases, over 200 times faster!). There are some interactions that contain arrays that need to be converted into tables. To achieve that,

How to check are there JSON Functions by SQL query?

こ雲淡風輕ζ 提交于 2019-12-23 09:37:39
问题 There are JSON Function in SQL 2016 like JSON_VALUE, JSON_QUERY and other. I would like to use it in my queries, but I still have old servers with SQL 2014, for example, that are not allowed to use the new functionality. Can I check are there functions like JSON_VALUE by query? Something like IF operator_exists('JSON_VALUE') SELECT JSON_VALUE([Value], '$.MyPath') FROM [dbo].[MyTable] WHERE [Name] = 'MyProperty' ELSE SELECT '' Thanks. UPDATE If I use ckecking like this (thanks Rigerta Demiri)

Power BI Slow with SSAS Multidimensional Cube

霸气de小男生 提交于 2019-12-23 07:00:09
问题 We are implementing Power BI with SSAS Cube Direct Query. For some reason, SSAS Power BI is extremely slow performance, however using SSDT SSAS Application or Power View or Excel is Much faster. I read that Power BI converts SSAS Multidimensional models by converting MDX to a DAX query. Is there any method to speed up Power BI queries for SSAS, or use MDX queries directly? We are applying SSAS Multidimensional model. 回答1: I don't think that the performance issue is caused by converting MDX

STRING_AGG is not a recognized built-in function name

北城余情 提交于 2019-12-23 06:56:35
问题 I've downloaded and installed SQL Server 2016. When I attempted to use the STRING_AGG function I receive this error. Here is my code: SELECT STRING_AGG(cast(FieldNumber AS VARCHAR(100)), ',') FROM Fields I've installed SQL Server 2016 and SP1. Is there anything else I need to do. Here is the feature I am trying to use. String Agg 回答1: STRING_AGG is not introduced in SQL SERVER 2016 . It is introduced in SQL SERVER vNext . In the MSDN link you have provided it is mentioned THIS TOPIC APPLIES

Get tabular as well as json column in a T-SQL query

这一生的挚爱 提交于 2019-12-23 05:25:18
问题 In SQL Server 2016, FOR JSON PATH allows for the whole result set returned as a JSON string. Is there a way to get a regular record set with some columns as JSON? For e.g. for a Products (Master) and Orders (Details) table when joined together, I would like the query to return the result set from the Products table as regular tabular columns, but those multiple rows for each product from the Orders table returned as a JSON column. Until now I have been doing this using a user-defined scalar

aggregate value in different rows

▼魔方 西西 提交于 2019-12-23 04:58:09
问题 i have data like this table ItemId Value Date 1 2 2017-12-18 17:00:00.000 1 2 2017-12-18 17:02:00.000 1 2 2017-12-18 17:04:00.000 1 3 2017-12-18 17:06:00.000 1 3 2017-12-18 17:08:00.000 1 2 2017-12-20 17:10:00.000 1 2 2017-12-20 17:12:00.000 i want to output like this in sql server ItemId Value MaxDate 1 2 2017-12-18 17:04:00.000 1 3 2017-12-18 17:08:00.000 1 2 2017-12-20 17:12:00.000 I'm sorry, I did not get a better sentence for my title 回答1: This can be done with a difference of row

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

*爱你&永不变心* 提交于 2019-12-22 18:24:57
问题 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

R In SQL Server 2016

大兔子大兔子 提交于 2019-12-22 12:36:09
问题 Trying to execute the test script that MSDN provides to make sure R is enabled, but it throws the following error, Msg 39023, Level 16, State 1, Procedure sp_execute_external_script, Line 1 [Batch Start Line 0] 'sp_execute_external_script' is disabled on this instance of SQL Server. Use sp_configure 'external scripts enabled' to enable it. Msg 11536, Level 16, State 1, Line 1 EXECUTE statement failed because its WITH RESULT SETS clause specified 1 result set(s), but the statement only sent 0