Questions tagged [adventureworks]

A sample SQL database for SQL Server, maintained by Microsoft.

The sample database for . AdventureWorks is maintained by Microsoft and is updated to reflect new features of .

http://msftdbprodsamples.codeplex.com/

220 questions
20
votes
7 answers

Permissions error when attaching a database: "Cannot access the specified path"

I am running SQL Server 2012 Enterprise Edition. I have downloaded the AdventureWorks 2012 OLTP data files (both .mdf and .ldf). I saved them to the AW folder that I created in My Documents where I unzipped the file. I go to SQL Server Management…
user2151027
  • 203
  • 1
  • 3
  • 5
12
votes
2 answers

Does AdventureWorks db have tutorials / exercises?

I downloaded and installed AdventureWorks db for sql server 2008. Are there any exercises or tutorials for it? I'd like to to practice SQL select statements
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
12
votes
3 answers

Adventure Works Explanation

I've been looking at Microsoft's Adventure Works 2012 database. I'd be very interested if there's any information explaining why the tables were created as they are. Some sort of schema overview I guess. For example: Why they chose to create a…
user1705507
  • 145
  • 1
  • 2
  • 7
7
votes
2 answers

SQL AdventureWorks count employees by gender by city

I want to count the cities by gender, like this; City GenderFCount GenderMCount Redmond 10 20 Here is my query gets city and gender in AdventureWorks database select Gender,City from HumanResources.Employee as t1 inner join…
qods
  • 177
  • 1
  • 3
  • 12
7
votes
2 answers

Where to download AdventureWorks2008.msi?

I'd like to install AdventureWorks2008 (I just install SQL Server 2008 R2 Express). Each time I download the recommended version from CodePlex, all I get is a AdventureWorks2008.mdf file. Not only I cannot attach the file from SQL Server Management…
Richard77
  • 20,343
  • 46
  • 150
  • 252
5
votes
2 answers

MDX Filter expression understanding

Am having trouble in understanding how FILTER function works in MDX. Here is my query which gets all the non-empty Internet Order Count values for all Sales Territory Countries across all the Calendar Years. SELECT NON EMPTY { …
VKarthik
  • 1,379
  • 2
  • 15
  • 30
4
votes
3 answers

Invalid column name with RANK OVER function SQL

Attempting to create a table with the total quantity sold by product and select the third highest quantity sold product segmented by date. Keep getting error Invalid Column name for the alias for my RANK () OVER statement: select RANK () OVER…
4
votes
1 answer

How can I combine two select statements into one table with two seperate columns?

New to SQL, using MS SQL Sever Management Studio with AdventureWorks sample DB: http://elsasoft.com/samples/sqlserver_adventureworks/sqlserver.spring.katmai.adventureworks/default.htm Trying to combine two SELECT statements each containing a COUNT…
BT93
  • 329
  • 2
  • 9
  • 25
4
votes
1 answer

Query to get 5 million records from Adventure works

I am generating a flat file from SQL Server and I want to have around 3-5 million records for that. Can someone give me a query which I can run on Adventure works to get 3-5 million records? I am looking from adventure works because it has…
Zerotoinfinity
  • 6,290
  • 32
  • 130
  • 206
4
votes
0 answers

How BusinessEntityContact is mapped with BusinessEntity, Contact and Person in AdventureWorks2008R2 database

How BusinessEntityContact is mapped with BusinessEntity, Contact and Person in AdventureWorks2008R2 database I had a brainstorming on this to get how it is related. I queried BusinessEntityContact with Store, Person, Customer and I didn't understood…
Shantanu Gupta
  • 20,688
  • 54
  • 182
  • 286
3
votes
1 answer

Based on territory, get the top customers and their total sales in percentage

Using adventureworks database. I am stuck with top 5 customers based on the territory. How can we get the output for this in the given format? SELECT TOP 5 CustomerID ,oh.TerritoryID ,Name ,SUM(TotalDue) / ( SELECT…
porsh01
  • 95
  • 13
3
votes
2 answers

Find product id of the top selling product of each day, using total sold quantity to determine the top selling product

Adventureworks2008R2 database. The result I want is each day the MaxQantity sold, for example, OrderDate 2007-09-01 shall have the max quantity of 96 only, but my query gives me 3 different results from the same day, maybe because it is considering…
porsh01
  • 95
  • 13
3
votes
1 answer

NONEMPTY and CROSSJOIN performance and order in MDX

I was wondering which of the following two queries is more performant? Query 1: SELECT NONEMPTY(CROSSJOIN({[Product].[Category].children}, {[Scenario].[Scenario].members} ) ) ON…
elvainch
  • 1,369
  • 3
  • 15
  • 32
3
votes
6 answers

In T-SQL how to display columns for given table name?

I am trying to list all of the columns from whichever Adventureworks table I choose. What T-sQL statement or stored proc can I execute to see this list of all columns? I want to use my C# web app to input one input parameter = table_name and then…
salvationishere
  • 3,461
  • 29
  • 104
  • 143
2
votes
1 answer

How to replace ' from the select query

In SQL Server, I have this query SELECT DISTINCT City FROM Person.Address But this gives me two cities which has name like Ville De'anjou (i.e. ') you can try the same by this SELECT DISTINCT City FROM Person.Address WHERE City like…
Zerotoinfinity
  • 6,290
  • 32
  • 130
  • 206
1
2 3
14 15