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.Linq; | |
namespace SampleTest | |
{ | |
public class Program | |
{ | |
public static void Main() | |
{ | |
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
DECLARE @LogIndex INT | |
DECLARE @LastCheckDate DATETIME | |
SET @LogIndex = 0 | |
SET @LastCheckDate = '2023-12-21' | |
DECLARE @Logs TABLE | |
( | |
LogDate DATETIME, | |
ProcessInfo NVARCHAR(4000), |
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
/// <summary> | |
/// Converts characters above ASCII to their ASCII equivalents. For example, accents are removed from accented characters. | |
/// </summary> | |
/// <param name="str"></param> | |
/// <returns></returns> | |
public static string ReplaceDiacritics(this string str) | |
{ | |
/* based on code here: | |
* https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ASCIIFoldingFilter.cs | |
*/ |
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 DatabaseName SET OFFLINE WITH ROLLBACK IMMEDIATE | |
ALTER DATABASE DatabaseName SET READ_COMMITTED_SNAPSHOT ON | |
ALTER DATABASE DatabaseName SET ONLINE | |
/* Generate sql scripts for multiple databases. | |
SELECT 'ALTER DATABASE ' + [name] + ' SET OFFLINE WITH ROLLBACK IMMEDIATE; | |
ALTER DATABASE ' + [name] + ' SET READ_COMMITTED_SNAPSHOT ON; | |
ALTER DATABASE ' + [name] + ' SET ONLINE; | |
' | |
FROM sys.databases |
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 Microsoft.EntityFrameworkCore.Diagnostics; | |
using System; | |
using System.Collections.Generic; | |
using System.Data.Common; | |
using System.Threading; | |
using System.Threading.Tasks; | |
*/ | |
public class EnrichExceptionDataDbCommandInterceptor : DbCommandInterceptor |
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
/* The CurrentThreadTaskScheduler code comes from | |
* https://github.com/dotnet/samples/blob/main/csharp/parallel/ParallelExtensionsExtras/TaskSchedulers/CurrentThreadTaskScheduler.cs | |
*/ | |
/// <summary> | |
/// Provides a task scheduler that runs tasks on the current thread. | |
/// </summary> | |
public sealed class CurrentThreadTaskScheduler : TaskScheduler | |
{ | |
/// <summary>Runs the provided Task synchronously on the current thread.</summary> | |
/// <param name="task">The task to be executed.</param> |
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
/* source: https://stackoverflow.com/a/7124052/2753545 */ | |
function htmlEscape(str) { | |
return str | |
.replace(/&/g, '&') | |
.replace(/"/g, '"') | |
.replace(/'/g, ''') | |
.replace(/</g, '<') | |
.replace(/>/g, '>') | |
.replace(/\//g, '/'); |
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 T.name AS TableName, A.name AS ColumnName, d.name AS ConstraintName | |
FROM sys.default_constraints D | |
INNER JOIN sys.all_columns A ON A.default_object_id = D.object_id | |
INNER JOIN sys.tables T ON T.object_id = A.object_id | |
WHERE T.name = @TableName AND A.name = @ColumnName |
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
CREATE PROCEDURE [dbo].[spDuplicateEntryWithIdentityValue] | |
@TableName NVARCHAR(128), | |
@IdentityColumnName NVARCHAR(128), -- the name of auto-increasing column | |
@CurrentIdentityValue INT, | |
@NewIdentityValue INT OUTPUT | |
AS | |
DECLARE @ColumnNames NVARCHAR(MAX) | |
SELECT @ColumnNames = STRING_AGG(N'[' + COLUMN_NAME + N']', N', ') | |
FROM INFORMATION_SCHEMA.COLUMNS |
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
CREATE FUNCTION [dbo].[fnGetDateRange] | |
( | |
@Now DATETIME, | |
@FrequencyId INT | |
) | |
RETURNS @Result TABLE | |
( | |
StartDate DATE, | |
EndDate DATE | |
) |
NewerOlder