SQL SERVER 2005 基本查询(连接查询)
2009-10-24 18:53
357 查看
use AdventureWorks GO SELECT c.LastName FROM Person.Contact c; SELECT * FROM HumanResources.Employee e INNER JOIN HumanResources.Employee m ON e.ManagerID = m.EmployeeID; n SELECT ProductID,Name,ProductNumber,ReorderPoint from Production.Product where ProductID in( select ProductID from Production.Product where ProductID in (1,2,3) ) if EXISTS( select ProductID from Production.Product where ProductID in (1,2,3) ) PRINT 'TRUE' ELSE PRINT 'FALSE' SELECT e.EmployeeID,ce.FirstName,ce.LastName FROM HumanResources.Employee e INNER JOIN HumanResources.Employee m ON e.ManagerID = m.EmployeeID INNER JOIN Person.Contact ce ON e.ContactID = ce.ContactID INNER JOIN Person.Contact cm ON m.ContactID = cm.ContactID WHERE cm.FirstName = 'Jo' and cm.LastName = 'Brown'; Select SalesOrderID,SUM(OrderQty) as sum from Sales.SalesOrderDetail where SalesOrderID between 43684 and 43686 group by SalesOrderID having SUM(OrderQty) > 5 create table UserInfor ( UserID int not null, FirstName nvarchar(50), LastName nvarchar(50) ) GO ALTER TABLE UserInfor add primary key (UserID) INSERT INTO UserInfor(UserID,FirstName,LastName) SELECT e.EmployeeID,ce.FirstName,ce.LastName FROM HumanResources.Employee e INNER JOIN HumanResources.Employee m ON e.ManagerID = m.EmployeeID INNER JOIN Person.Contact ce ON e.ContactID = ce.ContactID INNER JOIN Person.Contact cm ON m.ContactID = cm.ContactID WHERE cm.FirstName = 'Jo' and cm.LastName = 'Brown'; declare @MyTable table ( SalesOrderID int, CustomerID int ) INSERT INTO @MyTable(SalesOrderID,CustomerID) select SalesOrderID,CustomerID from AdventureWorks.Sales.SalesOrderHeader where SalesOrderId between 50222 and 50225 select * from @MyTable create table Shippers ( ShipperID int identity not null primary key, ShipperName varchar(30) not null, Address varchar(20) not null, City varchar(25) not null, State char(2) not null, Zip varchar(14) not null, PhoneNo varchar(14) not null UNIQUE ) alter table HumanResources.Employees add CONSTRAINT AK_EmployeeSSN UNIQUE(SSN)
相关文章推荐
- 在SQL Server 2005中连接Oracle,完成查询、插入操作
- 数据库开发基本操作-SQL Server 2005 不允许远程连接解决方法
- 在SQL Server 2005中连接Oracle,完成查询、插入操作
- sql server 2005中查询一个数据库中的基本信息
- sql server 2005建立数据库,表,约束,账户密码,权限,基本查询删除语句
- Visual C# 2008+SQL Server 2005 数据库与网络开发--11.2.2 LINQ的基本查询操作
- SQL Server 2005技术内幕:查询、调整和优化3——连接
- SQL Server 2005技术内幕:查询、调整和优化3——连接
- 在SQL Server 2005中连接Oracle,完成查询、插入操作
- 在SQL Server 2005中连接Oracle,完成查询、插入操作
- java连接数据库(SQL Server、MySQL、Oracle)及基本查询
- 在SQL Server 2005中连接Oracle,完成查询、插入操作
- SQL Server 2005 不允许远程连接的解决方法
- sql server 2005 连接总结
- 在Eclipse中用JDBC连接Sql Server 2005总结
- WIN 2003 Server配置SQL Server 2005远程连接体验
- sql server 查询所有表的字段的详细信息的存储过程(在 SQL Server 2005 中查询表结构及索引 )
- SQL Server 2005架构中的一些基本概念模型
- SQL SERVER 查询作业(Job)基本信息及执行情况的sql
- 黄聪:win7 下使用sql管理器连接sql server 2005方法大全(如果18452/18456错误,必看)