Copy codeThe Code is as follows:DECLARE cur CURSORSELECT[Object_name] = s. name + '.' + OBJECT_NAME (A. object_id ),B. nameFROM sys. dm_db_index_physical_stats (DB_ID ('adventureworks'), NULL, null, null) ASJOIN sys. indexes AS BOn a. [object_id] =
I tried some methods provided on the Internet and finally solved some problems with SQL.1. Select the database in the query analyzer and enter:Exec sp_configure 'Allow updates', 1 -- allow updating system tables.RECONFIGURE WITH OVERRIDE2. Run the
You can delete duplicate records in the following ways:For example, table name: dbo. Description $. The fields include ID_PK, breed name, traits standard number, and code. First, create a table with the same structure as the original table:Copy
The problem is as follows:There is an INSERT trigger on table T1. when data is inserted, a record is automatically inserted into Table T2.In this way, when I insert new data into Table T1 and obtain @ IDENTITY, the returned id value is the value of
It is said that this statement works: select top 5 * from tablename order by newid ()I put it in the SQL query analyzer to execute it. It really works. I randomly extract 5 pieces of information and keep changing it. As a result, I don't need to use
The reason for these problems is that the database is damaged or the index is incomplete.In ACCESS, there is a function to fix the database to solve this problem. In SQL Enterprise Manager, this function is not available and should be completed
1. Clear all tables in the database Copy codeThe Code is as follows:DECLARE @ tablename varchar (50)DECLARE @ truncatesql varchar (255)DECLARE TrCun_Cursor CURSORSelect [name] from sysobjects where type = 'U'-- Conditional table name clearing <>
1. display the column name in the query results: A. Use the as Keyword: select name as 'name' from students order by ageB. Direct representation: select name 'name' from students order by age2. Exact search:A. Use in to specify the range: select *
Declare @ I intSet @ I = 'A'Set @ I = cast ('A' as int)Set @ I = convert (int, 'A ')Print @ I-- Syntax error occurs when the varchar value 'a' is converted to an int column. This is different from java.
Declare @ ch varchar (90)Set @ ch = 97Print @
Originally, the program runs normally. Sometimes some exceptions may occur because the user's excel document is not in the required format. I thought the same was true this time. After reading the data, I did not find any exceptions, and I did some
Outer Join. Outer Join can be left Outer Join, right outer join, or complete external join.When an external join is specified in the FROM clause, it can be specified by one of the following sets of keywords:Left join or left outer join.The result
Tools and Database Maintenance Planner in Enterprise Manager can set Regular automatic backup schedules for databases. Start the SQL server Agent to automatically run the backup plan. The procedure is as follows:1. Open the Enterprise Manager and
1. What are primary keys and Foreign keys:A record in a relational database has several attributes. If one of the attribute groups (note that it is a group) uniquely identifies a record, the attribute group can become a primary key, for
This article demonstrates the complete full-text index of the SQL SERVER database. The pubs database is used as an example.The following describes how to create a full-text index using the system stored procedure:1) Start the full-text processing
SQL SERVER calculates the distance according to the latitude and longitude of the map.Copy codeThe Code is as follows:Go-- Create a latitude and longitude distance calculation functionCREATEFUNCTION [dbo]. [fnGetDistance]-- LatBegin start longitude--
Table types can be used in Stored Procedures for batch addition.Table type definition:Copy codeThe Code is as follows:Create type dbo. SubCardTable as table([SC _ID] [varchar] (50 ),[ZhuKaInfo_ID] [varchar] (50 ),[Project_KeyName] [varchar] (50
A few days ago, I found that the query on the website is abnormal. Generally, the content of the first-level directory is queried first, and the second-level directory is queried after I click the first-level directory ...... Until the bottom file
However, I think this function is also useful for setting backup servers or testing servers,
Publishing Services on one machine can be subscribed to in the SQL statements of other machines. Depending on your publishing conditions, you can publish
/* Stored Procedure */Sp_databases -- list all databases on the serverSp_server_info -- list server information, such as character set, version, and orderSp_stored_procedures -- list all stored procedures in the current environmentSp_tables -- list
Webmasters who use MSSQL will be admired by the ability of the MSSQL database to eat memory. After a small website runs for several days, MSSQL will eat up all the memory on the server, at this time, you have to restart the server or MSSQL to
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.