sql-server

Configuring an MDX query on SSIS

血红的双手。 提交于 2021-02-16 16:27:33
问题 Hi I am having troubles configuring the SSIS task to run an MDX query. The parse works fine but it doesn't allow me to display the different columns of the query to map it Here is the query i used: SELECT [Measures].[# Consumers] ON 0, [Company].[Company Country Code].[Company Country Code].MEMBERS ON 1 FROM _CDM The Error thrown is: No Column information was returned by the SQL Command Error snapshot 回答1: You can use MDX Select as a Source in Data Transformation Task. Two important notes:

Table Variables in Azure Data Warehouse

谁都会走 提交于 2021-02-16 15:58:20
问题 In a SQL Server database, one can use table variables like this: declare @table as table (a int) In an Azure Data Warehouse, that throws an error. Parse error at line: 1, column: 19: Incorrect syntax near 'table' In an Azure Data Warehouse, you can use temporary tables: create table #table (a int) but not inside functions. Msg 2772, Level 16, State 1, Line 6 Cannot access temporary tables from within a function. This document from Microsoft says, ◦Must be declared in two steps (rather than

How to use GROUP_CONCAT function on MSSQL

流过昼夜 提交于 2021-02-16 15:13:25
问题 How can I use the GROUP_CONCAT function on MSSQL while MySQL is running? current table; QUESTION_ID ANSWER_ID USER 1. 1 1 A 2. 1 1 B 3. 1 2 C i need; QUESTION_ID ANSWER_ID USER 1. 1 1 A, B 2. 1 2 C thanks in advance.. 回答1: Try: select distinct t1.QUESTION_ID, t1.ANSWER_ID STUFF((SELECT distinct '' + t2.USER from yourtable t2 where t1.ANSWER_ID= t2.ANSWER_ID FOR XML PATH(''), TYPE ).value('.', 'NVARCHAR(MAX)') ,1,0,'') data from yourtable t1; 回答2: I think the equivalent function could be

Remove minutes from datetime - sql

柔情痞子 提交于 2021-02-16 15:01:10
问题 DECLARE @MinutesToAdd int = 20; DECLARE @StartTimeDate datetime = '2017-06-05 14:37:56.113'; DATEADD(minute,@MinutesToAdd,@StartTimeDate); Code above adds 20 minutes to StartTimeDate. Is there a good way to remove those 20 minutes not add? Tried to find a solution, but didn't catch one. Any ideas? 回答1: You don't have any specific function to subtract any dateparts Just add negative symbol in front Select DATEADD(minute,-@MinutesToAdd,@StartTimeDate); or multiply with -1 Select DATEADD(minute,

Remove minutes from datetime - sql

房东的猫 提交于 2021-02-16 15:00:27
问题 DECLARE @MinutesToAdd int = 20; DECLARE @StartTimeDate datetime = '2017-06-05 14:37:56.113'; DATEADD(minute,@MinutesToAdd,@StartTimeDate); Code above adds 20 minutes to StartTimeDate. Is there a good way to remove those 20 minutes not add? Tried to find a solution, but didn't catch one. Any ideas? 回答1: You don't have any specific function to subtract any dateparts Just add negative symbol in front Select DATEADD(minute,-@MinutesToAdd,@StartTimeDate); or multiply with -1 Select DATEADD(minute,

Azure SQL Database Development Environment

假装没事ソ 提交于 2021-02-16 14:03:06
问题 How can I setup SQL Azure Database for development. I currently have few SQL databases ProjectName-Development, ProjectName-Staging, ProjectName-Production ... Is this the right way? This is getting more and more expensive. 回答1: I would recommend (from experience) using Azure only for Staging and Production environments. SQL Server 2016 Developer Edition is free (so is SSMS) so you can do all of your local development ... locally. When you're ready to go to staging, you can then perform a

How to add HIDDEN property on column?

别等时光非礼了梦想. 提交于 2021-02-16 13:37:47
问题 When temporal table is created, we need to defined start and end date time columns which can be hidden - not visible in SELECT * or INSERT without columns . I want to add one more column, which will contain information about the user who has commit the change. The issue is, I am getting the following error: Msg 13735, Level 16, State 1, Line 10 Cannot alter HIDDEN attribute on column 'UserID' in table 'GK' because this column is not a generated always column. Here is the code: DROP TABLE IF

How to add HIDDEN property on column?

蓝咒 提交于 2021-02-16 13:37:45
问题 When temporal table is created, we need to defined start and end date time columns which can be hidden - not visible in SELECT * or INSERT without columns . I want to add one more column, which will contain information about the user who has commit the change. The issue is, I am getting the following error: Msg 13735, Level 16, State 1, Line 10 Cannot alter HIDDEN attribute on column 'UserID' in table 'GK' because this column is not a generated always column. Here is the code: DROP TABLE IF

How to format date on MS SQL Server 2008

我是研究僧i 提交于 2021-02-16 05:12:02
问题 I would like to format dates based on a pattern like for example 22/01/2015 or 2016-12-15. In the .NET Framework we have DateTime -> ToString() method which accepts formats as argument or even string.Format, which does the same. Is there any function on MS SQL Server 2008 that formats date based on a argument pattern? 回答1: I had a similar problem in SQL 2012 they have a great function called format which you could pass in a date and the format you require SELECT FORMAT(GETDATE(), 'dd/mm/yyy')

How to format date on MS SQL Server 2008

主宰稳场 提交于 2021-02-16 05:11:50
问题 I would like to format dates based on a pattern like for example 22/01/2015 or 2016-12-15. In the .NET Framework we have DateTime -> ToString() method which accepts formats as argument or even string.Format, which does the same. Is there any function on MS SQL Server 2008 that formats date based on a argument pattern? 回答1: I had a similar problem in SQL 2012 they have a great function called format which you could pass in a date and the format you require SELECT FORMAT(GETDATE(), 'dd/mm/yyy')