# Friday, September 11, 2009

When SQL Data Services (now SQL Azure) released its first CTP it did not look anything like SQL Server: there were no tables, stored procedures, views, etc. With the new CTP, SQL Azure embraces SQL Server in the sky and supports the relational model, including stored procedures. This is good since there are millions of lines of stored procedures out there in production today and migrating them to SQL Azure is pretty easy.

I decided to give a simple stored procedure a test drive. I opened up SQL Management Studio, started a new query, entered in my SQL:

   1:  CREATE Procedure sel_CustomerOrder   
   2:  @CustomerID char(5)   
   3:  AS
   4:  SELECT o.OrderID, o.OrderDate,  p.ProductName,   
   5:       (od.UnitPrice*od.Quantity)-((od.UnitPrice*od.Quantity)*od.Discount) as TotalCost   
   6:  FROM orders o   
   7:       inner join [order details] od   
   8:              on o.OrderID=od.OrderID  
   9:       inner join products p  
  10:              on od.ProductID=p.ProductId  
  11:  WHERE CustomerID=@CustomerID
  12:  ORDER BY o.OrderID

 

I hit F5 and all was right with the world. So I decided to try it out:

Exec sel_CustomerOrder @CustomerID='ALFKI'

And got the expected results.

image

You can now use this stored procedure in all the applications that you connect to since SQL Azure supports standard ADO.NET connection strings. Pretty cool.

Comments are closed.