Table creation and modification of table structure we're not going to talk about it here, mainly talking about query statements and some common statements.
--Update the statement operation, the main thing to explain is that in front of the Chinese characters better add N to prevent garbled
set username=n' genius summer rain 'where id=5
--Add a new statement and get his primary key ID immediately (this is used a lot, such as restaurant management)
Insert into Values (' xiayu222 ', ' ewdfdf ', ' 172.1.1.0'@ @IDENTITY
--query statement is very powerful, almost can look for anything
--Querying SQL Server version
Select as version
--Query Date
Select GETDATE () as Date
Now let's focus on the query statement.
--Query for eligible records
Select *fromwhere username=' summer rain '
--Query the operation after the table is sorted (order by)
Select * from Gb_data order by Createdate,username
The--order by statement must be placed behind the where statement (otherwise there will be an error---syntax errors near the keyword ' where '. )
Select *fromwhere username=' summer rain ' ORDER by CreateDate
--fuzzy query with the LIKE keyword, _ represents a character,% represents more than one character
Select *fromwhere'% rain%'
Select *from gb_data where username like ' _ Rain% '
Note: null means "Do not know", NULL participates in an operation structure that is generally null, query data is NULL, cannot be used =,! =, use the IS keyword
--query data in a range can be used in the keyword
Select from where inch (+)
Collation of common SQL statements--sql Server 2008 (query one)