易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

批量修改SQL数据库字段值

正确的修改方法:sql批量修改字段内容的语句
1、没试过,网上搜索的

引用
update '表名' set 要修改字段名 = replace (要修改字段名,'被替换的特定字符','替换成的字符')
2、自己按照一个一个修改是看数据表总结的
例如偶修改自己博客boblog_replies表中的adminrepid和adminreplier字段值:
UPDATE `xxx`.`boblog_ ......

SQL 数据库之一

1.      SELECT
实例105
SELECT ID "编号",Name 姓名,
       Math_Score '数学成绩',  //怎么有的有AS,有的没有
       Music_Score AS 音乐成绩,
       English_Score AS 英文成绩
f ......

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 ......

oracle数据库导入到sql server2005

引用:http://blog.csdn.net/wizardlun/archive/2009/09/08/4531576.aspx
今天,终于把oracle中的数据库导入到sql server中了,方法如下:
  一、在sql server中建个同名数据库,例如ssdb。
  二、右键点击ssdb,选择“所有任务”——>“导入数据”,就会弹出一个“DTS ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号