String aggregate function (remove duplicate values)

-- Function: Provides replacement Aggregate functions for strings.-- Note: for example, convert the following data-- Test_id test_value--------------------'A' 01, 03,04''A' 02, 04''B' 03, 04, 08''B' 06, 08,09''C' '09''C' '10'-- Convert to the

How to obtain the midnight time value of the current date in sqlserver

The following are the custom functions of Infor syteline 8.02:Copy codeThe Code is as follows:MidnightOfAlter function [dbo]. [MidnightOf] (@ Date DATETIME) RETURNS DATETIMEASBEGINRETURN (dateadd (year, (datepart (year, @ Date)-2000), dateadd (month,

When SQL has external connections, pay attention to the filtering condition location. Otherwise, the webpage will be slow.

Grandma's, why are we only three days in May? The weather in May is the most suitable for traveling, but we cannot afford these tough IT guys.As soon as I arrived at the company, the project manager found the development leader, saying that our

Instance code for obtaining various attributes of SQL Server table fields

Copy codeThe Code is as follows:-- SQL Server 2000SELECT a. name AS field name, CASE WHEN EXISTS(SELECT 1FROM sysobjectsWHERE xtype = 'pk' AND parent_obj = a. id AND name IN(SELECT nameFROM sysindexesWHERE indid IN(SELECT indidFROM sysindexkeysWHERE

In-depth explanation of differences between fixed-length char (n) and variable-length varchar (n) in SQL Server

Char (n) is a fixed-length format. The field in the format of char (n) occupies a fixed width of n characters. If the actual length of the stored data exceeds n, the excess data is truncated, if the length is less than n, it will be filled with null

How to add, delete, and update data between two tables in the database

Create add, delete, and update triggers respectively to synchronize data between two tables.1: Data Synchronization increases:If there are two tables, table A and Table B, create A trigger to enable table B to insert data synchronously after Table A

Introduction to ISNULL functions in SQL

ISNULL Replace NULL with the specified replacement value. SyntaxISNULL (check_expression, replacement_value) ParametersCheck_expression Whether the expression is NULL is checked. Check_expression can be of any type. Replacement_value The expression

SQL2000 transaction rollback

Copy codeThe Code is as follows:Create procedure test_tranAsSet xact_abort on ----- judge by @ error. For serious errors, the system will not execute the subsequent judgment on @ error, and the execution will be terminated directly. Therefore, it is

Instance for SQL Server to obtain the returned values of Stored Procedures

1. OUPUT parameter Return Value Copy codeThe Code is as follows:Create procedure [dbo]. [nb_order_insert] (@ O_buyerid int,@ O_id bigint OUTPUT)ASBEGINSet nocount on;BEGINInsert into [Order] (o_buyerid)VALUES (@ o_buyerid)SET @ o_id = @

Detailed description of the task scheduling mechanism based on SQL Server OS

Introduction On Windows, SQL Server OS is a user-level operating system level used to serve SQL Server. It abstracts some functions of the operating system from the entire SQL Server engine and forms a separate layer to provide services for the

The sorting result of SQL Server is not desired.

In forums, people often ask such questions.:Why is the result set of the same query sometimes arranged in the desired order, sometimes not, or in the order of SQL2000, to SQL2005/2008?In fact, as long as "order by" is not specified in the statement,

How to delete dirty data in multiple tables with a cursor

Method 1: Copy codeThe Code is as follows: CREATE proc [dbo]. [delAllRecord]AsDeclare @ tableName nvarchar (255)Declare @ SQL nvarchar (255) Declare curTable CursorFor select Table_Name from information_schema.tables where TABLE_TYPE = 'base

Introduction to WINDOWS performance counters in sqlserver

Processer:% Processor Time Processor is busy with task execution Time threshold 80%, CPU bottlenecks, insufficient memory, low query plan reuse rate, unoptimized statements, and so on.SQLServer: Buffer ManagerBuffer cache hit ratio Adjust the

How does SQL SERVER determine whether a field contains uppercase letters?

SQL statements are case-insensitive by default, so the statement:SQL codeSELECT * FROM RecEngineBizInfo WHERE RecEngineBizName = 'qq'AndSQL codeSELECT * FROM RecEngineBizInfo WHERE RecEngineBizName = 'qq'The results are the same.The script to check

Introduction to basic functional statements of SQL Server

1 annotatorAnnotation is a text string that is not executed in the program code. It is a description of the program, which can improve the readability of the program and make the program code easier to maintain, it is usually embedded in a program

First day of SQL Study -- Understanding of SQL UNION and UNION ALL operators

SQL UNION operatorThe UNION operator is used to merge the result sets of two or more SELECT statements.Note::1. SELECT statements within UNION must have the same number of columns. Columns must also have similar data types. In addition, the columns

The first day of SQL Learning -- SQL defines variables as tables (Virtual tables)

SQL defines variables as the Table TypeWhen defining variables in SQL statements, we often define variables like char, varchar, nvarchar, int ........, so how to make a variable as a virtual table is actually very simple.Basic Syntax:Copy codeThe

SQL Server: Merge multiple rows into one row and perform grouping statistics.

Copy codeThe Code is as follows:-- Create a test table and insert dataCreate table test (code varchar (50), [values] varchar (10), [count] int)INSERT test SELECT '001', 'AA', 1Union all select '001', 'bb ', 2Union all select '002 ', 'aaa', 4Union

SQL query records

Take the first 20 to 30 queries as an example. The primary key name is id.Method 1: perform a regular check first and then perform a reverse check. Select top 10 * from (select top 30 * from tablename order by id asc) A order by id descMethod 2: Use

Input and Output Parameters in SQL Server Stored Procedures (simple instances can be understood at a Glance)

[SQL]-- ============================= [Create a stored procedure] ====================== ======USE [Message]GO/***** Object: StoredProcedure [dbo]. [read external database query] Script Date: 10/24/2012 05:39:16 ******/SET ANSI_NULLS ONGOSET

Total Pages: 923 1 .... 883 884 885 886 887 .... 923 Go to: GO

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.