Calculate the balance

A netizen asked that in SQL, the balance of each transaction should be calculated. His screenshot Description:     To achieve this function, the key is to obtain the value of the eqty field of the previous record. Next, Insus.NET tries to write it. The easiest way to do this is to loop through each record. Then you can calculate qty plus ...

Posted on Wed, 01 Jan 2020 17:27:54 -0500 by benracer

Query database history

In the SQL Server database, most of the operations that have been done since the login and what has happened in the database can be traced, but some of them can't be traced. 1, Database start record 1. Last time SQL Server was started select sqlserver_start_time from sys.dm_os_sys_info; --You can also refer to the creation time of the s ...

Posted on Sat, 28 Dec 2019 11:35:16 -0500 by binto

Automatic backup of stored procedure code

First, create the tables ProcSqlTable and BackProcSqlTable under the master database. ProcSqlTable stores the current version code of stored procedure, and BackProcSqlTable stores the historical version code. USE [master] GO CREATE TABLE [dbo].[BackProcSqlTable]( [id] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY ,--number [dbName] [nvarcha ...

Posted on Mon, 23 Dec 2019 12:44:01 -0500 by dbchip2000

Specified index of SQL Server Performance Optimization

Background: the SQL statement query in the production environment is too slow (the total data is about 3.5 million), and the log center keeps alarming Solution: after analyzing the failure, turn to the DBA of the company. After analyzing the DBA, it is recommended to specify the index in the statement Solution: specify the index in the SQL st ...

Posted on Thu, 12 Dec 2019 09:46:05 -0500 by Thresher

Yii2.0 calls sql server stored procedure and gets return value

1. First, it shows the statement of creating sql server stored procedure, creating a simple stored procedure for testing. 1 SET ANSI_NULLS ON 2 GO 3 SET QUOTED_IDENTIFIER ON 4 GO 5 6 CREATE PROCEDURE [dbo].[register_info] 7 @name varchar(50), 8 @sex char(1), 9 @idcard char(30), 10 @phone varchar(15), 11 ...

Posted on Sun, 08 Dec 2019 10:24:25 -0500 by readourlines

Nodejs operation Sql Server

Intro Recently, the project needs to crawl some data, the data is encrypted, the front-end js is confused, the ajax request is hook, some complex, and finally plans to use puppeter to crawl the data. Puppeter is a project that the Google team is maintaining. The original intention is mainly to do automatic testing of web pages. The official Hea ...

Posted on Wed, 04 Dec 2019 11:45:18 -0500 by breadcom

Three data table de duplication methods of MSSQL SQL Server

Abstract: Three different data De duplication methods will be shared belowData De duplication: it needs to be defined according to a certain field. When there is more than one line of records in this field, we define that there are duplicates in this line of data. Data De duplication method 1: When the maximum SN is in the table, we can get ...

Posted on Mon, 02 Dec 2019 01:35:04 -0500 by PandaFi

The same and different points of SELECT and SET assignment in SQL SERVER

SELECT and SET can be used to assign values to variables in SQL SERVER, but their usage and effect are different in some details. 1. In terms of variable assignment, SET is the ANSI standard assignment method, while SELECT is not. This is one of the reasons why SET is recommended. 2. SELECT can assign multiple variables at one time, while SET c ...

Posted on Mon, 02 Dec 2019 00:12:37 -0500 by Daggeth

SQL server stored procedure self made data dictionary

I believe that many of my friends have a headache about data dictionary. When the editor first joined the company, the eldest one left a project and came back with a design document. The data dictionary and the field description are all available, It all depends on "context". So you must form the habit of explaining fields. After expl ...

Posted on Sun, 01 Dec 2019 09:23:56 -0500 by penguin_powered

Summary of some common statements in SQL Server database

21. Reading of SQL running Log . EXEC xp_readerrorlog 0,1,null,null, 'start time', 'end time' 22. Alwayson status and transmission monitoring SELECT ar.replica_server_name AS [Copy name] , ar.availability_mode_desc as [Synchronization mode], DB_NAME(dbr.database_id) AS [Database name] , dbr.database_state_desc AS ...

Posted on Sat, 23 Nov 2019 14:29:01 -0500 by JayVee