Instantly share code, notes, and snippets.

View AggregateFunctionsinanUpdateStatementquery4.sql
WITH AggregateData AS
(
SELECT Gate
,MAX(RecordedTime) AS MaxRecordedTime
FROM dbo.SFOGateInfo
)
UPDATE AggregateTest
SET LastUsedDateTime = AggregateData.MaxRecordedTime
FROM AggregateTest
INNER JOIN AggregateData
View AggregateFunctionsinanUpdateStatementquery3.sql
UPDATE AggregateTest
SET LastUsedDateTime = MAX(recordedTime)
FROM SFOGateInfo
View AggregateFunctionsinanUpdateStatementquery2.sql
INSERT INTO AggregateTest (Gate, LastUsedDateTime)
SELECT Gate
MAX(RecordedTime)
FROM SFOGateInfo
GROUP BY Gate
View AggregateFunctionsinanUpdateStatementquery1.sql
CREATE TABLE AggregateTest
(
ID INT IDENTITY(1, 1) PRIMARY KEY NOT NULL
,Gate VARCHAR(5) NULL
,LastUsedDateTime DATETIME2(7) NULL
)
View StringTruncated.sql
use tempdb
GO
CREATE TABLE dbo.Test1
(
Col1 VARCHAR(6) NOT NULL PRIMARY KEY
)
GO
View AllPostsAndAcceptedAnswersAndEditedUsers.sql
--Use a Where Clause
SELECT Posts.Title
,acceptedAnswer.CreationDate
,Users.DisplayName
FROM dbo.Posts
LEFT JOIN dbo.Posts AS acceptedAnswer
ON acceptedAnswer.Id = Posts.AcceptedAnswerId
LEFT JOIN dbo.Users
ON acceptedAnswer.LastEditorUserId = Users.Id
View LeftJoinPostsToAcceptedAnswerInnerJoinUser.sql
SELECT Posts.Title, acceptedAnswer.CreationDate, Users.DisplayName
FROM dbo.Posts
LEFT JOIN dbo.Posts AS acceptedAnswer
ON acceptedAnswer.Id = Posts.AcceptedAnswerId
INNER JOIN dbo.Users
ON acceptedAnswer.LastEditorUserId = Users.Id
WHERE Posts.PostTypeId = 1
View leftjoinpoststoacceptedanswer.sql
SELECT Posts.Title,acceptedAnswer.CreationDate
FROM dbo.Posts
LEFT JOIN dbo.Posts AS acceptedAnswer
ON acceptedAnswer.Id = Posts.AcceptedAnswerId
WHERE Posts.PostTypeId = 1
View GenerateToast c#
private void GenerateToast(string title, string message)
{
var template = ToastTemplateType.ToastImageAndText02;
var toastXML = ToastNotificationManager.GetTemplateContent(template);
var images = toastXML.GetElementsByTagName("image");
images[0].Attributes[1].NodeValue = @"file://**FilePath**\**FileName.png";
var textNodes = toastXML.GetElementsByTagName("text");
textNodes[0].AppendChild(toastXML.CreateTextNode(title));
textNodes[1].AppendChild(toastXML.CreateTextNode(message));