declare @n int
set @n = 10
select TOP(@n) * from Orders
select * from(select OrderId, Freight, ROW_NUMBER() OVER(order by Freight) as row from Orders) a
where row between 20 and 30
select * from(select OrderId, Freight, RANK() OVER(order by Freight) as rank from Orders) a
where rank between 20 and 30
SET XACT_ABORT ON -- 打開 try功能
BEGIN TRY
begin tran
insert into Orders(CustomerId) values(-1)
commit tran
print 'commited'
END TRY
BEGIN CATCH
rollback
print 'rolled back'
END CATCH
WITH OrderFreight AS(
select OrderId, Freight, ROW_NUMBER() OVER(order by Freight) as row from Orders
)
select OrderId, Freight from OrderFreight where row between 10 and 20
--DataSet CustOrdersOrders(string customerID)
CREATE ENDPOINT Orders_Endpoint
state=started
as http(
path='/sql/orders',
AUTHENTICATION=(INTEGRATED),
ports=(clear)
)
for soap(
WebMethod 'CustOrdersOrders'(
name='Northwind.dbo.CustOrdersOrders'
),
wsdl=default,
database='Northwind',
namespace='http://mysite.org/'
)
關鍵詞: