This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH | |
MEMBER [Measures].[СТАТ.ДЕМ.01] AS ([Measures].[VALUE], [Account].[Code].&[СТАТ.ДЕМ.01]) | |
SELECT [Measures].[СТАТ.ДЕМ.01] on 0, | |
Non empty ( | |
order( | |
[Territory].[Territories].[Федеральные округа]*[Calendar].[Year].[Year] | |
,[Calendar].[Year]. MemberValue, BDESC | |
) | |
) on 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Microsoft SQL Server Integration Services Script Component | |
' Write scripts using Microsoft Visual Basic 2008. | |
' ScriptMain is the entry point class of the script. | |
Imports System | |
Imports System.Data | |
Imports System.Math | |
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper | |
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT TOP 10 CAST(ACCOUNT_value_id AS NVARCHAR) + '...' | |
FROM [DM].[F_ACCOUNT_VALUE] FOR XML PATH('') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Количество уровней иерархии | |
WITH | |
MEMBER [Measures].[NumberOfLevels] AS | |
[Territory].[Territories]. Levels.Count | |
SELECT | |
[Measures].[NumberOfLevels] ON COLUMNS | |
FROM | |
[FRGS] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Tab, line feed and carriage return control characters have the values CHAR(9), CHAR(10) and CHAR(13) respectively. | |
cast(REPLACE(REPLACE(REPLACE(your_number_column,CHAR(9),”), CHAR(10),”),CHAR(13),”) as bigint) | |
http://bisherryli.com/2014/05/30/sql-54casting-numbers-with-white-spaces-as-integer-will-fail/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT o .[name], o. [type], i.[name] , i .[index_id], f. [name] | |
FROM sys .indexes i | |
INNER JOIN sys. filegroups f | |
ON i .data_space_id = f .data_space_id | |
INNER JOIN sys. all_objects o | |
ON i .[object_id] = o .[object_id] | |
WHERE i .data_space_id = f .data_space_id | |
AND o .type = 'U' -- User Created Tables | |
ORDER BY f. [name] | |
--------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH cte AS ( | |
SELECT 1 i | |
UNION ALL | |
SELECT i +1 FROM cte WHERE i < 100 | |
) | |
SELECT * FROM cte | |
OPTION ( maxrecursion 0 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER Procedure [dbo].[my_sp]@currentDate datetime = nullASIF @currentDate IS nullSET @currentDate = getdate() | |
URL: http://stackoverflow.com/questions/470664/sql-function-as-default-parameter-value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER DATABASE <dbname> SET OFFLINE WITH ROLLBACK IMMEDIATE | |
URL: http://stackoverflow.com/questions/808232/extreme-wait-time-when-taking-a-sql-server-database-offline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE [msdb] | |
GO | |
SELECT j.job_id, | |
s.srvname, | |
j.name, | |
js.step_id, | |
js.command, | |
j.enabled | |
FROM dbo.sysjobs j | |
JOIN dbo.sysjobsteps js |
OlderNewer