First we need to download available SQL2000SampleDb.msi file from this location Northwind and Pubs Sample Database 2. Once we download SQL2000SampleDb.msi file right click on that and install it like. AFAIK the download of the Northwind MS Access database isn't any longer available. Click the Download button and save the SQL2000SampleDb.msi file to a local folder on your computer. After the download has finished, double-click the SQL2000SampleDb.msi file to begin the installation process. The installation process installs the Northwind and pubs database files (.mdf and.ldf files) in the following folder.
This article describes how to dynamically rank rows when you perform a SELECT statement by using a flexible method, which may be the only possible solution and which is faster than the procedural solution. Row numbering or ranking is a typical procedural issue. The solutions are typically based on loops and temporary tables; therefore, they are based on SQL Server loops and cursors. This technique is based on an auto join. The chosen relationship is typically 'is greater than.' Count how many times each element of a particular set of data fulfills the relationship 'is greater than' when the set is compared to itself.Note The following examples are based on the pubs database. By default, the Northwind sample database and the pubs sample database are not installed in SQL Server 2005. These databases can be downloaded from the Microsoft Download Center. For more information, visit the following Microsoft Web site:
If you are using SQL Server 2005
We recommend that you use ranking functions that are provided as a new feature in SQL Server 2005. For more information about the ranking functions, visit the following Microsoft Developer Network (MSDN) Web site:Example 1
In this example:- Set 1 is authors.
- Set 2 is authors.
- The relationship is 'last and first names are greater than.'
- You can avoid the duplicate problem by comparing the first + last names to the other first + last names.
- Count the number of times the relationship is fulfilled by count(*).
Example 2
In this example:- Rank stores by the number of books sold.
- Set 1 is the number of books sold by store: select stor_id, qty=sum(qty) from sales group by stor_id.
- Set 2 is the number of books sold by store: select stor_id, qty=sum(qty) from sales group by stor_id.
- The relationship is 'the number of books is greater than.'
- To avoid duplicates, you can (as an example) compare price*qty instead of qty.
Use the following code in SQL Server 2005.Result: Note In SQL Server 2005, you can receive the correct result of the ranking and the quantity when you use the ranking functions.
Example 3
In this example:- Rank the publishers by their earnings.
- Set 1 is the total sales by publisher:
- Set 2 is the total sales by publisher:
- The relationship is 'earns more money than.'
Use the following code in SQL Server 2005. Result: Note You receive the correct result of the ranking and the earning when you use the ranking functions.
Drawbacks
- Because of the cross join, this is not designed for working with a large number of rows. It works well for hundreds of rows. On large tables, make sure to use an index to avoid large scans.
- This does not work well with duplicate values. When you compare duplicate values, discontinuous row numbering occurs. If this is not the behavior that you want, you can avoid it by hiding the rank column when you insert the result in a spreadsheet; use the spreadsheet numbering instead.
Note If you are using SQL Server 2005, you can use the row_number() function to return the sequential number of a row, regardless of the duplicate rows.
Benefits
- You can use these queries in views and result formatting.
- You can shift the lower-ranked data more to the right.
Example 2: Query: Result: Use the following code in SQL Server 2005.Result: Dec 1, 2007
Sql2000sampledb Msi Download Free
Hi all,
I downloaded the Northwind database install script (SQL2000SampleDb.msi) and ran instnwnd.sql in my SQL Server Management Studio Express. I got the following error messages:
Msg 5105, Level 16, State 2, Line 1
A file activation error occurred. The physical file name 'northwnd.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
Msg 1802, Level 16, State 1, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Msg 15010, Level 16, State 1, Procedure sp_dboption, Line 64
The database 'Northwind' does not exist. Use sp_helpdb to show available databases.
Msg 15010, Level 16, State 1, Procedure sp_dboption, Line 64
The database 'Northwind' does not exist. Use sp_helpdb to show available databases.
Msg 911, Level 16, State 1, Line 1
Could not locate entry in sysdatabases for database 'Northwind'. No entry found with that name. Make sure that the name is entered correctly.
Msg 3726, Level 16, State 1, Line 2
Could not drop object 'dbo.Customers' because it is referenced by a FOREIGN KEY constraint.
Msg 3726, Level 16, State 1, Line 2
Could not drop object 'dbo.Employees' because it is referenced by a FOREIGN KEY constraint.
Msg 2714, Level 16, State 6, Line 1
There is already an object named 'Employees' in the database.
Msg 1913, Level 16, State 1, Line 1
The operation failed because an index or statistics with name 'LastName' already exists on table 'dbo.Employees'.
Msg 1913, Level 16, State 1, Line 1
The operation failed because an index or statistics with name 'PostalCode' already exists on table 'dbo.Employees'.
Msg 2714, Level 16, State 6, Line 1
There is already an object named 'Customers' in the database.
Msg 1913, Level 16, State 1, Line 1
The operation failed because an index or statistics with name 'City' already exists on table 'dbo.Customers'.
Msg 1913, Level 16, State 1, Line 1
The operation failed because an index or statistics with name 'CompanyName' already exists on table 'dbo.Customers'.
Msg 1913, Level 16, State 1, Line 1
The operation failed because an index or statistics with name 'PostalCode' already exists on table 'dbo.Customers'.
Msg 1913, Level 16, State 1, Line 1
The operation failed because an index or statistics with name 'Region' already exists on table 'dbo.Customers'.
(1 row(s) affected)
............................................etc.
Please help and advise me how to get the Northwind database installed in my SQL Server Management Studio Express.
Thanks in advance,
Scott Chang