Showing posts with label query. Show all posts
Showing posts with label query. Show all posts

Tuesday, March 27, 2012

Database snapshot

I drop and recreate a database snapshot for reporting purposes at the end of a DW loading process.

I need to create some indexes to improve query performance.

Where I should create the index, on the originale db or on the snapshot db ?

Cosimo

If I remember from an article, you can not do this on a snapshot database. So I guess you should do this on the source DB. Please check it though.|||

SOLVED

I create the index on the source db.

Sunday, March 25, 2012

Database Size Limitations

Hey all,
Is there any way that I can find the current size limitation (eg, MSDE = 2gb
limit) of a database from a db query / DMO dll call etc?
ThanksYou can get the edition and product information with these:
SELECT SERVERPROPERTY('productversion') AS [ProductVersion]
SELECT SERVERPROPERTY('ProductLevel') AS [ProductLevel]
SELECT SERVERPROPERTY('Edition') AS [Edition]
But there is no bit that I know of that you can see for the size limitation.
It's pretty simple though if it is MSDE it is 2GB, if it is SQLExpress it is
4GB otherwise there is no limit.
Andrew J. Kelly SQL MVP
"-Ldwater" <Ldwater@.discussions.microsoft.com> wrote in message
news:9F961CBD-4303-49DA-A8D8-8E2C63296BB5@.microsoft.com...
> Hey all,
> Is there any way that I can find the current size limitation (eg, MSDE =
> 2gb
> limit) of a database from a db query / DMO dll call etc?
> Thanks|||Thanks Andrew, but which bit out of the server results would show what
version the DB is running on?
I understand which DB's have limits, but I cant establish a way to find out
which type of DB system is being used by our customers in order to impose a
limit check.
Any help would be great! Thanks!
"Andrew J. Kelly" wrote:

> You can get the edition and product information with these:
>
> SELECT SERVERPROPERTY('productversion') AS [ProductVersion]
> SELECT SERVERPROPERTY('ProductLevel') AS [ProductLevel]
> SELECT SERVERPROPERTY('Edition') AS [Edition]
> But there is no bit that I know of that you can see for the size limitatio
n.
> It's pretty simple though if it is MSDE it is 2GB, if it is SQLExpress it
is
> 4GB otherwise there is no limit.
> --
> Andrew J. Kelly SQL MVP
>
> "-Ldwater" <Ldwater@.discussions.microsoft.com> wrote in message
> news:9F961CBD-4303-49DA-A8D8-8E2C63296BB5@.microsoft.com...
>
>|||I am not sure i am understanding you properly. Are you asking how do you
determine if they are running MSDE or not? Is so then just run
SERVERPROPERTY('Edition') to see. You can check BooksOnLine under this
command for the proper results.
Andrew J. Kelly SQL MVP
"-Ldwater" <Ldwater@.discussions.microsoft.com> wrote in message
news:44A7095B-F895-49DD-AA34-28FFE7F4DC1E@.microsoft.com...
> Thanks Andrew, but which bit out of the server results would show what
> version the DB is running on?
> I understand which DB's have limits, but I cant establish a way to find
> out
> which type of DB system is being used by our customers in order to impose
> a
> limit check.
> Any help would be great! Thanks!
> "Andrew J. Kelly" wrote:
>|||Yeah, thats what im after.
When trying it out, ive got an MSDE installation locally and a full SQL 2000
on a server, but both return 'Developer Edition' from the 'Edition' server
property, so I assumed that this wasn't specific enough?
"Andrew J. Kelly" wrote:

> I am not sure i am understanding you properly. Are you asking how do you
> determine if they are running MSDE or not? Is so then just run
> SERVERPROPERTY('Edition') to see. You can check BooksOnLine under this
> command for the proper results.
>
> --
> Andrew J. Kelly SQL MVP
>
> "-Ldwater" <Ldwater@.discussions.microsoft.com> wrote in message
> news:44A7095B-F895-49DD-AA34-28FFE7F4DC1E@.microsoft.com...
>
>|||Hmmm. I can see the Full version showing Developer if that what it is but I
would expect MSDE to show DeskTop. Are you sure you were pointing to the
correct instance? What does "engine edition" show?
Andrew J. Kelly SQL MVP
"-Ldwater" <Ldwater@.discussions.microsoft.com> wrote in message
news:B68E0408-2DE2-4CEA-886A-00338CBA8645@.microsoft.com...
> Yeah, thats what im after.
> When trying it out, ive got an MSDE installation locally and a full SQL
> 2000
> on a server, but both return 'Developer Edition' from the 'Edition' server
> property, so I assumed that this wasn't specific enough?
> "Andrew J. Kelly" wrote:
>|||Ok.. im a dumbass! (Looking at the wrong DB!)
Now my 'Engine Edition' Shows 1 (Desktop Edition) which is what I would
expect.
Do we know if the 'SERVERPROPERTY(EngineEdition)' returns similar results
for SQL 2005 & SQLExpress?
"Andrew J. Kelly" wrote:

> Hmmm. I can see the Full version showing Developer if that what it is but
I
> would expect MSDE to show DeskTop. Are you sure you were pointing to the
> correct instance? What does "engine edition" show?
> --
> Andrew J. Kelly SQL MVP
>
> "-Ldwater" <Ldwater@.discussions.microsoft.com> wrote in message
> news:B68E0408-2DE2-4CEA-886A-00338CBA8645@.microsoft.com...
>
>|||These are the possible results from both the Edition and Engine Edition
properties in 2005 BOL:
'Desktop Engine'
'Developer Edition'
'Enterprise Edition'
'Enterprise Evaluation Edition'
'Personal Edition'
'Standard Edition'
'Express Edition'
'Workgroup Edition'
'Windows Embedded SQL'
---
Database Engine edition of the instance of SQL Server installed on the
server.
1 = Personal or Desktop Engine
2 = Standard
3 = Enterprise (This is returned for Enterprise, Enterprise Evaluation, and
Developer.)
4 = Express
Andrew J. Kelly SQL MVP
"-Ldwater" <Ldwater@.discussions.microsoft.com> wrote in message
news:24868DAD-04FA-42B2-BF4E-7571BF6DCB06@.microsoft.com...
> Ok.. im a dumbass! (Looking at the wrong DB!)
> Now my 'Engine Edition' Shows 1 (Desktop Edition) which is what I would
> expect.
> Do we know if the 'SERVERPROPERTY(EngineEdition)' returns similar results
> for SQL 2005 & SQLExpress?
> "Andrew J. Kelly" wrote:
>sql

database size and raid configuration

Hi
I need to provide following information:
1. Size of all the current databases on all sql server (2000 and 2005). Is
these a query I can use to get this information.
2. Database size requirement for next three years.
3. Backup space requirements (I know which database require simple and which
transactional log database backups).
4. Test database space requirements (I know which databases require test
database).
5. New SQL server reporting services (Server space requirement), I know
which databases require a reporting server.
6. Recommendation for RAID for live and test databases including logging.
Thanks
ontario, canada
When i select size of files using sql server using
"select name,filename,size from sysaltfiles" I get size of files as
File one size: file1.mdf = 4976
File two size: file2.ldf = 2504
File three size file3.mdf = 1360
File four size file4.ldf = 13408
When I see the size of files in the disk using windows explorer I get
different size
File one size: 39804 kb
File two size: 20032 kb
File three size:10,880 kb
File four size: 107,264 KB
Why is that difference in file sizes?
ontario, canada
"db" wrote:

> Hi
> I need to provide following information:
> 1. Size of all the current databases on all sql server (2000 and 2005). Is
> these a query I can use to get this information.
> 2. Database size requirement for next three years.
> 3. Backup space requirements (I know which database require simple and which
> transactional log database backups).
> 4. Test database space requirements (I know which databases require test
> database).
> 5. New SQL server reporting services (Server space requirement), I know
> which databases require a reporting server.
> 6. Recommendation for RAID for live and test databases including logging.
> Thanks
> --
> ontario, canada
|||Thanks Tibor.
1. I am using sysaltfiles and sp_databases to get the Size of all the
current databases on all sql server (2000 and 2005). Looks like it works.
2. Database size requirement for next three years. For last 1.5 years size
of databases have increased by 50%. What do you think i should project for
next three years assuming no new applications?
3. Can I use a sql script to find the size of all backup files (.bak) for
the databases on the servers? If yes what?
4. Test database space requirements (I know which databases require test
database). What is the ideal size?
5. We will have new SQL server reporting server. How should i decide size
of the reporting server?
6. Recommendation for RAID for live and test databases. I would like to go
with maximum performance... ?
ontario, canada
"Tibor Karaszi" wrote:

> The unit for sysaltfiles is in pages (one page is 8KB).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "db" <db@.discussions.microsoft.com> wrote in message
> news:BCE5FEFC-57F7-44B8-B23F-10CED667E7FB@.microsoft.com...
>
|||2) I would plan on 50-75% growth per year based on your very limited
information.
3) I would use vbscript to scan directories and gather backup size
information. If you have never cleaned out msdb, you can find sizes for
backups there in one of the backupset... tables. See BOL for backupset and
it's related tables to get details.
4) We cannot guide you in this area without a good deal more information.
5) Again, need much more information.
6) Maximum performance would probably be RAID10, with lots of 15Krpm
spindles. You could perhaps get better read performance with RAID5, but
update/insert/delete performance will suffer. There is a LOT more to
disk/file configuration, btw!
BTW, I strongly recommend you hire an expert for a day or three to assist
you in your project. LOTS of ways to go astray here, and LOTS of variables
come into play.
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"db" <db@.discussions.microsoft.com> wrote in message
news:CDA4EAF9-424E-4E0F-8164-EBE289ECC407@.microsoft.com...[vbcol=seagreen]
> Thanks Tibor.
> 1. I am using sysaltfiles and sp_databases to get the Size of all the
> current databases on all sql server (2000 and 2005). Looks like it works.
> 2. Database size requirement for next three years. For last 1.5 years size
> of databases have increased by 50%. What do you think i should project for
> next three years assuming no new applications?
> 3. Can I use a sql script to find the size of all backup files (.bak) for
> the databases on the servers? If yes what?
> 4. Test database space requirements (I know which databases require test
> database). What is the ideal size?
> 5. We will have new SQL server reporting server. How should i decide size
> of the reporting server?
> 6. Recommendation for RAID for live and test databases. I would like to go
> with maximum performance... ?
> --
> ontario, canada
>
> "Tibor Karaszi" wrote:

Thursday, March 22, 2012

database size and raid configuration

Hi
I need to provide following information:
1. Size of all the current databases on all sql server (2000 and 2005). Is
these a query I can use to get this information.
2. Database size requirement for next three years.
3. Backup space requirements (I know which database require simple and which
transactional log database backups).
4. Test database space requirements (I know which databases require test
database).
5. New SQL server reporting services (Server space requirement), I know
which databases require a reporting server.
6. Recommendation for RAID for live and test databases including logging.
Thanks
--
ontario, canadaWhen i select size of files using sql server using
"select name,filename,size from sysaltfiles" I get size of files as
File one size: file1.mdf = 4976
File two size: file2.ldf = 2504
File three size file3.mdf = 1360
File four size file4.ldf = 13408
When I see the size of files in the disk using windows explorer I get
different size
File one size: 39804 kb
File two size: 20032 kb
File three size:10,880 kb
File four size: 107,264 KB
Why is that difference in file sizes?
--
ontario, canada
"db" wrote:
> Hi
> I need to provide following information:
> 1. Size of all the current databases on all sql server (2000 and 2005). Is
> these a query I can use to get this information.
> 2. Database size requirement for next three years.
> 3. Backup space requirements (I know which database require simple and which
> transactional log database backups).
> 4. Test database space requirements (I know which databases require test
> database).
> 5. New SQL server reporting services (Server space requirement), I know
> which databases require a reporting server.
> 6. Recommendation for RAID for live and test databases including logging.
> Thanks
> --
> ontario, canada|||The unit for sysaltfiles is in pages (one page is 8KB).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"db" <db@.discussions.microsoft.com> wrote in message
news:BCE5FEFC-57F7-44B8-B23F-10CED667E7FB@.microsoft.com...
> When i select size of files using sql server using
> "select name,filename,size from sysaltfiles" I get size of files as
> File one size: file1.mdf = 4976
> File two size: file2.ldf = 2504
> File three size file3.mdf = 1360
> File four size file4.ldf = 13408
> When I see the size of files in the disk using windows explorer I get
> different size
> File one size: 39804 kb
> File two size: 20032 kb
> File three size:10,880 kb
> File four size: 107,264 KB
> Why is that difference in file sizes?
> --
> ontario, canada
>
> "db" wrote:
>> Hi
>> I need to provide following information:
>> 1. Size of all the current databases on all sql server (2000 and 2005). Is
>> these a query I can use to get this information.
>> 2. Database size requirement for next three years.
>> 3. Backup space requirements (I know which database require simple and which
>> transactional log database backups).
>> 4. Test database space requirements (I know which databases require test
>> database).
>> 5. New SQL server reporting services (Server space requirement), I know
>> which databases require a reporting server.
>> 6. Recommendation for RAID for live and test databases including logging.
>> Thanks
>> --
>> ontario, canada|||Thanks Tibor.
1. I am using sysaltfiles and sp_databases to get the Size of all the
current databases on all sql server (2000 and 2005). Looks like it works.
2. Database size requirement for next three years. For last 1.5 years size
of databases have increased by 50%. What do you think i should project for
next three years assuming no new applications'
3. Can I use a sql script to find the size of all backup files (.bak) for
the databases on the servers? If yes what?
4. Test database space requirements (I know which databases require test
database). What is the ideal size'
5. We will have new SQL server reporting server. How should i decide size
of the reporting server?
6. Recommendation for RAID for live and test databases. I would like to go
with maximum performance... ?
--
ontario, canada
"Tibor Karaszi" wrote:
> The unit for sysaltfiles is in pages (one page is 8KB).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "db" <db@.discussions.microsoft.com> wrote in message
> news:BCE5FEFC-57F7-44B8-B23F-10CED667E7FB@.microsoft.com...
> > When i select size of files using sql server using
> > "select name,filename,size from sysaltfiles" I get size of files as
> >
> > File one size: file1.mdf = 4976
> > File two size: file2.ldf = 2504
> > File three size file3.mdf = 1360
> > File four size file4.ldf = 13408
> >
> > When I see the size of files in the disk using windows explorer I get
> > different size
> >
> > File one size: 39804 kb
> > File two size: 20032 kb
> > File three size:10,880 kb
> > File four size: 107,264 KB
> >
> > Why is that difference in file sizes?
> > --
> > ontario, canada
> >
> >
> > "db" wrote:
> >
> >> Hi
> >>
> >> I need to provide following information:
> >> 1. Size of all the current databases on all sql server (2000 and 2005). Is
> >> these a query I can use to get this information.
> >> 2. Database size requirement for next three years.
> >> 3. Backup space requirements (I know which database require simple and which
> >> transactional log database backups).
> >> 4. Test database space requirements (I know which databases require test
> >> database).
> >> 5. New SQL server reporting services (Server space requirement), I know
> >> which databases require a reporting server.
> >> 6. Recommendation for RAID for live and test databases including logging.
> >>
> >> Thanks
> >> --
> >> ontario, canada
>|||2) I would plan on 50-75% growth per year based on your very limited
information.
3) I would use vbscript to scan directories and gather backup size
information. If you have never cleaned out msdb, you can find sizes for
backups there in one of the backupset... tables. See BOL for backupset and
it's related tables to get details.
4) We cannot guide you in this area without a good deal more information.
5) Again, need much more information.
6) Maximum performance would probably be RAID10, with lots of 15Krpm
spindles. You could perhaps get better read performance with RAID5, but
update/insert/delete performance will suffer. There is a LOT more to
disk/file configuration, btw!
BTW, I strongly recommend you hire an expert for a day or three to assist
you in your project. LOTS of ways to go astray here, and LOTS of variables
come into play.
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net
"db" <db@.discussions.microsoft.com> wrote in message
news:CDA4EAF9-424E-4E0F-8164-EBE289ECC407@.microsoft.com...
> Thanks Tibor.
> 1. I am using sysaltfiles and sp_databases to get the Size of all the
> current databases on all sql server (2000 and 2005). Looks like it works.
> 2. Database size requirement for next three years. For last 1.5 years size
> of databases have increased by 50%. What do you think i should project for
> next three years assuming no new applications'
> 3. Can I use a sql script to find the size of all backup files (.bak) for
> the databases on the servers? If yes what?
> 4. Test database space requirements (I know which databases require test
> database). What is the ideal size'
> 5. We will have new SQL server reporting server. How should i decide size
> of the reporting server?
> 6. Recommendation for RAID for live and test databases. I would like to go
> with maximum performance... ?
> --
> ontario, canada
>
> "Tibor Karaszi" wrote:
>> The unit for sysaltfiles is in pages (one page is 8KB).
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "db" <db@.discussions.microsoft.com> wrote in message
>> news:BCE5FEFC-57F7-44B8-B23F-10CED667E7FB@.microsoft.com...
>> > When i select size of files using sql server using
>> > "select name,filename,size from sysaltfiles" I get size of files as
>> >
>> > File one size: file1.mdf = 4976
>> > File two size: file2.ldf = 2504
>> > File three size file3.mdf = 1360
>> > File four size file4.ldf = 13408
>> >
>> > When I see the size of files in the disk using windows explorer I get
>> > different size
>> >
>> > File one size: 39804 kb
>> > File two size: 20032 kb
>> > File three size:10,880 kb
>> > File four size: 107,264 KB
>> >
>> > Why is that difference in file sizes?
>> > --
>> > ontario, canada
>> >
>> >
>> > "db" wrote:
>> >
>> >> Hi
>> >>
>> >> I need to provide following information:
>> >> 1. Size of all the current databases on all sql server (2000 and
>> >> 2005). Is
>> >> these a query I can use to get this information.
>> >> 2. Database size requirement for next three years.
>> >> 3. Backup space requirements (I know which database require simple and
>> >> which
>> >> transactional log database backups).
>> >> 4. Test database space requirements (I know which databases require
>> >> test
>> >> database).
>> >> 5. New SQL server reporting services (Server space requirement), I
>> >> know
>> >> which databases require a reporting server.
>> >> 6. Recommendation for RAID for live and test databases including
>> >> logging.
>> >>
>> >> Thanks
>> >> --
>> >> ontario, canadasql

Database Size

I want how can i do to do capacity planning in sqlserver 2000.
Do you make scripts (vbs) who query the sysfiles tables and transfer the answer in excel ?
Please help me.
Philselect cast(sum(m.[size]) * 8 as nvarchar)+N'KB' AS DB_SIZE, cast(sum(l.[size]) * 8 as varchar)+N'KB' AS LOG_SIZE
from dbo.[sysfiles] m, dbo.[sysfiles] l
where m.[groupid] != 0
and l.[groupid] = 0|||Thanks for your answer, can i query other database server with this query ?|||[servername].[database].[dbo].[sysfiles]

where the server and database have been linked to the SQL Server you are running the query from

Database Size

Hi,
Someone can telle how with a query can i get the use size of all my db of akll my server.
I use the table sysfiles but is the total size of my file and not the use size.
Thanks a lot and happy new year.
Best regards.Would looking at all the *.mdf/*.ldf files where you store them help?|||This question has been addressed a couple of times recently. Here's a link...

http://www.dbforums.com/t1006334.html

Regards,

hmscottsql

Wednesday, March 21, 2012

Database Setting for text box and text area forms

I have a SQL Server database. The data from a table is populated in the table and can do a regular display query on a record without issue.

Problem is when I pull the data into a form the data doesn't show up in some form fields for editing.

I am building a backend for the manager to make updates and changes and this is vital. Does anyone know if it has something to do with a database setting or has had a similar issue in the past?

The reason I think its a database setting is becuase the same table converted into MS Access has no problem populating the text boxs and text areas.

Your help is much needed and appreciated.

Thanks.In case anyone is interested. You can solve this with a work around. Set a vaiable for the field item then use the response.write the variable to popluate the text box or text area.

Database setting

. The BPA recommend that the model database setting for the items below be set to on. I can accomplish this task through the query analyzer and run the set command. (Set ANSI_NULLS on). The response is positive but when I re-run the report the setting are back off.

Why?

QUOTED_IDENTIFIER
ANSI_NULLS
ANSI_WARNINGS
ANSI_PADDING
ANSI_NULL_DFLT_ON
CONCAT_NULL_YIELDS_NULLDon't the setting only last for the scope of the session?

That's why they have to be coded inside the sporcs?

I'll have to look a more defenitive answer...but I'll just be fgetting from BOL|||Garry,

Those settings are only taking effect for that single session i.e. within Query Analyzer.

To make any permanent changes to the model database, you need to right click it in Query Analyzer and check the options under properties. You should save a copy of the database first in case you should find that you need to return to the default settings.

Please note carefully this article in case you need to reattach your model database:

http://support.microsoft.com/?id=224071

We would advise leaving the model database at default settings.

Use the following from Query Analyzer to check the settings:
Sp_helpdb
And also check for databaseproperty in Books Online
Syntax
DATABASEPROPERTY( database , property )

USE master

SELECT DATABASEPROPERTY('model', 'IsANSINullDEFAULT')|||Well its up to you, but most people would leave the model database alone. It depends on your particular needs more than anything else. Remember the model database is only a template used to create new databases, so if you are bringing databases to this machine from another server, then the model database settings will have no effect.

Any conflict here is due to ANSI compatibility levels. SQL Server does not always default to the ANSI compatible levels.

Please review this article for a note on the various database settings and their effects:-

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_03_6ohf.asp

These two commands give you information on your current connection details, and on the database settings that may be configured respectively:-

sp_dboption

dbcc useroptions|||why did you post the question if you already had the answer?|||Perhaps it was a rhetorical question?

Read the top of his posts. He was just copying information from MicroCoughed.sql

Monday, March 19, 2012

Database script creation

In the paste I have used SQL2000 to create db from the Query Analyser. In SQL2005 I can't see Query Analzyer but found under programs --> Microsoft SQL Server 2005 --> Configuration Tools --> Reporting Services Configuration --> Database Setup. It creates a database and I can connect to it from VS.NET. Here is my dilema, I was provided SQL scripts to create tables, stored procs etc. Where and how do I run these scripts to create these things in my newly create db.

Also how do I remove a db in SQL2005?

You can run your scripts from the command line via sqlcmd.exe or what I suggest you really do is download SQL Server Management Studio - Express Edition, that is a lightweight replacement for QA and EM, but for Express|||

Excellent suggestion... SQL Server Management Studio was exactly what I was looking for.

Thanks!

Sunday, March 11, 2012

Database Role/User Query

Anyone have a tsql query that will give me a listing of database roles and their users already put together?try sp_helpuser with no arguments.

Database Restore Woes

I attempt to back up a database on one server and restore it on my local machine.

This is what the query text looks like:

restore database model from
Disk='c:\JQJ\mydump\model.bak'
with replace

I get this error:

The backup of the system database on device c:\JQJ\mydump\model.bak cannot be restored because it was created by a
different version of the server
(134217922) than this server (134218488).

The other server product version is: 8.00.194(RTM)
The server on my machine is 8.00.760(SP3)

1.How can I make this restore work? Seems to me I have the later version, so I should be able to handle it. Mine is a
10-user, and the other is enterprise.

2.Also I need to be able to force a different path and even database name: The source server where I create the backup file
may have a different location than I have on my machine, so what parameters can I give the command so that it will use the
location I specifiy? The backup file will have the location information relative to the source server, which I can not
always use. This means I will need to programatically extract that location information on my machine. (I can't hard code
it, since other people with different installation setups will use my program on their machines).

3.The database name on the source server may be ABC, but I may want to restore over XYZ. How can I force that? Perhaps it
would be the same parameter I need for 2.

Thanks,

JonJon Jacobs (JonJacobsAtcomcast.net) writes:
> I attempt to back up a database on one server and restore it on my local
> machine.
> This is what the query text looks like:
> restore database model from
> Disk='c:\JQJ\mydump\model.bak'
> with replace
> I get this error:
> The backup of the system database on device c:\JQJ\mydump\model.bak
> cannot be restored because it was created by a different version of the
> server (134217922) than this server (134218488).
> The other server product version is: 8.00.194(RTM)
> The server on my machine is 8.00.760(SP3)
> 1.How can I make this restore work? Seems to me I have the later
> version, so I should be able to handle it. Mine is a 10-user, and the
> other is enterprise.

I would expect that it is possible to restore a backup from SQL 2000
RTM on SQL 2000 SP3, but it is very clear that it is not possible in
this case. But then again, you are not restoring any database - you
are restoring model. That's a system database, so I assume it is special.

Question: are you restoring model, because you really need a copy of model
from the other box on your machine? Or did you just pick model as a test
case? In the former case, the easiest may be to script any user objects
you have in model, and run the script. I would not really expect that
you have any data in model. If you are just testing, try Northwind or
pubs instead.

> 2.Also I need to be able to force a different path and even database
> name: The source server where I create the backup file may have a
> different location than I have on my machine, so what parameters can I
> give the command so that it will use the location I specifiy?

You use MOVE:

RESTORE DATABASE mydatase FROM disk = 'C:\temp\mydump.bak'
WITH MOVE 'mydatabase_data' TO 'e:\mylocation\mydatabase.mdf',
MOVE 'mydatabase_log' TO 'f:\myloglocation\mydatabase.ldf',
REPLACE

It does not seem that you can use variable in place of the device
and paths, but you could build the BACKUP command dynamically and
execute with EXEC(@.sql).

> 3.The database name on the source server may be ABC, but I may want to
> restore over XYZ. How can I force that? Perhaps it would be the same
> parameter I need for 2.

RESTORE DATABASE XYZ ...

There is no law that says that the database you restore to must have
the same name as the source database.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||>Question: are you restoring model, because you really need a copy of model
>from the other box on your machine? Or did you just pick model as a test
>case? In the former case, the easiest may be to script any user objects
>you have in model, and run the script. I would not really expect that
>you have any data in model. If you are just testing, try Northwind or
>pubs instead.

Yes, Model was just for testing. I will try another database.

>You use MOVE:
> RESTORE DATABASE mydatase FROM disk = 'C:\temp\mydump.bak'
> WITH MOVE 'mydatabase_data' TO 'e:\mylocation\mydatabase.mdf',
> MOVE 'mydatabase_log' TO 'f:\myloglocation\mydatabase.ldf',
> REPLACE

Excellent. I will put that to use.

>It does not seem that you can use variable in place of the device
>and paths, but you could build the BACKUP command dynamically and
>execute with EXEC(@.sql).

I will need to build the command dynamically as you say. But first I need to extract the destination path. How?

>RESTORE DATABASE XYZ ...
>There is no law that says that the database you restore to must have
>the same name as the source database.

I've been trying that to no avail. Well, maybe it will work after I get the other issues resolved, but so far, the error
messages complain about the original database name.

Thank you very, very much.

Jon|||Jon Jacobs (JonJacobsAtcomcast.net) writes:
> I will need to build the command dynamically as you say. But first I
> need to extract the destination path. How?

Well, I silently passed over that question, since I can't really tell
from a distance where you want to have your databases.

But assuming that you want the database in the default location of the
server.

This information is stored in the registry of the server, and you can
retrieve it with xp_regread. However, this is a undocumented and
unsupported function. (Note also that with SQL 2000 SP4, the function
will be restricted to access to SQL Server own values.)

A somewhat more roundabout way of doing it, is this:

CREATE DATABASE temp
SELECT @.path = filename FROM sysdatabases WHERE name = 'temp'
SELECT @.path = replace(@.path, '//', '/')
SELECT @.path = substring(@.path, 1, len(@.path) - len('temp.mdf'))
DROP DATABASE temp

>>RESTORE DATABASE XYZ ...
>>
>>There is no law that says that the database you restore to must have
>>the same name as the source database.
> I've been trying that to no avail. Well, maybe it will work after I get
> the other issues resolved, but so far, the error messages complain about
> the original database name.

You to use WITH REPLACE in this case. Since you already had this in
your example, I did not mention this.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Thursday, March 8, 2012

Database restore help

Use Query Analyzer and run RESTORE FILELISTONLY for the backup file. Post
those results here. We'll follow up when we get those.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Gonzo" <no@.no123.com> wrote in message
news:523266A9-C34C-47F9-9C22-FC91A9E798E7@.microsoft.com...
I need to restore a database over an existing DB (I have made a backup and
it's SQL 2000).
When I do try and restore it via SQL Enterprose Manager 2000 (the only way I
know) it it says "logical file 'database' is not part of a database
'database2'. Use RESTORE FILELISTONLY to list the logocal file names.
RESTORE DATAVASE is terminating adbnormally.
Type:
use master
go
... before running the RESTORE. Also, be sure that no one is connected to
the DB when you restore it.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Gonzo" <no@.no123.com> wrote in message
news:863AE2DE-3B3B-4647-8AC6-6BFAE4FFDDEC@.microsoft.com...
Hi I get:
Server: Msg 3101, Level 16, State 1, Line 1
Exclusive access could not be obtained because the database is in use.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:%23SUif2MtHHA.4796@.TK2MSFTNGP04.phx.gbl...
> From QA, run:
> RESTORE DATABASE RM_test1
> FROM DISK = 'f:\MSSQL80\BACKUP\RM_test1.bak'
> WITH REPLACE
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
> SQL Server MVP
> Toronto, ON Canada
> https://mvp.support.microsoft.com/profile/Tom.Moreau
>
> "Gonzo" <no@.no123.com> wrote in message
> news:9F74A63C-2524-4AE0-AEAC-9E9853D66B30@.microsoft.com...
> Many thanks:
> RESTORE FILElISTONLY from Disk = 'f:\MSSQL80\BACKUP\RM_test1.bak'
> I get:
> Btest_Data C:\Program Files\Microsoft SQL Server\MSSQL\Data\BRITLIVE.mdf
> D PRIMARY
> Btest_Log C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\BRITLIVE_log.ldf L NULL
>
> On the server we have these DB's:
> Btest
> RM_test1
>
> We sent a company the Btest DB to make some changes that they have done
> and
> sent the bak file back. I need to restore this over the RM_test1 DB, but
> it
> seems that it still references the original Btest DB everywhere.
>
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
> news:OUAXLKMtHHA.4572@.TK2MSFTNGP02.phx.gbl...
>
|||Hi
That means that somebody is using the database while you are trying to
restore it. Make sure that nobody is accessing the database - including
the session you are restoring from...:-).
Regards
Steen Schlter Persson
Database Administrator / System Administrator
Gonzo wrote:
> Hi I get:
> Server: Msg 3101, Level 16, State 1, Line 1
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.
>
>
>
>
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
> news:%23SUif2MtHHA.4796@.TK2MSFTNGP04.phx.gbl...
>
|||There is still a connection to the db somewhere. SOmetimes EM doesn't show
it. Do a sp_helpdb, get the dbid of the database that you're dealing with, do
a select * from master..sysprocess where dbid = <whatever the dbid is>, get
the coresponding spid and kill <spid>, then try to restore.
MG
"Gonzo" wrote:

> Hi I get:
> Server: Msg 3101, Level 16, State 1, Line 1
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.
>
>
>
>
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
> news:%23SUif2MtHHA.4796@.TK2MSFTNGP04.phx.gbl...
>
|||You have to keep the logical names for the restore. You can change those
later.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Gonzo" <no@.no123.com> wrote in message
news:A4969E2E-1F25-484A-BDE3-91247145CD79@.microsoft.com...
It seems I can restore it using EM (tried on a test server) but only if i
keep the logical names. in E:\Program Files\Microsoft SQL Server\MSSQL\Data
the databse is RM_test1 but I right click on the database and go to
properties and then the tabs Data files and transaction log then the file
name is Btest_data and Btest_logs. Now a database on the live server is
already called 'Btest' will this cause a problem?
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:e4XJkINtHHA.3504@.TK2MSFTNGP05.phx.gbl...
> Type:
> use master
> go
> ... before running the RESTORE. Also, be sure that no one is connected
> to
> the DB when you restore it.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
> SQL Server MVP
> Toronto, ON Canada
> https://mvp.support.microsoft.com/profile/Tom.Moreau
>
> "Gonzo" <no@.no123.com> wrote in message
> news:863AE2DE-3B3B-4647-8AC6-6BFAE4FFDDEC@.microsoft.com...
> Hi I get:
> Server: Msg 3101, Level 16, State 1, Line 1
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.
>
>
>
>
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
> news:%23SUif2MtHHA.4796@.TK2MSFTNGP04.phx.gbl...
>
|||Use
Restore Database <db_name>
from Disk = 'f:\MSSQL80\BACKUP\RM_test1.bak'
WITH Move 'Btest_Data' To 'C:\Program Files\Microsoft SQL
Server\MSSQL\Data\BRITLIVE_2.mdf',
Move 'Btest_Log' To 'C:\Program Files\Microsoft SQL
Server\MSSQL\Data\BRITLIVE_2_log.ldf',
just change the name of the .mdf & .ldf to something that doesn't already
exist.
MG
"Gonzo" wrote:

> It seems I can restore it using EM (tried on a test server) but only if i
> keep the logical names. in E:\Program Files\Microsoft SQL Server\MSSQL\Data
> the databse is RM_test1 but I right click on the database and go to
> properties and then the tabs Data files and transaction log then the file
> name is Btest_data and Btest_logs. Now a database on the live server is
> already called 'Btest' will this cause a problem?
>
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
> news:e4XJkINtHHA.3504@.TK2MSFTNGP05.phx.gbl...
>
|||Check out ALTER DATABASE in the BOL.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Gonzo" <no@.no123.com> wrote in message
news:%23JzdGUNtHHA.768@.TK2MSFTNGP04.phx.gbl...
I have restored it now, how can I now change the logical names to something
else?
many thanks
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:O4i5xSNtHHA.3556@.TK2MSFTNGP05.phx.gbl...
> You have to keep the logical names for the restore. You can change those
> later.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
> SQL Server MVP
> Toronto, ON Canada
> https://mvp.support.microsoft.com/profile/Tom.Moreau
>
> "Gonzo" <no@.no123.com> wrote in message
> news:A4969E2E-1F25-484A-BDE3-91247145CD79@.microsoft.com...
> It seems I can restore it using EM (tried on a test server) but only if i
> keep the logical names. in E:\Program Files\Microsoft SQL
> Server\MSSQL\Data
> the databse is RM_test1 but I right click on the database and go to
> properties and then the tabs Data files and transaction log then the file
> name is Btest_data and Btest_logs. Now a database on the live server is
> already called 'Btest' will this cause a problem?
>
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
> news:e4XJkINtHHA.3504@.TK2MSFTNGP05.phx.gbl...
>
|||No. Logical names are local to the DB.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Gonzo" <no@.no123.com> wrote in message
news:28BF2F6F-4256-4299-BE76-1F1DAAB4D61F@.microsoft.com...
I now get:
Processed 9336 pages for database 'RM_test1', file 'Btest_Data' on file 1.
Processed 1 pages for database 'RM_test1', file 'Btest_Log' on file 1.
RESTORE DATABASE successfully processed 9337 pages in 13.278 seconds (5.760
MB/sec).
There is a database caleld Btest already uses Btest for it's database name
and logical name, will this create a problem with both having the same name?
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:e4XJkINtHHA.3504@.TK2MSFTNGP05.phx.gbl...
> Type:
> use master
> go
> ... before running the RESTORE. Also, be sure that no one is connected
> to
> the DB when you restore it.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
> SQL Server MVP
> Toronto, ON Canada
> https://mvp.support.microsoft.com/profile/Tom.Moreau
>
> "Gonzo" <no@.no123.com> wrote in message
> news:863AE2DE-3B3B-4647-8AC6-6BFAE4FFDDEC@.microsoft.com...
> Hi I get:
> Server: Msg 3101, Level 16, State 1, Line 1
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.
>
>
>
>
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
> news:%23SUif2MtHHA.4796@.TK2MSFTNGP04.phx.gbl...
>
|||Yep.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Gonzo" <no@.no123.com> wrote in message
news:46D17BBE-E208-4A83-942E-B7446A202C5A@.microsoft.com...
Woudl this be it? I would have to do this for both files I guess (this is
all new to me)
ALTER DATABASE
MODIFY FILE (NAME = logical_file_name, NEWNAME = new_logical_name...).
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:%23PPC$WNtHHA.4688@.TK2MSFTNGP05.phx.gbl...
> Check out ALTER DATABASE in the BOL.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
> SQL Server MVP
> Toronto, ON Canada
> https://mvp.support.microsoft.com/profile/Tom.Moreau
>
> "Gonzo" <no@.no123.com> wrote in message
> news:%23JzdGUNtHHA.768@.TK2MSFTNGP04.phx.gbl...
> I have restored it now, how can I now change the logical names to
> something
> else?
> many thanks
>
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
> news:O4i5xSNtHHA.3556@.TK2MSFTNGP05.phx.gbl...
>
|||Run:
sp_helpfile
...and post the results.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
https://mvp.support.microsoft.com/profile/Tom.Moreau
"Gonzo" <no@.no123.com> wrote in message
news:OKu6WmNtHHA.768@.TK2MSFTNGP04.phx.gbl...
Sorry about this, I'm now getting:
ALTER DATABASE RM_TEST1
MODIFY FILE (Btest_Data = logical_file_name, RM_test1_DATA =
new_logical_name...).
Server: Msg 155, Level 15, State 1, Line 2
'Btest_Data' is not a recognized CREATE/ALTER DATABASE option.
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:O$$Y4jNtHHA.4824@.TK2MSFTNGP06.phx.gbl...
> Yep.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
> SQL Server MVP
> Toronto, ON Canada
> https://mvp.support.microsoft.com/profile/Tom.Moreau
>
> "Gonzo" <no@.no123.com> wrote in message
> news:46D17BBE-E208-4A83-942E-B7446A202C5A@.microsoft.com...
> Woudl this be it? I would have to do this for both files I guess (this is
> all new to me)
> ALTER DATABASE
> MODIFY FILE (NAME = logical_file_name, NEWNAME = new_logical_name...).
>
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
> news:%23PPC$WNtHHA.4688@.TK2MSFTNGP05.phx.gbl...
>

Saturday, February 25, 2012

Database Relationship

Hi all,
Where can I see the Table relationship in Enterprise Manager. I see all
Tables but to run some query using two or more tables I need to know which
table is connected with that particular table. Can someone help me.
Thanks,
Betre
Two ways, and they only work if there is actually a defined relationship.
1. Look in the diagrams, or create a new one with the tables in question.
Anything you do here as far as adding/deleting may affect the actual table.
Its not just a picture...
2. Create a new view and add the tables. If the relationship has been
defined, it will fill in automatically
Kevin Hill
President
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"betrek" <betrek@.discussions.microsoft.com> wrote in message
news:1F84DE39-7EC6-4DA7-937B-0F8D8EDC90E9@.microsoft.com...
> Hi all,
> Where can I see the Table relationship in Enterprise Manager. I see all
> Tables but to run some query using two or more tables I need to know which
> table is connected with that particular table. Can someone help me.
> Thanks,
> Betre
|||Also, you can right click on tables and look at the design. Then right
click on columns and check out relationships, keys, indexes, etc.
Kevin3NF wrote:[vbcol=seagreen]
> Two ways, and they only work if there is actually a defined relationship.
> 1. Look in the diagrams, or create a new one with the tables in question.
> Anything you do here as far as adding/deleting may affect the actual table.
> Its not just a picture...
> 2. Create a new view and add the tables. If the relationship has been
> defined, it will fill in automatically
>
> --
> Kevin Hill
> President
> 3NF Consulting
> www.3nf-inc.com/NewsGroups.htm
>
> "betrek" <betrek@.discussions.microsoft.com> wrote in message
> news:1F84DE39-7EC6-4DA7-937B-0F8D8EDC90E9@.microsoft.com...

Database Relationship

Hi all,
Where can I see the Table relationship in Enterprise Manager. I see all
Tables but to run some query using two or more tables I need to know which
table is connected with that particular table. Can someone help me.
Thanks,
BetreTwo ways, and they only work if there is actually a defined relationship.
1. Look in the diagrams, or create a new one with the tables in question.
Anything you do here as far as adding/deleting may affect the actual table.
Its not just a picture...
2. Create a new view and add the tables. If the relationship has been
defined, it will fill in automatically
Kevin Hill
President
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"betrek" <betrek@.discussions.microsoft.com> wrote in message
news:1F84DE39-7EC6-4DA7-937B-0F8D8EDC90E9@.microsoft.com...
> Hi all,
> Where can I see the Table relationship in Enterprise Manager. I see all
> Tables but to run some query using two or more tables I need to know which
> table is connected with that particular table. Can someone help me.
> Thanks,
> Betre|||Also, you can right click on tables and look at the design. Then right
click on columns and check out relationships, keys, indexes, etc.
Kevin3NF wrote:[vbcol=seagreen]
> Two ways, and they only work if there is actually a defined relationship.
> 1. Look in the diagrams, or create a new one with the tables in question.
> Anything you do here as far as adding/deleting may affect the actual table
.
> Its not just a picture...
> 2. Create a new view and add the tables. If the relationship has been
> defined, it will fill in automatically
>
> --
> Kevin Hill
> President
> 3NF Consulting
> www.3nf-inc.com/NewsGroups.htm
>
> "betrek" <betrek@.discussions.microsoft.com> wrote in message
> news:1F84DE39-7EC6-4DA7-937B-0F8D8EDC90E9@.microsoft.com...

Database Relationship

Hi all,
Where can I see the Table relationship in Enterprise Manager. I see all
Tables but to run some query using two or more tables I need to know which
table is connected with that particular table. Can someone help me.
Thanks,
BetreTwo ways, and they only work if there is actually a defined relationship.
1. Look in the diagrams, or create a new one with the tables in question.
Anything you do here as far as adding/deleting may affect the actual table.
Its not just a picture...
2. Create a new view and add the tables. If the relationship has been
defined, it will fill in automatically
Kevin Hill
President
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
"betrek" <betrek@.discussions.microsoft.com> wrote in message
news:1F84DE39-7EC6-4DA7-937B-0F8D8EDC90E9@.microsoft.com...
> Hi all,
> Where can I see the Table relationship in Enterprise Manager. I see all
> Tables but to run some query using two or more tables I need to know which
> table is connected with that particular table. Can someone help me.
> Thanks,
> Betre|||Also, you can right click on tables and look at the design. Then right
click on columns and check out relationships, keys, indexes, etc.
Kevin3NF wrote:
> Two ways, and they only work if there is actually a defined relationship.
> 1. Look in the diagrams, or create a new one with the tables in question.
> Anything you do here as far as adding/deleting may affect the actual table.
> Its not just a picture...
> 2. Create a new view and add the tables. If the relationship has been
> defined, it will fill in automatically
>
> --
> Kevin Hill
> President
> 3NF Consulting
> www.3nf-inc.com/NewsGroups.htm
>
> "betrek" <betrek@.discussions.microsoft.com> wrote in message
> news:1F84DE39-7EC6-4DA7-937B-0F8D8EDC90E9@.microsoft.com...
> > Hi all,
> >
> > Where can I see the Table relationship in Enterprise Manager. I see all
> > Tables but to run some query using two or more tables I need to know which
> > table is connected with that particular table. Can someone help me.
> >
> > Thanks,
> >
> > Betre

Sunday, February 19, 2012

database question

I have an Access application that links to SQL Server tables via an ODBC link.

I execute the following query in the Access application,

SELECT customerName From customers Where stateCode = 'CA'

My question:

Who (Access, SQL Server or the ODBC provider) selects based on the state code?

Does SQL Server only return customerNames where stateCode = 'CA'
OR
Does SQL Server return ALL rows and let Access select the customerNames where stateCode = 'CA'
OR
Does SQL Server return ALL rows and let the ODBC provider select and return only the appropriate rows to Access?

Thanks for your helpThe cleanest way to determine this is to run the query while SQL Profiler is running, and see what gets passed to SQL Server. My guess is that Access only asks for the rows where stateCode is CA.|||Agree with D.R. However, from what I remember it depends on the ODBC driver. If the remote server (in this case SQL) implements a specific part of the ODBC capabiliies then it will do the query on the server, otherwise the client has to do it. I'm pretty sure SQL will implement that capability.

Database Query... Novice Alert...No Idea Where to Turn...

Hello,

I'm creating a website for a student organization at my university. Basically, I have an Excel file with a list of contacts that the members of our organization need to be able to search on our website.

The only field that I need our members to be able to search is "contact location." So for example, a member might want to know if our organization has any contacts in Spain, so the member would type "spain" into the "contact location search" field" and would get results.

I really don't known where to turn... I need the easiest thing that would be manageable for a novice. It doesn't need to be an intense search function; just something to make the website functional (so it obviously needs to be uploadable to a server; the server has PHP capability...no idea if that has any relevance). I've been searching around all day and have come across potentials like PHP, SQL, XML, etc. but have no idea which way to turn... I have Office and Adobe Studio programs at my disposal.

Thank you all-powerful and all-knowing web gods! I owe you my deepest gratitude!

Mikey
:beer:Start by finding out what type of resources you have at your disposal for the university. Whether you use ASP/ASP.NET/PHP/MYSQL/MSSQL will likely determine the appropriate choice. From there you'll have at least a starting point.

Database query performance

I have a database table. The table has number of fields. Out of those fields one is Company and
another is DateTime. The table has thousands of records. I want to get the most recent
record for each company. In order to do that I am using the following query

SELECT * from CompanyDetail AS X
WHERE [DateTime]=(SELECT max([DateTime]) FROM CompanyDetail WHERE Company=X.Company)
ORDER BY Company


Note: There is only one record exists for the given company on a given date

The problem is that this query is very slow. Am I doing something wrong or there could be another
alternative way to improve it ?

Thanks in advance
KDV


Your best bet is to ask this question in the Transact-SQL forum:
http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=85

David Sceppa
Microsoft

DataBase Query help

Here's my situation:

I've got a column in one table called PRODID, and each value in this column references 1 or more values, say OrderDates, and I was wondering whether it's possible to write a query that returns all the values in the PRODID along with the latest OrderDate of the relevant PRODID value into the following result set:

PRODID OrderDate
1 "Latest Date"
2 "Latest Date"

And so on. Latest Date refers to the DateTime shown under OrderDates.

All help appreciatedSELECT P.ProductID, MAX(O.OrderDate)
FROM Orders O
INNER JOIN Products P ON O.ProductID = P.ProductID
GROUP BY P.ProductID|||Thanks for that, but I was just wondering is there any way to modify that query so that if any values for ProdID do not have an orderDate, the result set also returns these ProdIds but with a null value for the OrderDate?|||Actually ignore my last post, I managed to modify it to suit my eact needs, thanks for showing me the code though

Database Query

Is it possible to return the column names from the database using a SQL query,
what i need to do is
SELECT * FROM FEATURES WHERE 'VALUE' = 'YES'

i have a table which has a list of features and if they are selected i store the value yes, otherwise no . i want to be able to display a list of the features from the tables which have the value yes ! is this possible?yes xcept you dont need quotes around the column name..


SELECT * FROM FEATURES WHERE VALUE = 'YES'

hth|||Cheers but I worded the problem badly, VALUE isnt the name of the column, their are a number of different columns, each with different names, and i only want to display the column name if the value is yes ! any idea's?|||you wound then need to use CASE statement...check BOL for xact syntax but its something like


...
CASE
WHEN
colname='yes' then colname
ELSE NULL

hth|||what is BOL?|||BOL = Books Online

It is SQL Server's documentation.