When using tables in a database, we often encounter two ways to use tables: using temporary tables and table variables. In actual use, how can we flexibly use them in the stored procedure? Although they implement the same functions, in a stored procedure, how does one sometimes use temporary tables instead of table variables, and sometimes use table variables ins
Document directory
Difference between Schema and user
Supplement
Schema in SQL Server
We know the database, as its name implies. the most important thing is data management, and data is stored in tables in the system. Therefore, almost all the mechanisms and operations in the database are centered around the table. the importance of tables can be imagined.
in loss of some data.2. DBCC checktableIf the DBCC CHECKDB check still has errors, you can use DBCC CHECKTABLE to fix them.Use the name of the database entity that needs to be repairedDECLARE @dbname varchar (255)Set @dbname = ' Name of the database entity to be repaired 'exec sp_dboption @dbname, ' Single user ', ' true 'DBCC CHECKTABLE (' name of the data table to be repaired ', repair_allow_data_loss)DBCC CHECKTABLE (' name of the data
Label:SQL Server Basics (1) Create a database There are two ways to create a database, manually create and write SQL script creation, where I use a script to create a database called TSQLFundamentals2008. The script is as follows: View Code While inserting some data into the database table, the user follows the SQL pr
Original: Oracle\ms SQL Server Update Multiple Table association updateA single update UPDATE statement is not able to update multiple tables unless you use triggers to suppress updates. In the update operation of the table, in many cases, you need to refer to data other than the t
Lock a table in a database
SELECT * from table with (HOLDLOCK)
Note: The difference between a table that locks a database
SELECT * from table with (HOLDLOCK)
Other transactions can read the table, but cannot update the deletion
SELECT * from
(*) from syscolumnsWhere id = (select id from sysobjects where type = 'U' and name = 'your table name ')And name = 'field name to be judged'A small example-- Assume that the table to be processed is named tb.-- Determines whether the table to be added has a primary key.If exists (select 1 from sysobjects where parent_obj = object_id ('tb') and xtype = 'pk ')Begi
Recently, I used a SQL Server cache to increase the data volume by a day and receive queries from customers. The speed is getting slower and slower as the data volume grows.
Review Frequently Used Indexes
I. Clustered Index
The page level of the clustered index includes the index key and data page. Therefore, the answer to what the leaf level of the clustered index stores besides the key value is ev
Author: drillchina, source: blog, responsible editor: Li shuqin, in SQL Server performance tuning, there is an incomparable problem: that is, how to take a long time
Code Or are temporary datasets processed in frequently called code? Table variables and temporary tables are two options.
In SQL
SQL server database creation, table creation, and creation Constraints
The following describes SQL server database creation, table creation, and constraints.
-- Before creating the School database: first, determine whether the dat
In the previous article, du Fei introduced the page types of SQL Server data files, the system manages the table's storage structure logically Based on the 96-byte header information and the system table.
In the previous article, du Fei introduced the page types of SQL Server
:.. From B in
"server.mappath (". ") "\data.mdb" "where."
24. Create a Database
CREATE DATABASE Database-name
25. Note: Delete database
Drop Database dbname
26. Note: Back up SQL Server
---Create
Device of Backup data
Use master
EXEC sp_addumpdevice disk, Testback,
C:\mssql7backup\MyNwind_1.dat
---start Backup
BACKUP DATABASE pubs to Testback
27. Note: Create a new
1, the vertical table to the horizontal table
Vertical table Structure Table_a:
Converted structure:
SQL example for vertical table to horizontal table:
SELECT Name,
sum (case when Course = n ' language ' THEN Grade
EL
Oracle|sql server|access Database Tutorial All table names, field names
SELECT * FROM user_tables WHERE table_name = ' username '
Use the following statement if you are logged on with this user:SELECT *From User_tables;If you are using another user:SELECT * from All_tables WHERE owner= ' user_name 'First, the first sentence: is the query of the user under all t
I. Clustered IndexThe page level of the clustered index includes the index key and data page. Therefore, the answer to what the leaf level of the clustered index stores besides the key value is everything, that is, all fields in each row are in the leaf level.Another talk is that data itself is part of the clustered index, which maintains the Data Order in the table based on the key value.In SQL
I. Clustered Index
The page level of the clustered index includes the index key and data page. Therefore, the answer to what the leaf level of the clustered index stores besides the key value is everything, that is, all fields in each row are in the leaf level.Another talk is that data itself is part of the clustered index, which maintains the Data Order in the table based on the key value.In SQL
Table expressionTable expressions do not have any physical instantiation, they are virtual when querying table expressions, internal queries are non-nested, in other words, external queries and internal queries are merged directly into a query of an underlying object, and the benefits of using table expressions are often related to the logical aspects of the code
partition table in SQL Server 2005 (iv): Delete (merge) a partitionCategory: SQL Server2009-12-04 09:10 8735 People read comments (0) favorite reports SQL Server2010functionmerge Storage DatabaseIn the previous section we described how to create and use a partitioned
) '
Exec sp_executesql @Str, N ' @WokNo Varchar () output ', @WokNo output
Select @WokNo, @i--a line to display the employee number
Set @i = @i + 1 principle If a local temporary table is created by a stored procedure or by an application that is executed concurrently by multiple users, SQL Server must be able to differentiate between tables
When single-table data is too long. We can divide the level, the SQL Server partitioned view to achieve a horizontal table, horizontal division can improve some of the performance of the table.The vertical sub-table is relatively rare to see and use, because this may be a da
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.