1. query table name in SQL Server 2000
I often encounter situations where I forget the table name. I only remember the approximate one. At this time, I can query the system table Sysobjects to find the expected table name. For example, I want to
The column names do not have to be the same. As long as you list the columns to be inserted in HH and the selected columns in the select from mm table one-to-one correspondence, of course, the Data Types on both sides should be compatible.Insert
Scenario:
Recently, a DB Server occasionally experienced CPU alarms. My mail alarm threshold (please read y threshold) is set to 15%. It didn't take the case at the beginning. I thought it was a statistical query, later, it became more and more
SQL Server write a function to obtain the Chinese pinyin code (first letter)
Create function fun_getPY (@ str nvarchar (4000 ))
Returns nvarchar (4000)
As
Begin
Declare @ word nchar (1), @ PY nvarchar (4000)
Set @ PY =''
While len (@ str)>
CTE statement structure and CTE recursive query in SQL SERVER
CTE statement Structure
A common table expression (CTE) can be considered as a temporary result set defined within the execution range of a single SELECT, INSERT, UPDATE, DELETE, or
1. SQL statistics, which may be inaccurate after a large number of transaction operations
Exec sp_spaceused 'table name'
2. Accurate tablespace size, but it may take some time for Statistics
Exec sp_spaceused 'table name', true
3. database size
Problem description:
At work, there will always be some such situations from time to time. The program running on development or QA is always good, but the program cannot run in the production environment. I was impressed by the two web projects
Use the custom ADO. NET class MyDBase to connect to the SQL Server database
Using System;
Using System. Data;
Using System. Data. SqlClient;
Public class MyDBase
{
Bool ECode = false;
String ES;
SqlConnection cn = new System. Data. SqlClient.
1. Check database integrityCopy codeThe Code is as follows: dbcc checkdb (test)-- Increase the speed by adding tablockDbcc checkdb (test) with tablock2. Rename the database, modify the recovery mode, and modify the user mode.Copy codeThe Code is as
Restore database
Enterprise Manager
-- Right-click "Database"
-- All tasks
-- Restore database
-- Enter the restored database name in "Restore to Database"
-- Restore select "from device" -- select device -- add your backup file -- OK, and return to
First, create a table and insert a data statement:
Use Student
Go
Create table Score
(
Student ID nvarchar (10 ),
Nvarchar (10 ),
Score int
)
Go
Insert into Score values ('123', 'China', 87 );
Insert into Score values ('123', 'mat', 79 );
Insert
Obtains, adds, modifies, and deletes sqlserver field descriptions.
Select o. name AS tableName, c. name AS columnName, p. [value] AS Description
FROM sysproperties p INNER JOIN
Sysobjects o ON o. id = p. id INNER JOIN
Syscolumns c ON p. id = c. id
Recently, I helped the school to set up a score entry system, which has the following task requirements:
Requirement Description:
There are three tables:
1. You can find all students corresponding to the course in the web_inputCj_cjb table based on
I. Four Conditions for deadlock
1. Mutual exclusion: resources cannot be shared and can only be used by one process.
2. Hold and wait: processes that have obtained resources can apply for new resources again.
3. No pre-emption: allocated resources
(1 ). With the advent of the big data era, data plays an increasingly important role in our lives, and our dependence on data is growing. Therefore, it is a very important technology to learn and master database knowledge and design and develop
1. sort by strokes of the Last Name:
Select * From TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
2. database encryption:
Select encrypt ('original password ')
Select pwdencrypt ('original password ')
Select pwdcompare ('original
In a select statement, only SQL functions can be used to operate fields (link to SQL server ),
Select Field 1 from table 1 where field 1. IndexOf ("Cloud") = 1;
This statement is incorrect because the indexof () function is not an SQL function. You
-- All tables containing the hospital ID field
Select a. [name] from sysobjects,
(
Select [id], count (*) B from syscolumns
Where [name] = 'column1'
Group by [id]
)
B where a. [id] = B. [id] order by a. name asc
-- All tables that contain
Today, I want to copy a database under SQL server2005. The result is an error in the last step. If the replication fails, the database cannot be opened,
The "single user" is displayed after the name. It is estimated that it is automatically changed
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.