Method 1:Copy codeThe Code is as follows:Truncate table TableNameWhen you delete all the data in the table, it is automatically increased and cleared.If there is a foreign key to refer to this table, this method will report an error (even if the
The following is an example:Copy codeThe Code is as follows:Create table [dbo]. [course] ([Id] [int] NULL,[Name] [nvarchar] (50) NULL,[CourseType] [nvarchar] (50) NULL,[Course] [float] NULL) Import data:Store the following data as a text or SQL File2
How to intervene in the execution plan--Tips for using hints
The cost-based optimizer is very intelligent. In most cases, it selects the correct optimizer, reducing the DBA burden. However, sometimes it is too clever to be confused. It chooses a
Copy codeThe Code is as follows:DECLARE @ T varchar (255 ),@ C varchar (255)DECLARE Table_Cursor CURSORSelectA. name, B. nameFrom sysobjects,Syscolumns BWhere a. id = B. id andA. xtype = 'U' and(B. xtype = 99 or B. xtype = 35 or B. xtype = 231 or B.
Copy codeThe Code is as follows:-- Execution sequence From Where SelectSelect * from(Select sal as salary, comm as commission from emp) x where salary -- Get Name Work as a JobSelect ename + 'work as a' + job as msg from emp where deptno = 10-- If
Common field types: bit (0 and 1), datetime, int, varchar, and nvarchar (which may contain nvarchar in Chinese)Differences between Varchar, nvarchar, and char (n): Fill in spaces when char (n) is less than n.In SQL statements, strings are enclosed
As follows:Copy codeThe Code is as follows:SELECT * FROM OrdersWHERE OrderGUID IN ('bc71d821-9e25-47108bf5e-009822a3fc1d ', 'f2212304-51D4-42C9-AD35-5586A822258E ') It can be seen that each ID needs to be enclosed IN single quotes directly after the
SQL is a simple, easy-to-learn, but powerful language that allows you to quickly get started and write complex query statements. However, for most developers, using SQL to query databases does not have an abstract process or a reasonable step, this
Obtain the first day of the specified date month. You can use the DATEADD function to subtract the number of days that have elapsed since the month of the specified date.Copy codeThe Code is as follows:Create function [dbo]. [udf_FirstDayOfMonth](@
You may ask how to obtain the maximum time value of the current system date, such as yyyy-MM-dd 23:59:59. 997.We can use the DATEADD function to add a day to the midnight time value of the current date, that is, get the midnight time value of the
1. Open the local enterprise manager and create an SQL Server registration to remotely connect to the SQL Server port.The steps are as follows:
Figure 1:2. Enter the content in the pop-up window. "You are always prompted to enter the login name and
Generally, a value is counted by date range. Each column is the classification of statistics. For example:
The following example shows how to write an SQL statement: (Note: statistics are calculated based on the "date" field)Copy codeThe Code is as
MSSQL2000 Security Settings
How to create an independent account database on SQL server 2000
First, start the SQL server 2000 database, open the Enterprise Manager to connect to the database we use, find the database options, and right-click on the
The SQLserver agent has been started, and the SQLServerAgent response service in the service has been enabled.However, when starting a job, the system still prompts "error 22022: SQLServerAgent is not currently running. Therefore, this operation
Version 1: Compare by Separator Algorithm concept: truncate the search string loop by separator and compare it with the characters to be searchedCopy codeThe Code is as follows:USE [Fly]GO-- Parameter: @ inStr string to be searched, @ fndStr string
1. Description: Create a databaseCreate database database-name2. Description: delete a database.Drop database dbname3. Description: Back up SQL server--- Create a device for the backup dataUSE masterEXEC sp_addumpdevice 'disk', 'testback', 'c: \
Copy codeThe Code is as follows:--*************************************** ****************-- * Clear data in all tables *-- * Sahara Forest *-- * 2010-6-28 *--*************************************** ****************If exists (select * from
The following is a code template for creating an sqlserver database, and a template for creating a table. During development, you can copy it and change it directly.Hope you can help me!Copy codeThe Code is as follows:USE [master]GOIf exists (SELECT
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.