Showing posts with label databases. Show all posts
Showing posts with label databases. Show all posts

Friday, March 23, 2012

Getting Started SQL 2005

Can anyone help with REAL Fast Track links to Getting Started with SQL 2005 DB Design? I have loads of ideas on implementing databases but I'm stuck on where exactly to start from. No prior DB or programming experience but I possess remarkable aptitude.

>>No prior DB or programming experience but I possess remarkable aptitude

LOL - gotta love confidence.

Well, your first step is almost always a good book. I can't recommend any, the books I bought were SQL for programmers. You should read some beginner books on SQL and database design, and work from there. Remember, you can't do anything with a database unless you learn to drive a tool like Access, a programming language such as C#, or you're happy to type SQL directly into SQL Server for all your queries/inserts/updates.

|||Thanks a lot. Always 'knew' that the best way to start would be yo push Access to its limits. Hope using VB (2005) isn't a bad choice for a programming language. Figured I should start with VB before delving into C#. Once again, thanks a lot cos I'm darn serious about this .NET developer track. Resources on VB & C# programming are most welcome. Huge task ahead but I guess the 1st step is getting started!

Wednesday, March 21, 2012

Getting sample databases in Management Studio

How to get sample database AdventureWorks and AdventureWorksDW
deployed in Management Studio. I selected to install sample database
entire feature on my local hard drive and I can see it did installed all
the .mdf,.ldf,.dim,.cube and the rest in
C:\Program Files\Microsoft SQL Server\90\Tools\Samples\

How can I get the database in Management studio.
I tried to use Attach db and it didn't worked, gave me following error

Msg 1813, Level 16, State 2, Line 1

Could not open new database 'AdventureWorks'. CREATE DATABASE is aborted.

Msg 602, Level 21, State 50, Line 1

Could not find row in sysindexes for database ID 8, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.

Any help would be appreciated.

Here is a link to a msi to install the database

http://www.microsoft.com/downloads/info.aspx?na=46&p=1&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=8D5BDE68-4991-432A-9D4B-0562DC49992E&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f4%2fb%2fc%2f4bc19fa4-5849-46a6-bebb-c22493d219e8%2fAdventureWorksDB.msi&oRef=http%3a%2f%2flab.msdn.microsoft.com%2fexpress%2fsql%2fdefault.aspx|||I installed using the above link but I am unable to see the AdventureWorks db
in the Management studio under database tree.

After the installation do I need to configure something?
|||hi Ken,

This is link to Adventure Works DB. Do you have link to Adventure Works DW msi?|||Sorry I cant find a link.

Here is some better instructions on how to install the adventure works db
http://download.microsoft.com/download/2/a/a/2aaa56bc-a173-4263-af15-e9421a14d5f8/SQLServerExpressSamplesOverview.htm|||If the sample databases were installed correctly, the .mdf and .ldf files for both AdventureWorks and AdventureWorksDW would be located in this folder
<drive>:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data not the folder you reference in your post. And you shouldn't have to attach the databases; the installation process performs the attach operation by default. However, it sounds like that didn't happen, so as an alternative you can re-create the databases by using the installation scripts.

The install script (instawdb.sql) for AdventureWorks should be located in
Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks OLTP
and the install script (instawdwdb.sql) for AdventureWorksDW should be located in
Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks Data Warehouse.

You can run these scripts to re-create the sample databases. Please read the Books Online topic "Reinstalling Sample Databases from Script " for detailed instructions on how to do this. You must modify one statement in both scripts to point to the correct location of the .csv (raw data) files. This is explained in the topic.

Regards,
|||

In the vs2005 documentation there are excellent walkthroughs for asp.net 2.0. Someone overlooked that only AdventureWorks comes with it. Several of the walkthroughs want Northwind and Pubs.

I deleted those when I uninstalled sqlserver 2000. Where can I download them and how would I install them in sqlserver 2005?

Thanks in advance.

dennist685

|||You can download them here

http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46a0-8da2-eebc53a68034&DisplayLang=en|||As Ken points out, these databases are available for download. The readme that is included in the download provides instructions for installing the databases. The instructions assume you have SQL Server 2000, but they are essentially the same for SQL Server 2005. You have two choices: attach the databases or run the installation scripts.

Regards,|||gaile,

I'm having the same problem as the original poster (same error). The .msi file installs but the database is not attached. Does it make a difference that I am using the Demo version of SQL 2005? The folder you mention does not exist (Program Files\Microsoft SQL Server\90\Tools\Samples <- there is no samples folder).|||

I need some more information please.
Which database are you trying to install?

If it's AdventureWorks or AdventureWorksDW, did you follow the instructions in the Books Online topic "Running Setup to Install AdventureWorks Sample Databases and Samples ", or did you download the msi from the web?

If you downloaded the msi, you need to manually attach the database. The process for doing this is described in the readme file that is included in the download.

What version of SQL Server 2005 do you have installed?
Thanks,

|||"Which database are you trying to install?"

Both AdventureWorks and AdventureWorksDW.

"...did you follow the instructions in the Books Online topic "Running Setup to Install AdventureWorks Sample Databases and Samples ", or did you download the msi from the web?"

I downloaded the msi. Thanks for the suggestion though. I looked up that topic in Books Online and it seems I'm getting a bit further... however, once I try to execute the script as per the instructions, I get tons of errors. Here's a few of the early errors:

Oh, and version of SQL is SQL 2005 Enterprise I believe (the demo only comes in one version). http://www.microsoft.com/sql/downloads/default.mspx


*** Dropping Database
Msg 208, Level 16, State 1, Line 2
Invalid object name 'master.sys.databases'.

*** Creating Database
Msg 208, Level 16, State 1, Line 6
Invalid object name 'master.sys.master_files'.

Msg 102, Level 15, State 6, Line 11
Incorrect syntax near 'CHECKSUM'.

Msg 911, Level 16, State 1, Line 2
Could not locate entry in sysdatabases for database 'AdventureWorks'. No entry found with that name. Make sure that the name is entered correctly.

|||once I try to execute the script as per the instructions, I get tons of errors.

What script are you running? There's nothing in the topic "Running Setup to Install AdventureWorks Sample Databases and Samples" about running a script. Look for the section "To install the sample databases and samples after setup" in the topic and see if you can get those steps to work.

Regards,|||

Here's how far I get following the "To install the sample databases and samples after setup"

4. From Feature Selection, expand the Books Online and Samples node.

There is no "Books Online and Samples" node. There is a "Client Components" and a "Documentation, Samples, and Sample Databases" node. I select the latter.

5. Select Samples.

There is no "Samples", but there is a "Sample Databases" node. I select it.

6. Expand Databases and then select the sample databases to be installed. Click Next.

At this point there is 2 nodes, "Adventureworks Sample OLTP" and "AdventureworksDW Sample Warehouse". Beneath the latter there is another node "Adventureworks Sample OLAP". All nodes are already solid White, as in they are already installed to my computer due to previous efforts.

7. To install and attach the sample databases, from Sample Databases Setup, select Attach sample databases and click Next.

I don't get this option. After clicking next, the wizard goes into it's install routine.

The database files are created and stored in the folder n:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data. The database is attached and ready for use.

I do now have an AdventureWorksDW database in this folder, and it is attached. However, the tutorial refers to an AdventureWorks (not DW) database, and I in-fact do not have any of the tables refered to in the tutorial, such as the first one I come across - Production.Product.

8. To install the sample database files without attaching, from Sample Databases Setup, select Install sample databases and click Next.

As Above, I do not have this option.

8. Complete the steps in the wizard.

9. To complete the installation of the samples, after Setup, perform one of the following steps:

10. From the Start menu, click All Programs, click Microsoft SQL Server 2005, click Documentation and Tutorials, click Samples, and then click Microsoft SQL Server 2005 Samples.

11. Alternatively, using Windows Explorer, navigate to n:\Program Files\Microsoft SQL Server\90\Tools\Samples\ and double-click SqlServerSamples.msi to launch the installer.

Tried these steps too, the SqlServerSamples.msi (also on the Program menu) is there and it runs, it just doesn't DO anything apparently!

It appears to me that the help files contained in "Books Online" is not concurrent with the present release of SQL Server 2005. The tutorial databases are not possible to install under the current instructions.

|||Thanks for your patience on this. I really appreciate it. Your information tells me that (for some unknown reason) setup thinks the sample databases have been installed, and it's ignoring the request to install them. We've seen this before and have opened a bug with setup, but it's been hard to reproduce.

Let's look at a couple of alternatives. In your original post, you said you ran the download, but the databases didn't attach. The download does not automatically attach the files, but this should mean that you actually have the .mdf and .ldf files available for attaching.

Please look in the <drive:>\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data folder for the files AdventureWorks_data.mdf and/or AdventureWorksDW_Data.mdf.

If you have these files, then you just need to attach the databases. You can do this from SQL Server Management Studio, or by running the following statements.

execsp_attach_db @.dbname=N'AdventureWorks', @.filename1=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf', @.filename2=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_log.ldf';

execsp_attach_db @.dbname=N'AdventureWorksDW', @.filename1=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorksDW_Data.mdf', @.filename2=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorksDW_log.ldf';

If you do not have these files, then you can download the sample databases again.
http://www.microsoft.com/downloads/details.aspx?familyid=e719ecf7-9f46-4312-af89-6ad8702e4e6e&displaylang=en

If you do the download again, please follow the instructions for removing previous installations of the sample databases described in http://download.microsoft.com/download/d/8/6/d865cf0c-c44b-401b-b426-b3bf5c628112/SQLServerDatabasesAndSamplesOverview.htm. I know this seems unnecessary, but it won't hurt your system and could help.

Again, thanks for your perseverance.

Regards,sql

Getting sample databases in Management Studio

How to get sample database AdventureWorks and AdventureWorksDW
deployed in Management Studio. I selected to install sample database
entire feature on my local hard drive and I can see it did installed all
the .mdf,.ldf,.dim,.cube and the rest in
C:\Program Files\Microsoft SQL Server\90\Tools\Samples\

How can I get the database in Management studio.
I tried to use Attach db and it didn't worked, gave me following error

Msg 1813, Level 16, State 2, Line 1

Could not open new database 'AdventureWorks'. CREATE DATABASE is aborted.

Msg 602, Level 21, State 50, Line 1

Could not find row in sysindexes for database ID 8, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.

Any help would be appreciated.

Here is a link to a msi to install the database

http://www.microsoft.com/downloads/info.aspx?na=46&p=1&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=8D5BDE68-4991-432A-9D4B-0562DC49992E&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f4%2fb%2fc%2f4bc19fa4-5849-46a6-bebb-c22493d219e8%2fAdventureWorksDB.msi&oRef=http%3a%2f%2flab.msdn.microsoft.com%2fexpress%2fsql%2fdefault.aspx|||I installed using the above link but I am unable to see the AdventureWorks db
in the Management studio under database tree.

After the installation do I need to configure something?
|||hi Ken,

This is link to Adventure Works DB. Do you have link to Adventure Works DW msi?|||Sorry I cant find a link.

Here is some better instructions on how to install the adventure works db
http://download.microsoft.com/download/2/a/a/2aaa56bc-a173-4263-af15-e9421a14d5f8/SQLServerExpressSamplesOverview.htm|||If the sample databases were installed correctly, the .mdf and .ldf files for both AdventureWorks and AdventureWorksDW would be located in this folder
<drive>:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data not the folder you reference in your post. And you shouldn't have to attach the databases; the installation process performs the attach operation by default. However, it sounds like that didn't happen, so as an alternative you can re-create the databases by using the installation scripts.

The install script (instawdb.sql) for AdventureWorks should be located in
Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks OLTP
and the install script (instawdwdb.sql) for AdventureWorksDW should be located in
Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks Data Warehouse.

You can run these scripts to re-create the sample databases. Please read the Books Online topic "Reinstalling Sample Databases from Script " for detailed instructions on how to do this. You must modify one statement in both scripts to point to the correct location of the .csv (raw data) files. This is explained in the topic.

Regards,
|||

In the vs2005 documentation there are excellent walkthroughs for asp.net 2.0. Someone overlooked that only AdventureWorks comes with it. Several of the walkthroughs want Northwind and Pubs.

I deleted those when I uninstalled sqlserver 2000. Where can I download them and how would I install them in sqlserver 2005?

Thanks in advance.

dennist685

|||You can download them here

http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46a0-8da2-eebc53a68034&DisplayLang=en|||As Ken points out, these databases are available for download. The readme that is included in the download provides instructions for installing the databases. The instructions assume you have SQL Server 2000, but they are essentially the same for SQL Server 2005. You have two choices: attach the databases or run the installation scripts.

Regards,|||gaile,

I'm having the same problem as the original poster (same error). The .msi file installs but the database is not attached. Does it make a difference that I am using the Demo version of SQL 2005? The folder you mention does not exist (Program Files\Microsoft SQL Server\90\Tools\Samples <- there is no samples folder).|||

I need some more information please.
Which database are you trying to install?

If it's AdventureWorks or AdventureWorksDW, did you follow the instructions in the Books Online topic "Running Setup to Install AdventureWorks Sample Databases and Samples ", or did you download the msi from the web?

If you downloaded the msi, you need to manually attach the database. The process for doing this is described in the readme file that is included in the download.

What version of SQL Server 2005 do you have installed?
Thanks,

|||"Which database are you trying to install?"

Both AdventureWorks and AdventureWorksDW.

"...did you follow the instructions in the Books Online topic "Running Setup to Install AdventureWorks Sample Databases and Samples ", or did you download the msi from the web?"

I downloaded the msi. Thanks for the suggestion though. I looked up that topic in Books Online and it seems I'm getting a bit further... however, once I try to execute the script as per the instructions, I get tons of errors. Here's a few of the early errors:

Oh, and version of SQL is SQL 2005 Enterprise I believe (the demo only comes in one version). http://www.microsoft.com/sql/downloads/default.mspx


*** Dropping Database
Msg 208, Level 16, State 1, Line 2
Invalid object name 'master.sys.databases'.

*** Creating Database
Msg 208, Level 16, State 1, Line 6
Invalid object name 'master.sys.master_files'.

Msg 102, Level 15, State 6, Line 11
Incorrect syntax near 'CHECKSUM'.

Msg 911, Level 16, State 1, Line 2
Could not locate entry in sysdatabases for database 'AdventureWorks'. No entry found with that name. Make sure that the name is entered correctly.

|||once I try to execute the script as per the instructions, I get tons of errors.

What script are you running? There's nothing in the topic "Running Setup to Install AdventureWorks Sample Databases and Samples" about running a script. Look for the section "To install the sample databases and samples after setup" in the topic and see if you can get those steps to work.

Regards,|||

Here's how far I get following the "To install the sample databases and samples after setup"

4. From Feature Selection, expand the Books Online and Samples node.

There is no "Books Online and Samples" node. There is a "Client Components" and a "Documentation, Samples, and Sample Databases" node. I select the latter.

5. Select Samples.

There is no "Samples", but there is a "Sample Databases" node. I select it.

6. Expand Databases and then select the sample databases to be installed. Click Next.

At this point there is 2 nodes, "Adventureworks Sample OLTP" and "AdventureworksDW Sample Warehouse". Beneath the latter there is another node "Adventureworks Sample OLAP". All nodes are already solid White, as in they are already installed to my computer due to previous efforts.

7. To install and attach the sample databases, from Sample Databases Setup, select Attach sample databases and click Next.

I don't get this option. After clicking next, the wizard goes into it's install routine.

The database files are created and stored in the folder n:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data. The database is attached and ready for use.

I do now have an AdventureWorksDW database in this folder, and it is attached. However, the tutorial refers to an AdventureWorks (not DW) database, and I in-fact do not have any of the tables refered to in the tutorial, such as the first one I come across - Production.Product.

8. To install the sample database files without attaching, from Sample Databases Setup, select Install sample databases and click Next.

As Above, I do not have this option.

8. Complete the steps in the wizard.

9. To complete the installation of the samples, after Setup, perform one of the following steps:

10. From the Start menu, click All Programs, click Microsoft SQL Server 2005, click Documentation and Tutorials, click Samples, and then click Microsoft SQL Server 2005 Samples.

11. Alternatively, using Windows Explorer, navigate to n:\Program Files\Microsoft SQL Server\90\Tools\Samples\ and double-click SqlServerSamples.msi to launch the installer.

Tried these steps too, the SqlServerSamples.msi (also on the Program menu) is there and it runs, it just doesn't DO anything apparently!

It appears to me that the help files contained in "Books Online" is not concurrent with the present release of SQL Server 2005. The tutorial databases are not possible to install under the current instructions.

|||Thanks for your patience on this. I really appreciate it. Your information tells me that (for some unknown reason) setup thinks the sample databases have been installed, and it's ignoring the request to install them. We've seen this before and have opened a bug with setup, but it's been hard to reproduce.

Let's look at a couple of alternatives. In your original post, you said you ran the download, but the databases didn't attach. The download does not automatically attach the files, but this should mean that you actually have the .mdf and .ldf files available for attaching.

Please look in the <drive:>\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data folder for the files AdventureWorks_data.mdf and/or AdventureWorksDW_Data.mdf.

If you have these files, then you just need to attach the databases. You can do this from SQL Server Management Studio, or by running the following statements.

exec sp_attach_db @.dbname=N'AdventureWorks', @.filename1=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf', @.filename2=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_log.ldf';

exec sp_attach_db @.dbname=N'AdventureWorksDW', @.filename1=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorksDW_Data.mdf', @.filename2=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorksDW_log.ldf';

If you do not have these files, then you can download the sample databases again.
http://www.microsoft.com/downloads/details.aspx?familyid=e719ecf7-9f46-4312-af89-6ad8702e4e6e&displaylang=en

If you do the download again, please follow the instructions for removing previous installations of the sample databases described in http://download.microsoft.com/download/d/8/6/d865cf0c-c44b-401b-b426-b3bf5c628112/SQLServerDatabasesAndSamplesOverview.htm. I know this seems unnecessary, but it won't hurt your system and could help.

Again, thanks for your perseverance.

Regards,

Getting sample databases in Management Studio

How to get sample database AdventureWorks and AdventureWorksDW
deployed in Management Studio. I selected to install sample database
entire feature on my local hard drive and I can see it did installed all
the .mdf,.ldf,.dim,.cube and the rest in
C:\Program Files\Microsoft SQL Server\90\Tools\Samples\

How can I get the database in Management studio.
I tried to use Attach db and it didn't worked, gave me following error

Msg 1813, Level 16, State 2, Line 1

Could not open new database 'AdventureWorks'. CREATE DATABASE is aborted.

Msg 602, Level 21, State 50, Line 1

Could not find row in sysindexes for database ID 8, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.

Any help would be appreciated.

Here is a link to a msi to install the database

http://www.microsoft.com/downloads/info.aspx?na=46&p=1&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=8D5BDE68-4991-432A-9D4B-0562DC49992E&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f4%2fb%2fc%2f4bc19fa4-5849-46a6-bebb-c22493d219e8%2fAdventureWorksDB.msi&oRef=http%3a%2f%2flab.msdn.microsoft.com%2fexpress%2fsql%2fdefault.aspx

|||I installed using the above link but I am unable to see the AdventureWorks db
in the Management studio under database tree.

After the installation do I need to configure something?|||hi Ken,

This is link to Adventure Works DB. Do you have link to Adventure Works DW msi?|||Sorry I cant find a link.

Here is some better instructions on how to install the adventure works db
http://download.microsoft.com/download/2/a/a/2aaa56bc-a173-4263-af15-e9421a14d5f8/SQLServerExpressSamplesOverview.htm|||If the sample databases were installed correctly, the .mdf and .ldf files for both AdventureWorks and AdventureWorksDW would be located in this folder
<drive>:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data not the folder you reference in your post. And you shouldn't have to attach the databases; the installation process performs the attach operation by default. However, it sounds like that didn't happen, so as an alternative you can re-create the databases by using the installation scripts.

The install script (instawdb.sql) for AdventureWorks should be located in
Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks OLTP
and the install script (instawdwdb.sql) for AdventureWorksDW should be located in
Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks Data Warehouse.

You can run these scripts to re-create the sample databases. Please read the Books Online topic "Reinstalling Sample Databases from Script " for detailed instructions on how to do this. You must modify one statement in both scripts to point to the correct location of the .csv (raw data) files. This is explained in the topic.

Regards,
|||

In the vs2005 documentation there are excellent walkthroughs for asp.net 2.0. Someone overlooked that only AdventureWorks comes with it. Several of the walkthroughs want Northwind and Pubs.

I deleted those when I uninstalled sqlserver 2000. Where can I download them and how would I install them in sqlserver 2005?

Thanks in advance.

dennist685

|||You can download them here

http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46a0-8da2-eebc53a68034&DisplayLang=en

|||As Ken points out, these databases are available for download. The readme that is included in the download provides instructions for installing the databases. The instructions assume you have SQL Server 2000, but they are essentially the same for SQL Server 2005. You have two choices: attach the databases or run the installation scripts.

Regards,|||gaile,

I'm having the same problem as the original poster (same error). The .msi file installs but the database is not attached. Does it make a difference that I am using the Demo version of SQL 2005? The folder you mention does not exist (Program Files\Microsoft SQL Server\90\Tools\Samples <- there is no samples folder).|||

I need some more information please.
Which database are you trying to install?

If it's AdventureWorks or AdventureWorksDW, did you follow the instructions in the Books Online topic "Running Setup to Install AdventureWorks Sample Databases and Samples ", or did you download the msi from the web?

If you downloaded the msi, you need to manually attach the database. The process for doing this is described in the readme file that is included in the download.

What version of SQL Server 2005 do you have installed?
Thanks,

|||"Which database are you trying to install?"

Both AdventureWorks and AdventureWorksDW.

"...did you follow the instructions in the Books Online topic "Running Setup to Install AdventureWorks Sample Databases and Samples ", or did you download the msi from the web?"

I downloaded the msi. Thanks for the suggestion though. I looked up that topic in Books Online and it seems I'm getting a bit further... however, once I try to execute the script as per the instructions, I get tons of errors. Here's a few of the early errors:

Oh, and version of SQL is SQL 2005 Enterprise I believe (the demo only comes in one version). http://www.microsoft.com/sql/downloads/default.mspx


*** Dropping Database
Msg 208, Level 16, State 1, Line 2
Invalid object name 'master.sys.databases'.

*** Creating Database
Msg 208, Level 16, State 1, Line 6
Invalid object name 'master.sys.master_files'.

Msg 102, Level 15, State 6, Line 11
Incorrect syntax near 'CHECKSUM'.

Msg 911, Level 16, State 1, Line 2
Could not locate entry in sysdatabases for database 'AdventureWorks'. No entry found with that name. Make sure that the name is entered correctly.

|||once I try to execute the script as per the instructions, I get tons of errors.

What script are you running? There's nothing in the topic "Running Setup to Install AdventureWorks Sample Databases and Samples" about running a script. Look for the section "To install the sample databases and samples after setup" in the topic and see if you can get those steps to work.

Regards,|||

Here's how far I get following the "To install the sample databases and samples after setup"

4. From Feature Selection, expand the Books Online and Samples node.

There is no "Books Online and Samples" node. There is a "Client Components" and a "Documentation, Samples, and Sample Databases" node. I select the latter.

5. Select Samples.

There is no "Samples", but there is a "Sample Databases" node. I select it.

6. Expand Databases and then select the sample databases to be installed. Click Next.

At this point there is 2 nodes, "Adventureworks Sample OLTP" and "AdventureworksDW Sample Warehouse". Beneath the latter there is another node "Adventureworks Sample OLAP". All nodes are already solid White, as in they are already installed to my computer due to previous efforts.

7. To install and attach the sample databases, from Sample Databases Setup, select Attach sample databases and click Next.

I don't get this option. After clicking next, the wizard goes into it's install routine.

The database files are created and stored in the folder n:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data. The database is attached and ready for use.

I do now have an AdventureWorksDW database in this folder, and it is attached. However, the tutorial refers to an AdventureWorks (not DW) database, and I in-fact do not have any of the tables refered to in the tutorial, such as the first one I come across - Production.Product.

8. To install the sample database files without attaching, from Sample Databases Setup, select Install sample databases and click Next.

As Above, I do not have this option.

8. Complete the steps in the wizard.

9. To complete the installation of the samples, after Setup, perform one of the following steps:

10. From the Start menu, click All Programs, click Microsoft SQL Server 2005, click Documentation and Tutorials, click Samples, and then click Microsoft SQL Server 2005 Samples.

11. Alternatively, using Windows Explorer, navigate to n:\Program Files\Microsoft SQL Server\90\Tools\Samples\ and double-click SqlServerSamples.msi to launch the installer.

Tried these steps too, the SqlServerSamples.msi (also on the Program menu) is there and it runs, it just doesn't DO anything apparently!

It appears to me that the help files contained in "Books Online" is not concurrent with the present release of SQL Server 2005. The tutorial databases are not possible to install under the current instructions.

|||Thanks for your patience on this. I really appreciate it. Your information tells me that (for some unknown reason) setup thinks the sample databases have been installed, and it's ignoring the request to install them. We've seen this before and have opened a bug with setup, but it's been hard to reproduce.

Let's look at a couple of alternatives. In your original post, you said you ran the download, but the databases didn't attach. The download does not automatically attach the files, but this should mean that you actually have the .mdf and .ldf files available for attaching.

Please look in the <drive:>\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data folder for the files AdventureWorks_data.mdf and/or AdventureWorksDW_Data.mdf.

If you have these files, then you just need to attach the databases. You can do this from SQL Server Management Studio, or by running the following statements.

exec sp_attach_db @.dbname=N'AdventureWorks', @.filename1=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf', @.filename2=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_log.ldf';

exec sp_attach_db @.dbname=N'AdventureWorksDW', @.filename1=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorksDW_Data.mdf', @.filename2=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorksDW_log.ldf';

If you do not have these files, then you can download the sample databases again.
http://www.microsoft.com/downloads/details.aspx?familyid=e719ecf7-9f46-4312-af89-6ad8702e4e6e&displaylang=en

If you do the download again, please follow the instructions for removing previous installations of the sample databases described in http://download.microsoft.com/download/d/8/6/d865cf0c-c44b-401b-b426-b3bf5c628112/SQLServerDatabasesAndSamplesOverview.htm. I know this seems unnecessary, but it won't hurt your system and could help.

Again, thanks for your perseverance.

Regards,

Getting sample databases in Management Studio

How to get sample database AdventureWorks and AdventureWorksDW
deployed in Management Studio. I selected to install sample database
entire feature on my local hard drive and I can see it did installed all
the .mdf,.ldf,.dim,.cube and the rest in
C:\Program Files\Microsoft SQL Server\90\Tools\Samples\

How can I get the database in Management studio.
I tried to use Attach db and it didn't worked, gave me following error

Msg 1813, Level 16, State 2, Line 1

Could not open new database 'AdventureWorks'. CREATE DATABASE is aborted.

Msg 602, Level 21, State 50, Line 1

Could not find row in sysindexes for database ID 8, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.

Any help would be appreciated.

Here is a link to a msi to install the database

http://www.microsoft.com/downloads/info.aspx?na=46&p=1&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=8D5BDE68-4991-432A-9D4B-0562DC49992E&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f4%2fb%2fc%2f4bc19fa4-5849-46a6-bebb-c22493d219e8%2fAdventureWorksDB.msi&oRef=http%3a%2f%2flab.msdn.microsoft.com%2fexpress%2fsql%2fdefault.aspx|||I installed using the above link but I am unable to see the AdventureWorks db
in the Management studio under database tree.

After the installation do I need to configure something?
|||hi Ken,

This is link to Adventure Works DB. Do you have link to Adventure Works DW msi?|||Sorry I cant find a link.

Here is some better instructions on how to install the adventure works db
http://download.microsoft.com/download/2/a/a/2aaa56bc-a173-4263-af15-e9421a14d5f8/SQLServerExpressSamplesOverview.htm|||If the sample databases were installed correctly, the .mdf and .ldf files for both AdventureWorks and AdventureWorksDW would be located in this folder
<drive>:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data not the folder you reference in your post. And you shouldn't have to attach the databases; the installation process performs the attach operation by default. However, it sounds like that didn't happen, so as an alternative you can re-create the databases by using the installation scripts.

The install script (instawdb.sql) for AdventureWorks should be located in
Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks OLTP
and the install script (instawdwdb.sql) for AdventureWorksDW should be located in
Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks Data Warehouse.

You can run these scripts to re-create the sample databases. Please read the Books Online topic "Reinstalling Sample Databases from Script " for detailed instructions on how to do this. You must modify one statement in both scripts to point to the correct location of the .csv (raw data) files. This is explained in the topic.

Regards,
|||

In the vs2005 documentation there are excellent walkthroughs for asp.net 2.0. Someone overlooked that only AdventureWorks comes with it. Several of the walkthroughs want Northwind and Pubs.

I deleted those when I uninstalled sqlserver 2000. Where can I download them and how would I install them in sqlserver 2005?

Thanks in advance.

dennist685

|||You can download them here

http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46a0-8da2-eebc53a68034&DisplayLang=en|||As Ken points out, these databases are available for download. The readme that is included in the download provides instructions for installing the databases. The instructions assume you have SQL Server 2000, but they are essentially the same for SQL Server 2005. You have two choices: attach the databases or run the installation scripts.

Regards,|||gaile,

I'm having the same problem as the original poster (same error). The .msi file installs but the database is not attached. Does it make a difference that I am using the Demo version of SQL 2005? The folder you mention does not exist (Program Files\Microsoft SQL Server\90\Tools\Samples <- there is no samples folder).|||

I need some more information please.
Which database are you trying to install?

If it's AdventureWorks or AdventureWorksDW, did you follow the instructions in the Books Online topic "Running Setup to Install AdventureWorks Sample Databases and Samples ", or did you download the msi from the web?

If you downloaded the msi, you need to manually attach the database. The process for doing this is described in the readme file that is included in the download.

What version of SQL Server 2005 do you have installed?
Thanks,

|||"Which database are you trying to install?"

Both AdventureWorks and AdventureWorksDW.

"...did you follow the instructions in the Books Online topic "Running Setup to Install AdventureWorks Sample Databases and Samples ", or did you download the msi from the web?"

I downloaded the msi. Thanks for the suggestion though. I looked up that topic in Books Online and it seems I'm getting a bit further... however, once I try to execute the script as per the instructions, I get tons of errors. Here's a few of the early errors:

Oh, and version of SQL is SQL 2005 Enterprise I believe (the demo only comes in one version). http://www.microsoft.com/sql/downloads/default.mspx


*** Dropping Database
Msg 208, Level 16, State 1, Line 2
Invalid object name 'master.sys.databases'.

*** Creating Database
Msg 208, Level 16, State 1, Line 6
Invalid object name 'master.sys.master_files'.

Msg 102, Level 15, State 6, Line 11
Incorrect syntax near 'CHECKSUM'.

Msg 911, Level 16, State 1, Line 2
Could not locate entry in sysdatabases for database 'AdventureWorks'. No entry found with that name. Make sure that the name is entered correctly.

|||once I try to execute the script as per the instructions, I get tons of errors.

What script are you running? There's nothing in the topic "Running Setup to Install AdventureWorks Sample Databases and Samples" about running a script. Look for the section "To install the sample databases and samples after setup" in the topic and see if you can get those steps to work.

Regards,|||

Here's how far I get following the "To install the sample databases and samples after setup"

4. From Feature Selection, expand the Books Online and Samples node.

There is no "Books Online and Samples" node. There is a "Client Components" and a "Documentation, Samples, and Sample Databases" node. I select the latter.

5. Select Samples.

There is no "Samples", but there is a "Sample Databases" node. I select it.

6. Expand Databases and then select the sample databases to be installed. Click Next.

At this point there is 2 nodes, "Adventureworks Sample OLTP" and "AdventureworksDW Sample Warehouse". Beneath the latter there is another node "Adventureworks Sample OLAP". All nodes are already solid White, as in they are already installed to my computer due to previous efforts.

7. To install and attach the sample databases, from Sample Databases Setup, select Attach sample databases and click Next.

I don't get this option. After clicking next, the wizard goes into it's install routine.

The database files are created and stored in the folder n:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data. The database is attached and ready for use.

I do now have an AdventureWorksDW database in this folder, and it is attached. However, the tutorial refers to an AdventureWorks (not DW) database, and I in-fact do not have any of the tables refered to in the tutorial, such as the first one I come across - Production.Product.

8. To install the sample database files without attaching, from Sample Databases Setup, select Install sample databases and click Next.

As Above, I do not have this option.

8. Complete the steps in the wizard.

9. To complete the installation of the samples, after Setup, perform one of the following steps:

10. From the Start menu, click All Programs, click Microsoft SQL Server 2005, click Documentation and Tutorials, click Samples, and then click Microsoft SQL Server 2005 Samples.

11. Alternatively, using Windows Explorer, navigate to n:\Program Files\Microsoft SQL Server\90\Tools\Samples\ and double-click SqlServerSamples.msi to launch the installer.

Tried these steps too, the SqlServerSamples.msi (also on the Program menu) is there and it runs, it just doesn't DO anything apparently!

It appears to me that the help files contained in "Books Online" is not concurrent with the present release of SQL Server 2005. The tutorial databases are not possible to install under the current instructions.

|||Thanks for your patience on this. I really appreciate it. Your information tells me that (for some unknown reason) setup thinks the sample databases have been installed, and it's ignoring the request to install them. We've seen this before and have opened a bug with setup, but it's been hard to reproduce.

Let's look at a couple of alternatives. In your original post, you said you ran the download, but the databases didn't attach. The download does not automatically attach the files, but this should mean that you actually have the .mdf and .ldf files available for attaching.

Please look in the <drive:>\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data folder for the files AdventureWorks_data.mdf and/or AdventureWorksDW_Data.mdf.

If you have these files, then you just need to attach the databases. You can do this from SQL Server Management Studio, or by running the following statements.

execsp_attach_db @.dbname=N'AdventureWorks', @.filename1=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf', @.filename2=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_log.ldf';

execsp_attach_db @.dbname=N'AdventureWorksDW', @.filename1=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorksDW_Data.mdf', @.filename2=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorksDW_log.ldf';

If you do not have these files, then you can download the sample databases again.
http://www.microsoft.com/downloads/details.aspx?familyid=e719ecf7-9f46-4312-af89-6ad8702e4e6e&displaylang=en

If you do the download again, please follow the instructions for removing previous installations of the sample databases described in http://download.microsoft.com/download/d/8/6/d865cf0c-c44b-401b-b426-b3bf5c628112/SQLServerDatabasesAndSamplesOverview.htm. I know this seems unnecessary, but it won't hurt your system and could help.

Again, thanks for your perseverance.

Regards,

Getting sample databases in Management Studio

How to get sample database AdventureWorks and AdventureWorksDW
deployed in Management Studio. I selected to install sample database
entire feature on my local hard drive and I can see it did installed all
the .mdf,.ldf,.dim,.cube and the rest in
C:\Program Files\Microsoft SQL Server\90\Tools\Samples\

How can I get the database in Management studio.
I tried to use Attach db and it didn't worked, gave me following error

Msg 1813, Level 16, State 2, Line 1

Could not open new database 'AdventureWorks'. CREATE DATABASE is aborted.

Msg 602, Level 21, State 50, Line 1

Could not find row in sysindexes for database ID 8, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.

Any help would be appreciated.

Here is a link to a msi to install the database

http://www.microsoft.com/downloads/info.aspx?na=46&p=1&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=8D5BDE68-4991-432A-9D4B-0562DC49992E&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f4%2fb%2fc%2f4bc19fa4-5849-46a6-bebb-c22493d219e8%2fAdventureWorksDB.msi&oRef=http%3a%2f%2flab.msdn.microsoft.com%2fexpress%2fsql%2fdefault.aspx|||I installed using the above link but I am unable to see the AdventureWorks db
in the Management studio under database tree.

After the installation do I need to configure something?
|||hi Ken,

This is link to Adventure Works DB. Do you have link to Adventure Works DW msi?|||Sorry I cant find a link.

Here is some better instructions on how to install the adventure works db
http://download.microsoft.com/download/2/a/a/2aaa56bc-a173-4263-af15-e9421a14d5f8/SQLServerExpressSamplesOverview.htm|||If the sample databases were installed correctly, the .mdf and .ldf files for both AdventureWorks and AdventureWorksDW would be located in this folder
<drive>:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data not the folder you reference in your post. And you shouldn't have to attach the databases; the installation process performs the attach operation by default. However, it sounds like that didn't happen, so as an alternative you can re-create the databases by using the installation scripts.

The install script (instawdb.sql) for AdventureWorks should be located in
Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks OLTP
and the install script (instawdwdb.sql) for AdventureWorksDW should be located in
Program Files\Microsoft SQL Server\90\Tools\Samples\AdventureWorks Data Warehouse.

You can run these scripts to re-create the sample databases. Please read the Books Online topic "Reinstalling Sample Databases from Script " for detailed instructions on how to do this. You must modify one statement in both scripts to point to the correct location of the .csv (raw data) files. This is explained in the topic.

Regards,
|||

In the vs2005 documentation there are excellent walkthroughs for asp.net 2.0. Someone overlooked that only AdventureWorks comes with it. Several of the walkthroughs want Northwind and Pubs.

I deleted those when I uninstalled sqlserver 2000. Where can I download them and how would I install them in sqlserver 2005?

Thanks in advance.

dennist685

|||You can download them here

http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46a0-8da2-eebc53a68034&DisplayLang=en|||As Ken points out, these databases are available for download. The readme that is included in the download provides instructions for installing the databases. The instructions assume you have SQL Server 2000, but they are essentially the same for SQL Server 2005. You have two choices: attach the databases or run the installation scripts.

Regards,|||gaile,

I'm having the same problem as the original poster (same error). The .msi file installs but the database is not attached. Does it make a difference that I am using the Demo version of SQL 2005? The folder you mention does not exist (Program Files\Microsoft SQL Server\90\Tools\Samples <- there is no samples folder).|||

I need some more information please.
Which database are you trying to install?

If it's AdventureWorks or AdventureWorksDW, did you follow the instructions in the Books Online topic "Running Setup to Install AdventureWorks Sample Databases and Samples ", or did you download the msi from the web?

If you downloaded the msi, you need to manually attach the database. The process for doing this is described in the readme file that is included in the download.

What version of SQL Server 2005 do you have installed?
Thanks,

|||"Which database are you trying to install?"

Both AdventureWorks and AdventureWorksDW.

"...did you follow the instructions in the Books Online topic "Running Setup to Install AdventureWorks Sample Databases and Samples ", or did you download the msi from the web?"

I downloaded the msi. Thanks for the suggestion though. I looked up that topic in Books Online and it seems I'm getting a bit further... however, once I try to execute the script as per the instructions, I get tons of errors. Here's a few of the early errors:

Oh, and version of SQL is SQL 2005 Enterprise I believe (the demo only comes in one version). http://www.microsoft.com/sql/downloads/default.mspx


*** Dropping Database
Msg 208, Level 16, State 1, Line 2
Invalid object name 'master.sys.databases'.

*** Creating Database
Msg 208, Level 16, State 1, Line 6
Invalid object name 'master.sys.master_files'.

Msg 102, Level 15, State 6, Line 11
Incorrect syntax near 'CHECKSUM'.

Msg 911, Level 16, State 1, Line 2
Could not locate entry in sysdatabases for database 'AdventureWorks'. No entry found with that name. Make sure that the name is entered correctly.

|||once I try to execute the script as per the instructions, I get tons of errors.

What script are you running? There's nothing in the topic "Running Setup to Install AdventureWorks Sample Databases and Samples" about running a script. Look for the section "To install the sample databases and samples after setup" in the topic and see if you can get those steps to work.

Regards,|||

Here's how far I get following the "To install the sample databases and samples after setup"

4. From Feature Selection, expand the Books Online and Samples node.

There is no "Books Online and Samples" node. There is a "Client Components" and a "Documentation, Samples, and Sample Databases" node. I select the latter.

5. Select Samples.

There is no "Samples", but there is a "Sample Databases" node. I select it.

6. Expand Databases and then select the sample databases to be installed. Click Next.

At this point there is 2 nodes, "Adventureworks Sample OLTP" and "AdventureworksDW Sample Warehouse". Beneath the latter there is another node "Adventureworks Sample OLAP". All nodes are already solid White, as in they are already installed to my computer due to previous efforts.

7. To install and attach the sample databases, from Sample Databases Setup, select Attach sample databases and click Next.

I don't get this option. After clicking next, the wizard goes into it's install routine.

The database files are created and stored in the folder n:\Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\Data. The database is attached and ready for use.

I do now have an AdventureWorksDW database in this folder, and it is attached. However, the tutorial refers to an AdventureWorks (not DW) database, and I in-fact do not have any of the tables refered to in the tutorial, such as the first one I come across - Production.Product.

8. To install the sample database files without attaching, from Sample Databases Setup, select Install sample databases and click Next.

As Above, I do not have this option.

8. Complete the steps in the wizard.

9. To complete the installation of the samples, after Setup, perform one of the following steps:

10. From the Start menu, click All Programs, click Microsoft SQL Server 2005, click Documentation and Tutorials, click Samples, and then click Microsoft SQL Server 2005 Samples.

11. Alternatively, using Windows Explorer, navigate to n:\Program Files\Microsoft SQL Server\90\Tools\Samples\ and double-click SqlServerSamples.msi to launch the installer.

Tried these steps too, the SqlServerSamples.msi (also on the Program menu) is there and it runs, it just doesn't DO anything apparently!

It appears to me that the help files contained in "Books Online" is not concurrent with the present release of SQL Server 2005. The tutorial databases are not possible to install under the current instructions.

|||Thanks for your patience on this. I really appreciate it. Your information tells me that (for some unknown reason) setup thinks the sample databases have been installed, and it's ignoring the request to install them. We've seen this before and have opened a bug with setup, but it's been hard to reproduce.

Let's look at a couple of alternatives. In your original post, you said you ran the download, but the databases didn't attach. The download does not automatically attach the files, but this should mean that you actually have the .mdf and .ldf files available for attaching.

Please look in the <drive:>\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data folder for the files AdventureWorks_data.mdf and/or AdventureWorksDW_Data.mdf.

If you have these files, then you just need to attach the databases. You can do this from SQL Server Management Studio, or by running the following statements.

exec sp_attach_db @.dbname=N'AdventureWorks', @.filename1=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf', @.filename2=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_log.ldf';

exec sp_attach_db @.dbname=N'AdventureWorksDW', @.filename1=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorksDW_Data.mdf', @.filename2=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorksDW_log.ldf';

If you do not have these files, then you can download the sample databases again.
http://www.microsoft.com/downloads/details.aspx?familyid=e719ecf7-9f46-4312-af89-6ad8702e4e6e&displaylang=en

If you do the download again, please follow the instructions for removing previous installations of the sample databases described in http://download.microsoft.com/download/d/8/6/d865cf0c-c44b-401b-b426-b3bf5c628112/SQLServerDatabasesAndSamplesOverview.htm. I know this seems unnecessary, but it won't hurt your system and could help.

Again, thanks for your perseverance.

Regards,

getting rid of sql express databases

This issue is just irritating: hope someone can help...

I recently deleted a whole lot of test websites on my laptop by physically deleting the folders. Each had their own SQL Express database. The database instances still show up in SQL Server Management Studio, although the databases have been removed. I can't drop the datababases with the GUI as it says they're not accessible (that would be right), and manually using the DROP DATABASE command tells me that the physical file can't be found (also correct).

Is there a "proper" way to get rid of them without directly manipulating the system tables?

This is a tricky situation.

One way to get the instances name not to show up in the GUI is to remove entries from the system tables.

Or, you could goto the Recycle Bin and restore the database files and try to delete the database from GUI again. Hope you did not use "Shift + Delete"

|||

I think that could be accomplished with the tool called sseutil, found here:http://www.microsoft.com/downloads/details.aspx?familyid=fa87e828-173f-472e-a85c-27ed01cf6b02&displaylang=en

Specifically look at the -d option

hope it helps,

/Klaus

|||

Klaus Byskov Pedersen:

I think that could be accomplished with the tool called sseutil, found here:http://www.microsoft.com/downloads/details.aspx?familyid=fa87e828-173f-472e-a85c-27ed01cf6b02&displaylang=en

Specifically look at the -d option

hope it helps,

/Klaus

Klaus,

That is a great tool. Hope the poster will be able to resolve the issue using this tool.

|||

Klaus, that worked - thanks! I'd forgotten sseutil, I rarely use it. For anyone else who need to do this, the tool has minimal documentation so here's the quick steps:

1. download and install sseutil using Klaus' link

2. list the databases on your local server (from the command-line prompt)

sseutil -l

3. Use the -d parameter to "detach" the database, this tool doesn't complain that the files aren't in place. Here's my example:

sseutil -d "C:\WEBSITE1\APP_DATA\ASPNETDB.MDF"

Unfortunately, I also have several ASPNETDB databases that get listed without a path but with a suffix e.g.ASPNETDB_82786741c8bb45919d200a59f159d29c. The sseutil utility can't deal with these, so I think I'll need to tinker with the system tables here. But the other ones have "disappeared" nicely.

sql

Wednesday, March 7, 2012

Getting meta-data for Linked Servers

My customer has a .NET application that reads meta data from SQL Server, Oracle, DB2, and several propritary databases. Because each DBMS stores the meta data using various techniques, they have written custom code for each DBMS. They are working on a generic ODBC/OLEDB suppport, but in the interim I was trying to use SQL Server to link to an Access database. The Access linked server works fine for queries in Query Analyzer, but I would like to be able to programatically read the metadata for an Access DB (tables, columns, types, etc) via the linked server. SQL Server's usual mechanism for storing meta-data in the Master database aparently is not used for Linked Servers.

Does SQL Server expose Linked Server meta data?

How would one retrieve this meta data if it is exposed?

Thanks,

Ben

Hi Ben,

No SQL Server does not store metadata about linked servers (excluding connection information stored in sys.servers/sysservers). You would need to interrogate the actual linked server for this. So, if it were MSAccess, you would need to refer to the system tables (such as MSysObjects) etc.

Cheers,

Rob

|||

I was afraid that was the answer.

Thanks

getting list of SQL Instances / Databases on network

I am using C#.NET and I am writing an application where I need to display to
the user in a comboBox all the SQL Server instances that can be detected and
dis. I have seen many applications like Enterprise Manager that can detect
them all. Once the user selects the instance, I would also like to get a lis
t
of all the databases stored into another combo.
How do I do this in C#?
Thanks for the help in advance.
David
Message posted via http://www.webservertalk.comhi
probably this can hekp you:
http://chanduas.blogspot.com/2005/0...-databases.html
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---
"David C via webservertalk.com" wrote:

> I am using C#.NET and I am writing an application where I need to display
to
> the user in a comboBox all the SQL Server instances that can be detected a
nd
> dis. I have seen many applications like Enterprise Manager that can detect
> them all. Once the user selects the instance, I would also like to get a l
ist
> of all the databases stored into another combo.
> How do I do this in C#?
> Thanks for the help in advance.
> David
>
> --
> Message posted via http://www.webservertalk.com
>|||This just lists the databases on a *known* single instance, which is also
treated here in more depth:
http://www.aspfaq.com/2456
"Chandra" <chandra@.discussions.microsoft.com> wrote in message
news:3EAACA02-A627-4CE6-8A6E-E9CCFF6208D2@.microsoft.com...
> hi
> probably this can hekp you:
> http://chanduas.blogspot.com/2005/0...-databases.html
>
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> http://www.SQLResource.com/
> ---
>
> "David C via webservertalk.com" wrote:
>|||If you are familiar with SQL-DMO, you can use ListAvailableServers()
You can also use the SQLPing utility; one version has C# source code
included.
http://www.sqlsecurity.com/DesktopDefault.aspx?tabid=26
In addition, Gert has produced some tools:
http://www.sqldev.net/misc/EnumSQLSvr.htm
http://www.sqldev.net/misc/ListSQLSvr.htm
http://www.sqldev.net/misc/OleDbEnum.htm
"David C via webservertalk.com" <forum@.webservertalk.com> wrote in message
news:52A41F2E6B25A@.webservertalk.com...
>I am using C#.NET and I am writing an application where I need to display
>to
> the user in a comboBox all the SQL Server instances that can be detected
> and
> dis. I have seen many applications like Enterprise Manager that can detect
> them all. Once the user selects the instance, I would also like to get a
> list
> of all the databases stored into another combo.
> How do I do this in C#?
> Thanks for the help in advance.
> David
>
> --
> Message posted via http://www.webservertalk.com|||Thank Chandra but that will only help me once I get the instance. I also nee
d
to know how to query all the instances that exist on the network. Any help
would be great from someone.
Thanks,
David
Chandra wrote:
>hi
>probably this can hekp you:
>http://chanduas.blogspot.com/2005/0...-databases.html
>
>[quoted text clipped - 7 lines]
Message posted via http://www.webservertalk.com|||Thank Chandra but that will only help me once I get the instance. I also nee
d
to know how to query all the instances that exist on the network. Any help
would be great from someone.
Thanks,
David
Chandra wrote:
>hi
>probably this can hekp you:
>http://chanduas.blogspot.com/2005/0...-databases.html
>
>[quoted text clipped - 7 lines]
Message posted via http://www.webservertalk.com|||Here's a very quick way to do it in C#
Create a new console application, and add this reference:
Project | Add Reference | COM | Microsoft SQLDMO Object Library
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
SQLDMO.Application sqlDmoApplication = new SQLDMO.Application();
SQLDMO.NameList serverList;
serverList = sqlDmoApplication.ListAvailableSQLServers();
foreach(string serverName in serverList)
{
Console.WriteLine(serverName);
}
}
}
}
That's it... now, as others might mention, this isn't 100% accurate, because
some servers in your network may be "hidden," and the service also has to be
started to be detected this way.
"David C via webservertalk.com" <forum@.webservertalk.com> wrote in message
news:52A41F2E6B25A@.webservertalk.com...
>I am using C#.NET and I am writing an application where I need to display
>to
> the user in a comboBox all the SQL Server instances that can be detected
> and
> dis. I have seen many applications like Enterprise Manager that can detect
> them all. Once the user selects the instance, I would also like to get a
> list
> of all the databases stored into another combo.
> How do I do this in C#?
> Thanks for the help in advance.
> David
>
> --
> Message posted via http://www.webservertalk.com|||Aaron,
If I could give you 1000 points for giving the perfect answer I would.
This was an outstanding piece of code that worked perfectly. We have an SQL
expert here and he did not think of this. So props to you.
Thanks,
David
Aaron Bertrand [SQL Server MVP] wrote:
>Here's a very quick way to do it in C#
>Create a new console application, and add this reference:
>Project | Add Reference | COM | Microsoft SQLDMO Object Library
>using System;
>using System.Collections.Generic;
>using System.Text;
>namespace ConsoleApplication1
>{
> class Program
> {
> static void Main(string[] args)
> {
> SQLDMO.Application sqlDmoApplication = new SQLDMO.Application()
;
> SQLDMO.NameList serverList;
> serverList = sqlDmoApplication.ListAvailableSQLServers();
> foreach(string serverName in serverList)
> {
> Console.WriteLine(serverName);
> }
> }
> }
>}
>That's it... now, as others might mention, this isn't 100% accurate, becaus
e
>some servers in your network may be "hidden," and the service also has to b
e
>started to be detected this way.
>
>[quoted text clipped - 10 lines]
Message posted via http://www.webservertalk.com|||The best way to do it is using SQLBrowseConnect function from ODBC (no
SQLDMO dependency). Check the sample here:
http://www.codeproject.com/cs/database/LocatingSql.asp
Note: SQLBrowseConnect does not work if LAN is not available (cable
unplugged, etc.) while local instances are still accessible :-))
cheers,
</wqw>|||I too am looking for this same type of information. I read through the
response's and none gave me any information I could use. I've already tried
the one David said returned the information he needed. Here's what I am
looking for.
I've got SQL Server 2005 Express installed twice with 2 instances. The
first is the default SQLExpress and the second I named. We'll say
TestExpress. I know if I go into the registry under SQL Server it list both
of these instance names and I can probably retrieve this information from
there. But is there anyway to retrieve it via SQLDMO or any of the .NET SQL
references.
This code Aaron listed and David said it worked for him
SQLDMO.Application sqlDmoApplication = new SQLDMO.Application();
SQLDMO.NameList serverList;
serverList = sqlDmoApplication.ListAvailableSQLServers();
foreach(string serverName in serverList)
{
Console.WriteLine(serverName);
}
This only retrieved 2 items
{local}
the other was my computer name
Any help would be appreciated.
Joe
"David C via webservertalk.com" <forum@.webservertalk.com> wrote in message
news:52A41F2E6B25A@.webservertalk.com...
>I am using C#.NET and I am writing an application where I need to display
>to
> the user in a comboBox all the SQL Server instances that can be detected
> and
> dis. I have seen many applications like Enterprise Manager that can detect
> them all. Once the user selects the instance, I would also like to get a
> list
> of all the databases stored into another combo.
> How do I do this in C#?
> Thanks for the help in advance.
> David
>
> --
> Message posted via http://www.webservertalk.com

Getting List of Databases From Server

Is there a way I can query the database server (SQL 2000) to get a list of all the available databases? As a threshold problem I am not clear how I would connect to the server. I am using VB.Net and presently connect to one database at a time. The connection string is in an XML file, such as:

<?xml version="1.0" encoding="utf-8" ?>

<Connection>workstation id=ASUS;packet size=4096;user id=sa;data source="5.15.183.222\KWMSDE2"; persist security info=True;initial catalog=tsLocal;password=pass

</Connection>

Is there some special way that you connect to the server without specifying the database?

Is there a certain query I must use once I am connected? Can the information be returned in the form of a data table in a data set?

Thanks.

Hi Kevin.

You can run the following query to get a list of databases on the given server:

select * from master.dbo.sysdatabases

You'll want to investigate some of the options/values available when using the databaseproperty() and databasepropertyex() functions to ensure the given database is available for connections (for example, it needs to be online)...

As for connecting to the server without specifying a database, you'll always be connected to a given database even if you don't specify one (your default database), but you'd be safe always connecting to one of the system db's if you have the permissions (master,model,msdb,tempdb).

HTH,

|||

Hi,

you can also use the SMO class library to evaluate the databases on the server. You will get a typed object back instead of just a datarow. THe object holds many properties the database has, so there would be no need to use additional queries for getting information about the database. A quick like would be something like this in C# using the SMo libaries:

Server s = new Server(@."Servername\InstanceName");
foreach(Database d in s.Databases) //Holds the database collection
{
Debug.Writeline(d.Name);
}

HTH, Jens K. Suessmeyer.


http://www.sqlserver2005.de