Here's an example of how to use the row_number() function which became available in SQL Server 2005.
Click here for a detailed description of the syntax.
Click here for a Google search on this topic.
Run this script against the AdventureWorks sample database in SQL Server 2005. See how the row_number() function numbers the line items per sales order:
select
SalesOrderNumber,
LineItemNo = row_number() over(partition by SalesOrderNumber order by SalesOrderDetailID),
Product = p.Name,
OrderQty,
UnitPrice,
UnitPriceDiscount,
LineTotal
from
Sales.SalesOrderHeader h
inner join
Sales.SalesOrderDetail d
on
d.SalesOrderID = h.SalesOrderID
inner join
Production.Product p
on
p.ProductID = d.ProductID
To keep track of favourite web sites, useful links, articles and own experiences which may be helpful in future software development.
Wednesday, April 23, 2008
Friday, April 18, 2008
Using LINQ to SQL
Scott Guthrie posted a series of excellent articles about LINQ to SQL on his blog. Here they are:
- Part 1: Introduction to LINQ to SQL
- Part 2: Defining our Data Model Classes
- Part 3: Querying our Database
- Part 4: Updating our Database
- Part 5: Binding UI using the ASP:LinqDataSource Control
- Part 6: Retrieving Data Using Stored Procedures
- Part 7: Updating our Database using Stored Procedures
- Part 8: Executing Custom SQL Expressions
- Part 9: Using a Custom LINQ Expression with the <asp:linqdatasource> control
Tuesday, April 1, 2008
Choosing Between SQL Server Compact 3.5 and SQL Server 2005 Express Edition
SQL Server Compact 3.5 and SQL Server 2005 Express Edition are basically the same thing - or are they?!
See the following article and white paper from Microsoft which will guide you when having to choose between these two editions of SQL Server.
Download SQL Server Compact 3.5
Download SQL Server 2005 Express Edition
See the following article and white paper from Microsoft which will guide you when having to choose between these two editions of SQL Server.
Download SQL Server Compact 3.5
Download SQL Server 2005 Express Edition
Subscribe to:
Posts (Atom)
SQL Server
- 101 Things I wish you knew about SQL Server
- 102 SQL Server 2005 Tutorials and Articles
- Audit Trails and Logging Part 1 (sqlservercentral.com)
- Audit Trails and Logging Part 2 (sqlservercentral.com)
- Audit data using SQL Server 2005's COLUMNS_UPDATED function
- Calling a web service from a CLR proc
- Choosing between SQL Server Compact 3.5 and SQL Server 2005 Express Edition
- Deploying Database Developments
- Download SQL Server 2005 Express Edition
- Download SQL Server Compact 3.5
- How to return a result set from a SQL Server 2005 CLR stored procedure (mssqltips.com)
- How to return a result set from a SQL Server 2005 CLR stored procedure (mssqltips.com)
- Online Training (sqlservercentral.com)
- SQL Server 2008 Transparent Data Encryption getting started (MSSQLTips.com)
- SQL Server Audit in SQL Server 2008 – Part 1 (Database Journal)
- SQL Server Data Structure
- SQL Server Indexes: The Basics
- T-SQL Enhancement - APPLY Join Operator (drsql)
- T-SQL Ranking Functions (MSDN)
- T-SQL: Calendar tables
- T-SQL: Correlated Joins Using "Apply" (sqlservercentral.com)
- T-SQL: Identify Modified Columns in a Trigger (SQL Server Magazine)
- T-SQL: Identity Columns (simple-talk)
- T-SQL: More with SQL Server 2005 : Top n Per Group, Paging, and Common Table Expressions
- T-SQL: Obtaining Data as XML from SQL Server (MSDN)
- T-SQL: SQL Server 2005 Programmability Enhancements — Common Table Expressions (codeguru)
- T-SQL: SQL Server 2005: Creating User-defined Functions (Database Engine) (MSDN)
- T-SQL: SQL Server: JOIN vs IN vs EXISTS - the logical difference
- T-SQL: The "Numbers" or "Tally" Table: What it is and how it replaces a loop.
- T-SQL: The Curse and Blessings of Dynamic SQL
- T-SQL: The ultimate guide to the datetime datatypes
- T-SQL: Understanding SQL 2005's new PIVOT clause
- T-SQL: Use Dynamic SQL to Improve Query Performance
- T-SQL: Using the OUTPUT clause for practical SQL Server applications
- T-SQL: What's New in FOR XML in Microsoft SQL Server 2005 (MSDN)
- TechNet: Improving Performance with SQL Server 2005 Indexed Views
- The Truth about "Cursor Busting" in SQL
- Thinking Set-Based .... or not?
- Upgrading a Database SQL 2000 to SQL 2005 (sqlservercentral.com)
DTS and SSIS
- Download SQL Server 2005 DTS add-in
- Dynamically Generate Folders for File Output using Variables in SSIS (sqlservercentral.com)
- How to create an XML config file for a SSIS package
- SQL Server Integration Services (SSIS), ETLs and Best Practices (Brian's Blog)
- Transactions in SQL Server 2005 Integration Services