SELECT
INSERT
DELETE
UPDATE
CREATE TABLE
DROP TABLE
ALTER TABLE
CREATE VIEW
DROP VIEW
CREATE INDEX
DROP INDEX
CREATE PROCEDURE
DROP PROCEDURE
CREATE TRIGGER
DROP TRIGGER
CREATE SCHEMA
DROP SCHEMA
CREATE DOMAIN
ALTER DOMAIN
DROP DOMAIN
GRANT
DENY
REVOKE
COMMIT
ROLLBACK
SET TRANSACTION
DECLARE
EXPLAN
OPEN
FETCH
CLOSE
PREPARE
EXECUTE
DESCRIBE
declare @id char(
select @id =
declare @x int @y int @z int
select @x =
if @x > @y
print
else if @y > @z
print
else print
use pangu
update employee
set e_wage =
case
when job_level = ’
when job_level = ’
when job_level = ’
else e_wage*
end
declare @x int @y int @c int
select @x =
while @x <
begin
print @x
while @y <
begin
select @c =
print @c
select @y = @y +
end
select @x = @x +
select @y =
end
waitfor delay ’
select * from employee
waitfor time ’
select * from employee
***SELECT***
select *(列名) from table_name(表名) where column_name operator value
ex:(宿主)
select * from stock_information where stockid = str(nid)
stockname =
stockname like
stockname like
stockname like
or stockpath =
or stocknumber <
and stockindex =
not stock*** =
stocknumber between
stocknumber in(
order by stockid desc(asc)
order by
stockname = (select stockname from stock_information where stockid =
select *from table
where table
table
select stockname from table
union [all]
select stockname from table
***insert***
insert into table_name (Stock_name
value (select Stockname
***update***
update table_name set Stockname = "xxx" [where Stockid =
Stockname = default
Stockname = null
Stocknumber = Stockname +
***delete***
delete from table_name where Stockid =
truncate table_name
drop table table_name
***alter table***
alter table database
sp_help table_name
create table table_name (name char(
insert into table_name select
alter table table_name drop constraint Stockname_default
AVG
COUNT
MAX
MIN
SUM
use pangu
select avg(e_wage) as dept_avgWage
from employee
group by dept_id
use pangu
select e_name
from employee
where e_wage =
(select max(e_wage)
from employee)
DAY()
MONTH()
YEAR()
DATEADD(
DATEDIFF(
DATENAME(
DATEPART(
GETDATE()
APP_NAME()
COALESCE()
COL_LENGTH(<
COL_NAME(
DATALENGTH()
DB_ID([
DB_NAME(database_id)
HOST_ID()
HOST_NAME()
IDENTITY([
ISDATE()
ISNULL(
ISNUMERIC()
NEWID()
NULLIF(
From:http://tw.wingwit.com/Article/program/SQLServer/201311/22273.html