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
using System; | |
using System.Runtime.CompilerServices; | |
public static class DebugHelper | |
{ | |
private static readonly ConditionalWeakTable<object, object> _objectIds = new ConditionalWeakTable<object, object>(); | |
private static int _lastObjectId; | |
private static readonly object _lock = new object(); | |
public static string GetObjectId(object obj) |
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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Threading.Tasks; | |
using Seq.Api; | |
namespace SeqExportAllToJson | |
{ | |
internal class Program | |
{ |
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 [Numbers] AS | |
( | |
SELECT | |
[Ones].[Number] + | |
10 * [Tens].[Number] + | |
100 * [Hundreds].[Number] + | |
1000 * [Thousands].[Number] | |
AS [Number] | |
FROM (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) [Ones]([Number]), | |
(VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) [Tens]([Number]), |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Runtime.InteropServices; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Guids | |
{ | |
public static class SequentialGuid |
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 MASTER | |
ALTER DATABASE [DatabaseOldName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE | |
ALTER DATABASE [DatabaseOldName] MODIFY NAME = [DatabaseNewName] | |
ALTER DATABASE [DatabaseNewName] SET MULTI_USER |
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 [NodesWithParents] AS | |
( | |
SELECT * FROM [Nodes] n WHERE n.[Id] IN (...) | |
UNION ALL | |
SELECT parent.* FROM [Nodes] parent | |
INNER JOIN [NodesWithParents] child ON child.[ParentNode_Id] = parent.[Id] | |
) | |
SELECT DISTINCT [Id] FROM [NodesWithParents] |
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 | |
CONVERT(NVARCHAR(MAX), t.[table_schema]) AS [Owner], | |
CONVERT(NVARCHAR(MAX), t.[table_name]) AS [TableName], | |
MAX(i.[rows]) AS [RecordCount] | |
FROM | |
[sysindexes] i, | |
[information_schema].[tables] t | |
WHERE | |
t.[table_name] = OBJECT_NAME(i.[id]) | |
AND t.[table_type] = 'BASE TABLE' |
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 COUNT(*) AS [TableCount] FROM [information_schema].[tables] WHERE [table_type] = 'BASE TABLE' |
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 CONCAT('ABC', REPLICATE('0',6-LEN(CAST(other_id as nvarchar(max)))), CAST(other_id as nvarchar(max))) | |
FROM [experiments].[dbo].[Table_1] | |
SELECT CONCAT('ABC', FORMAT(Other_Id, '000000')) | |
FROM [experiments].[dbo].[Table_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
SELECT | |
* | |
FROM | |
sys.foreign_keys fk | |
WHERE | |
EXISTS | |
( | |
SELECT | |
* | |
FROM |