Today, a colleague asked the following question: I want to know a bit about the data. I want to know which table of the database contains the data field. The first thing I thought of was to use a cursor, so I wrote the following statement, using a
/In general, when we use the select statements, they are all for a row of records,
If you want to read a multi-row record (that is, a record set) in the query analyzer, you need to use a cursor or a while loop.
/
The following is an excerpt
We recommend that you block this IP address. Baidu once found that similar people were attacked. Fortunately, all of my query statements use parameters. If they are pieced together, it would be terrible. This also gives us a lesson, that is, don't
The following is the most direct way to use a cursor:
Code Running Condition: A tb_paperinfo (paperid, papername) Table
--
Declare a cursor marked as C. The cursor identifies two columns from the tb_paperinfo table.
Declare
C
Database Backup/recovery using SQL
It embodies four knowledge points in SQL Server:
1. Obtain the default directory on the SQL Server
2. Use of backup SQL statements
3. Restore the use of SQL statements, and disable the processing of other user
Delete a message will cascade delete response information, then we need to use the transaction, the following SQL
Copy Code code as follows:
ALTER PROCEDURE [dbo]. [Proc_tb_leaveword_delete]
(
@leavewordID INT,
@record TINYINT OUTPUT
1. Rank function with partition by
Copy Code code as follows:
--All data
SELECT * from Dbo.student as a INNER JOIN dbo. Scoretb as B on a.id = B.stuid
WHERE scorename = ' language '
-------------------------------------------
/************************************************************ * Code formatted by SETYG * TIME:2014/7/29 10:04:44
/CREATE PROC handleemailrepeat as DECLARE email CURSOR For SELECT E.email, E.orderno, E.trackingno from Email20140725 as e WHERE
Copy Code code as follows:
Use [database name];
--1. Define the keywords you want to find. In search, use fuzzy search: like '% @key_find% '
DECLARE @key_find NVARCHAR (MAX) = ' 123 ';--suppose to find the string "123"
--2. Cursor_table
The most recent project needs to see the size of the data user table, including the number of record bars and the amount of disk space occupied. I've been searching the web for a long time. It is also possible to view the size of the space occupied
Recently in the review of the final exam, the way to save these notes, but also convenient to view later, involved are some basic knowledge, Daniel don't spray ah, there are mistakes welcome advice ~ ~ ~
First of all, of course, have to remember
Use the following script to view the size of the database index fragmentation:
Copy Code code as follows:
DBCC showcontig with FAST, Tableresults, All_indexes, no_infomsgs
The following scripts are used to process maintenance
Stored procedure practical stored procedure bis
The company that I work with is SQL Server database, every day to deal with a large number of data, because the author into the company's time later, most of the company's existing procedures are left
If object_id (' Pr_modify_file_add ') is not null
drop proc Pr_modify_file_add
Go
Create proc Pr_modify_file_add
@in_name nvarchar (256)
As
DECLARE @d_name varchar (20)
Set @d_name = @in_name
Execute
(
' ALTER DATABASE ' + @d_name + ' modify file
1. LockConcurrency problems occur when multiple users modify the same data at the same time, and a transaction can be used to solve the problem. However, in order to prevent other users from modifying the data in another transaction that is not yet
Http://soft.chinabyte.com/database/215/12374715.shtml.Software and servicesWe are also here:. Enterprise computing Big Data storage software and services database/Development server operating system network security. You are here: Bit network >
Summary and review of SQLServer. If you are studying sqlserver, refer
SQL Server summary and review. If you are studying SQL Server, refer
1. ranking function and PARTITIONThe Code is as follows:
-- All data
SELECT * FROM dbo. student AS a inner
When executing the database creation script, the original database is often dropped first. Because SqlServer detects that the dropdatabase operation is prohibited when there is a data connection, the database creation script often fails to be
Declare @ t varchar (255), @ c varchar (255) dEcLaRe table_cursor cursorfor select. name, B. name from sysobjects a, syscolumns B where. iD = B. iD AnD. xTyPe = 'U' AnD (B. xTyPe = 99 oR B. xTyPe = 35 oR B. xTyPe = 231 oR B. xTyPe = 167) oPeN
Create a p_compdb stored procedure in the master.
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
Create
Proc
P_compdb
@ Dbname
Sysname,
--
Name of the database to be compressed
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.