易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL SERVER 2005 高级查询(子查询查询)

--SQL高级程序设计:子查询
use AdventureWorks
GO
SELECT DISTINCT EmployeeID from HumanResources.JobCandidate WHERE EmployeeID IS NOT NULL;
SELECT e.EmployeeID,FirstName,LastName
from HumanResources.Employee e
INNER JOIN Person.Contact c
 ON e.ContactID = c.ContactID
WHERE e.EmployeeID IN (SELECT DISTINCT EmployeeID from HumanResources.JobCandidate
      WHERE EmployeeID IS NOT NULL)
SELECT DISTINCT EmployeeID from HumanResources.JobCandidate WHERE EmployeeID IS NOT NULL
SELECT e.EmployeeID,FirstName,LastName
from HumanResources.Employee e
INNER JOIN Person.Contact c
 ON e.ContactID = c.ContactID
WHERE e.EmployeeID NOT IN (
       SELECT DISTINCT EmployeeID
       from HumanResources.JobCandidate
       WHERE EmployeeID IS NOT NULL
       )
SELECT CustomerID,MIN((OrderDate)) AS OrderDate
INTO #MinOrderDates
from Sales.SalesOrderHeader
GROUP BY CustomerID
ORDER BY CustomerID
SELECT o.CustomerID,o.SalesOrderID,o.OrderDate
from Sales.SalesOrderHeader o
inner join #MinOrderDates t
 on o.CustomerID = t.CustomerID
 and o.OrderDate = t.OrderDate
order by o.CustomerID
DROP TABLE #MinOrderHeaders
SELECT O1.CustomerID,o1.SalesOrderID,o1.OrderDate
from Sales.SalesOrderHeader o1
WHERE o1.OrderDate = (SELECT MIN(o2.OrderDate)
      from Sales.SalesOrderHeader o2
      WHERE O2.CustomerID = o1.CustomerID)
ORDER BY CustomerID
SELECT c.LastName,ISNULL(CAST((SELECT MIN(OrderDate) from Sales.SalesOrderHeader o
     WHERE o.ContactID = c.ContactID) AS VARCHAR),'NEVER RECORD') AS "Order Date"
from Person.Contact c
SELECT e.EmployeeID,FirstName,LastName
from HumanResources.Employee e
INNER JOIN Person.Contact c
 ON e.ContactID = c.ContactID
WHERE EXISTS(SELECT DISTI


相关文档:

[收拢] 用sqlite 执行标准 sql 语法

http://www.umgr.com/blog/PostView.aspx?bpId=36294
 1. 执行sql语句
int sqlite3_exec(sqlite3*, const char *sql, sqlite3_callbacksql 语法
, void *,  char **errmsg );
这就是执行一条 sql 语句的函数。
第1个参数不再说了,是前面open函数得到的指针。说了是关键数据结构。
第2个参数const char ......

SQL数据库

1.      存储过程(定义&编写)
l  创建存储过程
CREATE PROCEDURE storedproc1
AS
SELECT *
from tb_project
WHERE  预计工期<= 90
ORDER BY  预计工期 DESC
GO
exec storedproc1
GO
 
l   修改存储过程
ALTER PROCEDURE storedproc1
AS
SEL ......

sql总结

1.创建数据库
    --exec xp_cmdshell 'mkdir d:\project'--调用DOS命令创建文件夹,使用此句需要启动SQL的外围工具
    if exists(select * from sysdatabases where name='数据库名')
     drop database 数据库名
    set nocount on   ......

SQL 连接字符串的说明


转自:http://hi.baidu.com/arslong/blog/item/b23307e76252342cb8382001.html
Item01
连接字符串中常用的声明有:
服务器声明:Data Source
、Server
和Addr
等。
数据库声明:Initial Catalog
和DataBase
等。
集成Windows
账号的安全性声明:Integrated
Security
和Trusted_Connection
等。
使用数据库 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号