Get the mother's day or father's Day date of a year

Today is mother's day, which is the second Sunday in May of each year, while father's Day is the third Sunday in June of each year. Set Sunday as the start of the week and the first day of the week as a number from 1 to 7. SET DATEFIRST 7; Reference MSDN: https://docs.microsoft.com/zh-cn/sql/t-sql/statements/set-datefirst-transact-sql? ...

Posted on Tue, 12 Nov 2019 15:22:53 -0500 by kidd1270

Learn about mother's day, father's day and Thanksgiving Day

Before you complete this requirement, you can refer to another function< Get the list of days in the current month>https://www.cnblogs.com/insus/p/10837900.html: Then you need to know the common sense of the three festivals. Mother's Day is on the second Sunday in May, father's Day is on the third Sunday in June, and Thanksgiving Day is ...

Posted on Tue, 12 Nov 2019 09:39:24 -0500 by agentsmith

(Sql server) create Sql Insert statement with data in existing table

Previously, a stored procedure for creating Sql statements of Insert with data in existing tables was published in Codeproject. Today, it is moved here. Note that this stored procedure is only applicable to SQL SERVER. introduce Sometimes, you want to export Sql scripts for records in existing tables so that you can insert the data into simil ...

Posted on Sat, 09 Nov 2019 15:43:26 -0500 by Warptweet

reverse string

We have a string, such as: DECLARE @Source VARCHAR(MAX)= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' Now I want to reverse it: ZYXWVUTSRQPONMLKJIHGFEDCBA At this point, you can write a method to handle:   SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Insus.NET -- Cr ...

Posted on Sat, 09 Nov 2019 11:02:58 -0500 by Andrew B

Dynamic PivotTable

Write a perspective stored procedure that meets your requirements. During development, it can be used directly.   SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Insus.NET -- Create date: 2019-05-19 -- Update date: 2019-05-19 -- Description: Dynamic perspective ...

Posted on Fri, 08 Nov 2019 11:32:17 -0500 by mxdan

T-SQL advanced query statement

System function:String function: The basic salary of select 'operation and maintenance engineer' + name + 'is:' + CAST (basic salary as varchar(10)) + 'Yuan' from A1 where position: 'operation and maintenance engineer' #Display the name and basic salary of all operation and maintenance engineers in table A1, and the required display format i ...

Posted on Sat, 02 Nov 2019 17:45:11 -0400 by djnrempel

YourSQLDba Shared Path Backup Encountered Restart Problem

If YourSQLDba has shared path backup (refer to blog specifically) YourSQLDba Setting Shared Path Backup Sometimes when the server restarts, the backup will make an error. The specific error message is similar to the following:     Date        2019/9/25 10:10:00 Log        SQL Server (Current - 2019/9/25 3:06:00)   Source        spid56   Messag ...

Posted on Wed, 09 Oct 2019 05:54:48 -0400 by daedalus__

SQL Server user-defined table type

Sometimes we need to compare tables in memory with tables in the database. For example, there are 100 rows of data in the Datatable. We need to determine whether there is any data in the database. In this case, we can use the User Defined Table Type in SQL server. The most important idea here is to treat the user-defined table type as a virtua ...

Posted on Sat, 05 Oct 2019 03:45:47 -0400 by adyre

How to Delete Windows Authenticated Users Correctly by SQL Server

In the SQL Server database, sometimes some Windows-certified accounts (domain accounts) will be established. For example, our company is used to granting NT account rights to developers and Support colleagues. If there is a turnover or change of responsibility, how to delete these Windows-certified accounts correctly? This article is to explore ...

Posted on Sat, 21 Sep 2019 06:43:45 -0400 by deezzer

Still writing GROUP BY clauses manually? SQL Prompt can automatically populate it!

SQL Prompt is a practical SQL grammar prompt tool. SQL Prompt automatically retrieves the database object name, grammar and code fragments to provide users with appropriate code selection. Automatic script settings make the code easy to read -- especially when developers are not familiar with scripts. SQL Prompt can be installed and used, whic ...

Posted on Fri, 20 Sep 2019 01:20:55 -0400 by username123