How to Use SQLserver to delete all tables in a database

It is convenient to delete all data tables in the database and clear the database. There are some constraints that cannot be deleted directly. You need to delete the constraints in the database first. The Code is as follows:Copy codeThe Code is as

SQL Server misunderstanding: About 27th days using BACKUP WITH CHECKSUM can replace DBCC CheckDB

Misunderstanding #27: Using BACKUP... with checksum can replace DBCC CheckDBErrorAt first glance, because backup with checksum will detect the CHECKSUM values of all allocated pages, this misunderstanding seems to be the case, but in fact it is not

How to convert the date format using the convert function in SQLserver

The default datetime format of the Chinese version of SQL Server is yyyy-mm-dd Thh: mm: ss. mmm.For example:Select getdate ()I sorted out the date format conversion methods that may be frequently used in SQL Server:Example:Select CONVERT (varchar,

Sqlldr data loading implementation code

Here we use excel Data for the simplest test.1) Save the excel data as a t.txt file. Note that the file suffix is. txt. 1 jhchen 11/07/2005 20:04:00 2005-11-7 20:042 jhchen 11/07/2005 20:04:00 2005-11-7 20:043 jhchen 11/07/2005 20:04:00 2005-11-7 20:

So that SQL users can only view their own databases (Graphic tutorial)

Take SQL Server 2012 as an Example Is part of the database, we executeCopy codeThe Code is as follows:Deny view any DATABASE to PUBLIC;Then run the command for the Best user of the Best database.Copy codeThe Code is as follows:Alter authorization

Several stored procedures created by SQL

Create a stored procedureYou can store table names and comparison fields as parameters.Create PROCEDURE sp_getTeacherInfo@ TblName nvarchar (30), -- table name@ CmpStr nvarchar (30), -- value used for comparison@ Tblasd nvarchar (30) -- fields

SQL Method for retrieving data between two values (for example, data between and)

Question: retrieve data between 100 and 200 entries in a tableMethod 1: temporary tableCopy codeThe Code is as follows:Select top 200 * into # aa from table order by time -- Insert the top m pen into the temporary tableSet rowcount 100Select * from #

SQL repeat record troubleshooting methods

1. Search for duplicate records① If you just don't want repeated records in the query results, you can add DistinctSelect distinct * from TestTable② If You Want to query repeated records and their quantity Select UserID, UserName, count (*) as

Difference between drop, truncate and delete

Note: The delete statement is a delete statement without the where clause.SimilaritiesTruncate, delete without where clause, and drop both delete table data.Differences:1. truncate and delete: delete only data. Do not delete the table structure

SQLServer manage common SQL statements

1. view the database versionSelect @ version2. view the operating system parameters of the machine where the database is locatedExec master .. xp_msver3. view database startup parametersSp_configure4. view the database startup timeSelect convert

SQL Server union, cube, rollup, and cumpute Operators

/*-- 1 the UNION operator combines two or more query results into a single result set.There are two basic rules for query result sets using UNION:1. The columns and columns in all queries must be in the same order.2. Data type must be compatibleA.

Five basic operations on SQL Server XML data

1. xml. existIf the input is an XQuery expression, 0, 1 or Null is returned. 0 indicates no, 1 indicates yes, and Null indicates that the input is Null.2. xml. valueThe input is an XQuery expression and returns an SQL Server scalar value.3. xml.

Fuzzy match string generated in SQL

If exists (select * from dbo. sysobjects where id = object_id (n' [dbo]. [f_ SQL] ') and xtype in (n'fn', n'if', n'tf '))Drop function [dbo]. [f_ SQL]GOIf exists (select * from dbo. sysobjects where id = object_id (n' [ordinal table] ') and

Very good SQL statement learning manual instance version 1/3 page

Table operationsExample 1 Table STUDENTS in the table teaching management database can be defined as follows: Copy codeThe Code is as follows:Create table students (sno numeric (6, 0) NOT NULLSname char (8) NOT NULLAge numeric (3, 0)Sex char

Exquisite SQL statements

Note: copy a table (only copy structure, source table name: a new table name: B)Select * into B from a where 1 <> 1 Description: copy a table (copy data, source table name: a target table name: B)Insert into B (a, B, c) select d, e, f from B;

SQL connection Query

The connection can be established in the FROM clause or Where clause of the Select statement. It is similar that it helps to distinguish the connection operation FROM the search conditions in the Where clause when the clause points out the

Resolution: Clear SQL statements injected with malicious virus code

Run the following code in the SQL query analyzer.Copy codeThe Code is as follows:Declare @ t varchar (255), @ c varchar (255)Declare table_cursor cursor for select a. name, B. nameFrom sysobjects a, syscolumns B, policypes cWhere a. id = B. id and a.

Query whether the Replace keyword contains a specific string

In SQL server, the Replace keyword is mainly used to Replace a character in a string with another character. Today, we need to reverse thinking. It can also be used to query whether a specific string is contained, for example, given the following

Restoration Technology for MDF files in SQL Server

First, place the file to be restored in the DATA file in ms SQL, and enter the ms SQL master database server.1. We use the default method to create a database for recovery (such as MHDYF2005 ). It can be created in SQL Server.2. Stop the database

Complete syntax and parameter description of various triggers in SQL SERVER

Syntax: Trigger on an INSERT, UPDATE, or DELETE statement to a table or view (DML Trigger)CREATE TRIGGER [ schema_name . ]trigger_name ON { table | view } [ WITH [ ,...n ] ]{ FOR | AFTER | INSTEAD OF } { [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ]

Total Pages: 923 1 .... 844 845 846 847 848 .... 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.