Sqlserver adds, modifies, deletes, and describes fields.

Copy codeThe Code is as follows:-- New table FieldALTER procedure [dbo]. [sp_Web_TableFiled_Insert](@ TableName varchar (100 ),@ FieldName varchar (100 ),FieldExplain varchar (200 ),@ DataType varchar (100 ),@ ConnectTableName varchar (100 ),@

One of the solutions to the maximum Id conflict problem of SQL Server databases

Copy codeThe Code is as follows:Create table [dbo]. [TbGuidTable] ([TableName] [varchar] (50) not null,[KeyName] [varchar] (20) not null,[KeyValue] [varchar] (100) NOT NULL) ON [PRIMARY]GOIf exists (select * from dbo. sysobjects where id = object_id

SQL Server database compression and Database Log (ldf) compression methods

AccessThe operation is very simple. The specific steps are as follows: Open your mdb database, tools> Database Utilities> compress and restore the database (c )...SQL SERVER In general, the contraction of the SQL database does not greatly reduce the

SQL statement exercise instance 2-find the sales champion

Copy codeThe Code is as follows:-- Sales champion-- Problem: in the company, the boss came in and asked for a report of the sales and sales staff of the top 3 sales in each region.---Create table salesdetail(Area int not null,Saler nvarchar (20) not

How to automatically generate numbers in a database

When using a database, it is inevitable that you delete it during use. If you use an int-type field to make it grow, this is the easiest way, but some of the consequences are not what you want! Take a look at this Demo: 1. create a simple table

SQL study notes seven function numbers, date, type conversion, null value processing, case

Numeric FunctionsABS (): returns the absolute value.CEILING (): round to the maximum integer.FLOOR (): round to the smallest integer.ROUND (): ROUND (A, B) A is the number to be processed, and B is the number of digits accurate to the decimal

SQL query entry (Part 1)

IntroductionIn the previous article (Introduction to SQL query (part I), I have explained the basic concepts of database query and Single Table query in detail. In this article, it mainly describes the various connections in SQL and the scope of use,

The identity field in the database does not need to be the unique value generated by the system. Performance Optimization Method (new trick)

However, fields with the identity feature do not need to be unique, not the primary key.Set identity_insert tablename (on | off) can be used to control whether a value can be specified in the identity field during runtime, rather than automatically

How to query the code of a consecutive date record in sqlserver

I saw a post on the Forum ,《How can I query records of consecutive dates?, As follows: Insus. NET tries to write a program and tests it to get the expected results. The SQL code can be used for reference and learning.Copy codeThe Code is as follows:-

How to delete and restore dangerous stored procedures of SQL Server databases

To implement the /"target =" _ blank "> SQLServer replication function today, many sqlserver s are deleted before, which may lead to expansion of insecure factors, as a result, many functions are unavailable and there is no way to restore the

How to obtain the number of days of a month in sqlserver

As follows:Copy codeThe Code is as follows:Create function [dbo]. [udf_DaysInMonth](@ Date DATETIME)RETURNS INTASBEGINDECLARE @ dim as table (m int, Dy INT)Insert into @ dim VALUES),),(2,Case when (YEAR (@ Date) % 4 = 0 and year (@ Date) % 100 <> 0)

SQL 2000 scheduled SQL statement execution

I don't know whether stored procedures can be implemented, but SQL Server 2000 Job Scheduling does have this function. How can I make some SQL statements run regularly and perform the following operations in sequence:Enterprise Manager-- Manage--

Differences between variables assigned by SELECT and SET in SQL Server Stored Procedures

SET instead of SELECT is recommended for SQL Server.When the expression returns a value and assigns a value to a variable, the SET method is recommended.The following table lists the differences between SET and SELECT. Pay special attention to the

Example of creating a linked server in sqlserver

1. Expand the Server Object --> link server --> right-click "new link server"Note: You must log on as a database administrator (usually the sa account) before creating a "linked server" 2. Enter the IP address of the linked server 3. Set the

Code for batch data insertion using SQL

Copy codeThe Code is as follows:DECLARE @ MyCounter INTSET @ MyCounter = 0/* SET variable */WHILE (@ MyCounter BEGINWaitfor delay '000: 00: 10'/* DELAY Time: 10 seconds */Insert into time_by_day(Time_id, the_date, the_year, month_of_year, quarter,

SQL Server Functions, stored procedures, cursors, and transaction templates

1. scalar function: the result is a single value that can contain a logical processing process. Uncertain System functions such as getdate () cannot be used.Copy codeThe Code is as follows:-- Scalar Value Function-- ==================================

Clear all Table Record IDs in the database and restore from 0

1. Search all table names and construct an SQL statement.Copy codeThe Code is as follows:Declare @ trun_name varchar (8000)Set @ trun_name =''Select @ trun_name = @ trun_name + 'truncate table' + [name] + ''from sysobjects where xtype = 'U' and

Deadlock description in SQLServer

A typical example of A deadlock between two processes is: Obtain lock A in process T1 and apply for lock B; obtain lock B in process T2 and apply for lock A. Here we will demonstrate this situation: 1. Create a Database named InvDB. 2. Execute the

SQL Server optimizes SQL statements in and not in

However, the SQL Performance with IN is always relatively low. The SQL Execution steps are used to analyze the differences between SQL with IN and SQL without IN:SQL tries to convert it to the join of multiple tables. If the conversion fails, it

Use of Local SQL Server Variables

A. Use DECLARE The following example uses a local variable named @ find to retrieve information of all authors whose names start with a Ring.Copy codeThe Code is as follows:Use pubsDeclare @ find varchar (30)Set @ find = 'ring %'Select au_lname,

Total Pages: 923 1 .... 695 696 697 698 699 .... 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.