Let's take a look at the following examples:
Table tables
Field 1 Field 2ID Name1 A2 b3 C4 C5 b
The library structure is probably like this, this is just a simple example, the actual situation will be much more complicated.
For example, I would
Copy Code code as follows:
--Member Table
If object_id (' UserInfo ', ' u ') is not null
drop table UserInfo
Go
CREATE TABLE userinfo (userid int primary key,user_tegral int,level int)
Insert INTO UserInfo Select 1,0,0
Go
--Membership
version One: comparing by separator
Algorithm idea: Intercept the search string loop by separator and compare the characters to be searched
Copy Code code as follows:
Use [Fly]
Go
--Parameters: @inStr to search strings, @fndStr
Create DATABASE Myindexdemo
Go
Use Myindexdemo
Go
CREATE TABLE ABC
(
A int NOT NULL,
B Char (10),
C varchar (10)
)
Go
INSERT INTO ABC
Select 1, ' B ', ' C '
Union
Select 5, ' B ', ' C '
Union
Select 7, ' B ', ' C '
Union
Select 9, ' B ', ' C
Copy Code code as follows:
Using System.Data;
Using System.Diagnostics;
Using System.Data.SqlClient;
String connectionString = "Data source=hg-j3ejj9lsw5py;initial catalog=test; User ID=SA;PASSWORD=HG ";
DataTable datatable =
Clustered index: Physical storage sorted by indexNonclustered indexes: Physical storage is not sorted by indexAdvantages and DisadvantagesClustered index: Slow to insert data (time spent on "sort of physical storage", which is first to locate and
Suppose there is a student score table (TB) as follows:
Name Subject Result
John Language 74
John Math 83
John Physics 93
Dick Language 74
Dick Math 84
Dick Physics 94
Want to become
Name Chinese mathematics Physics
---------- ----------- ----------
Instead of the bool type in SQL Server, a bit type is used to represent the bool value, presumably to conserve storage space.
However, to achieve the reverse operation seems to be troublesome to write, such as the following statements are not
E Packing directory Create a new Excel file Aa.xls and test the following code
Copy Code code as follows:
Use tempdb
Go
if (object_id (' udf_getexceltablenames ') is not null)
Drop function dbo. udf_getexceltablenames
Go
Create
SELECT * FROM table name where Convert (varchar (100), Date field, 23) = ' 2008-12-15 '
And I'll give you the application of the CONVERT function:
Copy Code code as follows:
Select CONVERT (varchar), GETDATE (), 0): 2006 10:57am
There are several treatments for the result set that are worth explaining
1. and set (Union,union all)This is very simple, is to combine two result set level. For example
SELECT * from AUNIONSELECT * from BNote Union deletes duplicate values,
I don't know if the stored procedure can be implemented, but the job scheduler for SQL Server 2000 does have the ability to make certain SQL statements run at regular intervals, and then do the following:Enterprise Manager--Management--sql Server
Two Tables Organizational structure table (organise) and payroll history Sheet (wagepermonthhis)
Two tables are associated by organise.item_id and Wagepermonthhis.orgids
Organise table (hereinafter referred to as O table) about 6,000 records in 11
1 annotation CharactersNote refers to the program code does not execute the text string, is a description of the program, you can improve the readability of the program, so that the program code easier to maintain, generally embedded in the program
BeginThis is last year's problem, today in the mail to find this problem, feel the top interesting, special record down.
In table Relationgraph, there are three fields (Id,node,relatednode), where node and relatednode two fields describe the
in the Forum, people often ask questions like :
The result set of the same query is sometimes arranged in the order he wants, sometimes not, or in the order of the SQL2000, and in that order of sql2005/2008?
As a matter of fact, SQL Server does
Several main situations are summarized:
First, how to enter a null valueIf you do not enter a null value, when the time is empty, the default is written to "1900-01-01", which is cumbersome for business processing.
Ctrl+0 You can enter a null
Copy Code code as follows:
--SQL Server 2000
SELECT a.name As field name, case when EXISTS
(SELECT 1
From sysobjects
WHERE xtype = ' PK ' and parent_obj = a.id and name in
(SELECT name
From sysindexes
WHERE Indid in
(SELECT indid
From
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.