Sunday, March 25, 2012
A Count of Counts?
Any pointers greatly appreciated!
Thanks,
jdkselect count(*)
from
where
group by xxx having count(*) > 5|||Originally posted by N-ary
select count(*)
from
where
group by xxx having count(*) > 5
Thanks!! I'm still validating results, but this appears to have been just what I needed.
jdk
Thursday, March 8, 2012
7.0 to 2000 Upgrade
1. Backup the databases.
2. Move the database mdf and ldf files to a neutral
location on the server's drive.
3. Upgrade the server to Win 2k and Sql Server 2000.
4. Add pertinent logins.
5. Reattach the mdf and ldf files and let sql server
upgrade the databases "on the fly".
The reason I'm asking is that I've always been ultra-safe
in times past and used the copy wizard to copy my 7.0
databases to a 2000 server first.
Is an attach/reattach considered a supported way of doing
a 7.0 to 2000 conversion?
I'm a little scared of course because if it doesn't attach
for some reason, then I can try the .BAK files and if that
doesn't work, I'm dead.It is hard to find documentation that provides it one way or another.
However, iny my experience of doing it Attach/reattaching works fine. Just
make sure you have a backup copy of your databases becauase you'll not be
able to reattach them to a SQL 7.0 server after attaching them to SQL 2000.
The only concerns I can think of have to do more with the sort order, which
would show up when people start to connect and use the system. SQL 2000
supports attaching databases with different sort orders, but some stored
procedures that create temp tables may have issues without having the
collation order specified for them. Only thorough testing will reveal a
problem like this.
My *safest method* is to use DTS to transfer the databases to another
server, then copy them back.
--
*******************************************************************
Andy S.
MCSE NT/2000, MCDBA SQL 7/2000
andymcdba1@.NOMORESPAM.yahoo.com
Please remove NOMORESPAM before replying.
Always keep your antivirus and Microsoft software
up to date with the latest definitions and product updates.
Be suspicious of every email attachment, I will never send
or post anything other than the text of a http:// link nor
post the link directly to a file for downloading.
This posting is provided "as is" with no warranties
and confers no rights.
*******************************************************************
"CLM" <anonymous@.discussions.microsoft.com> wrote in message
news:121bf01c3f57c$ec04e740$a501280a@.phx.gbl...
> Is this a reasonable way to upgrade a 7.0 server to 2000?
> 1. Backup the databases.
> 2. Move the database mdf and ldf files to a neutral
> location on the server's drive.
> 3. Upgrade the server to Win 2k and Sql Server 2000.
> 4. Add pertinent logins.
> 5. Reattach the mdf and ldf files and let sql server
> upgrade the databases "on the fly".
> The reason I'm asking is that I've always been ultra-safe
> in times past and used the copy wizard to copy my 7.0
> databases to a 2000 server first.
> Is an attach/reattach considered a supported way of doing
> a 7.0 to 2000 conversion?
> I'm a little scared of course because if it doesn't attach
> for some reason, then I can try the .BAK files and if that
> doesn't work, I'm dead.
>|||If you are going to upgrade Windows, I'd recommend
reinstalling everything from scratch. Our experience with
Windows upgrading in place is that it works successfully
30% of the time or less. And if it fails, it can fail
really hard (blue screen on a system that will never boot
again, i.e., total data loss).
SQL Server upgrades (without upgrading the OS) usually
work. One thing you *MUST* do, however, is install the
latest MDAC prior to beginning the SQL Server upgrade.
If you are worried about the integrity of the databases or
their backups, be sure to do a DBCC CHECKDB on all your
databases before you start this. Fix any problems before
taking your backups or detaching.
Also, keep records of all the logical *and* physical file
names (including the disk drive letters/file paths) for
*every* database file! You might need to know these to
get a restore or attach to work. This information can be
recorded from your existing installation only as long as
the databases are still attached, so get it first.
Regarding one of your questions: Both the attach and
restore SQL operations will automatically convert a SQL 7
database to SQL 2000.
P.S. It isn't really necessary to detach the databases to
copy them. You can copy the files safely as long as SQL
Server is stopped.
--Scott
>--Original Message--
>Is this a reasonable way to upgrade a 7.0 server to 2000?
>1. Backup the databases.
>2. Move the database mdf and ldf files to a neutral
>location on the server's drive.
>3. Upgrade the server to Win 2k and Sql Server 2000.
>4. Add pertinent logins.
>5. Reattach the mdf and ldf files and let sql server
>upgrade the databases "on the fly".
>The reason I'm asking is that I've always been ultra-safe
>in times past and used the copy wizard to copy my 7.0
>databases to a 2000 server first.
>Is an attach/reattach considered a supported way of doing
>a 7.0 to 2000 conversion?
>I'm a little scared of course because if it doesn't
attach
>for some reason, then I can try the .BAK files and if
that
>doesn't work, I'm dead.
>.
>
Sunday, February 12, 2012
4 Transaction Log questions
Disk>\Program Files\Microsoft SQL Server\MSSQL\Data\MyDb_Log.ldf?
2) Is it safe to delete it, as SQL will create a new Transaction Log when it
realises none already exist?
3) When trying to do 2) I get error message that file is in use, even though
SQL Server is closed. Any suggestions?
4) Can anyone shed light on the error message 'Write on ... <my path
here>... failed, status = 112. BACKUP LOG is terminating abnormally'? I get
this when trying to manually backup the Transaction Log 'All Tasks - Backup'
Thanks for any replies to my ignorance.See inline:
"TZoner" <tzoner@.hotmail.com> wrote in message
news:3ef952a0$0$31277$afc38c87@.news.optusnet.com.a u...
> 1) Can one find the location of the 'Transaction Log' at: <Hard
> Disk>\Program Files\Microsoft SQL Server\MSSQL\Data\MyDb_Log.ldf?
I am not sure what you are asking but sp_helpfile will give the names and
locations of the files associated with a current database.
> 2) Is it safe to delete it, as SQL will create a new Transaction Log when
it
> realises none already exist?
I would not recommend deleting any logfile. If SQLServer is running then you
won't be able to as the file is locked. If you have detatched the database
or SQL Server is not running, you may have problems re-attaching the
database or connecting to it once SQL Server is running.
> 3) When trying to do 2) I get error message that file is in use, even
though
> SQL Server is closed. Any suggestions?
I doubt if you have stopped the service, but in any case you should not be
deleting it.
If all you want to do is move the file then check out
http://support.microsoft.com/defaul...kb;EN-US;224071
If you want to shrink it check out
http://msdn.microsoft.com/library/d...-us/architec/8_
ar_da2_1uzr.asp
> 4) Can anyone shed light on the error message 'Write on ... <my path
> here>... failed, status = 112. BACKUP LOG is terminating abnormally'? I
get
> this when trying to manually backup the Transaction Log 'All Tasks -
Backup'
I don't know what this error is, at a guess there is a lack of disk space.
Maybe there is more information in the SQL Server log file or in the Event
log. You will also get errors if you backup to a mapped network drive.
John
>
> Thanks for any replies to my ignorance.|||John, thanks for the valuable information.
Where is the 'Transaction Log' located? I can't find the answer sp_helpfile
or after endless searches on google.
Does a Transaction Log exist per database in SQL Server? When backup occurs,
does these Transaction Log shrink?
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:3ef95a3b$0$18495$ed9e5944@.reading.news.pipex. net...
> See inline:
> "TZoner" <tzoner@.hotmail.com> wrote in message
> news:3ef952a0$0$31277$afc38c87@.news.optusnet.com.a u...
> > 1) Can one find the location of the 'Transaction Log' at: <Hard
> > Disk>\Program Files\Microsoft SQL Server\MSSQL\Data\MyDb_Log.ldf?
> I am not sure what you are asking but sp_helpfile will give the names and
> locations of the files associated with a current database.
> > 2) Is it safe to delete it, as SQL will create a new Transaction Log
when
> it
> > realises none already exist?
> I would not recommend deleting any logfile. If SQLServer is running then
you
> won't be able to as the file is locked. If you have detatched the database
> or SQL Server is not running, you may have problems re-attaching the
> database or connecting to it once SQL Server is running.
> > 3) When trying to do 2) I get error message that file is in use, even
> though
> > SQL Server is closed. Any suggestions?
> I doubt if you have stopped the service, but in any case you should not be
> deleting it.
> If all you want to do is move the file then check out
> http://support.microsoft.com/defaul...kb;EN-US;224071
> If you want to shrink it check out
http://msdn.microsoft.com/library/d...-us/architec/8_
> ar_da2_1uzr.asp
> > 4) Can anyone shed light on the error message 'Write on ... <my path
> > here>... failed, status = 112. BACKUP LOG is terminating abnormally'? I
> get
> > this when trying to manually backup the Transaction Log 'All Tasks -
> Backup'
> I don't know what this error is, at a guess there is a lack of disk space.
> Maybe there is more information in the SQL Server log file or in the Event
> log. You will also get errors if you backup to a mapped network drive.
> John
> > Thanks for any replies to my ignorance.|||Your transction logs are held in the ldf file which sp_help would give e.g
for Northwind you would get something like:
Name FileId filename filegroup Size Maxsize Growth Usage
Northwind 1 E:\MSSQL\DATA\northwnd.mdf PRIMARY 3008 KB
Unlimited 10% data only
Northwind_log 2 E:\MSSQL\DATA\northwnd.ldf NULL 1024 KB Unlimited
10% log only
Northwind_log is the internal logical name for the Transaction Log file
located at E:\MSSQL\DATA\northwnd.ldf. The log only usage shows it is a log
file.
The log file will not automatically shrink on backup, see the link I posted
in the last reply regarding how to shrink it.
John
"TZoner" <tzoner@.hotmail.com> wrote in message
news:3ef9813b$0$31280$afc38c87@.news.optusnet.com.a u...
> John, thanks for the valuable information.
> Where is the 'Transaction Log' located? I can't find the answer
sp_helpfile
> or after endless searches on google.
> Does a Transaction Log exist per database in SQL Server? When backup
occurs,
> does these Transaction Log shrink?
>
>
>
>
>
>
>
> "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> news:3ef95a3b$0$18495$ed9e5944@.reading.news.pipex. net...
> > See inline:
> > "TZoner" <tzoner@.hotmail.com> wrote in message
> > news:3ef952a0$0$31277$afc38c87@.news.optusnet.com.a u...
> > > 1) Can one find the location of the 'Transaction Log' at: <Hard
> > > Disk>\Program Files\Microsoft SQL Server\MSSQL\Data\MyDb_Log.ldf?
> > I am not sure what you are asking but sp_helpfile will give the names
and
> > locations of the files associated with a current database.
> > > > 2) Is it safe to delete it, as SQL will create a new Transaction Log
> when
> > it
> > > realises none already exist?
> > I would not recommend deleting any logfile. If SQLServer is running then
> you
> > won't be able to as the file is locked. If you have detatched the
database
> > or SQL Server is not running, you may have problems re-attaching the
> > database or connecting to it once SQL Server is running.
> > > > 3) When trying to do 2) I get error message that file is in use, even
> > though
> > > SQL Server is closed. Any suggestions?
> > I doubt if you have stopped the service, but in any case you should not
be
> > deleting it.
> > If all you want to do is move the file then check out
> > http://support.microsoft.com/defaul...kb;EN-US;224071
> > If you want to shrink it check out
http://msdn.microsoft.com/library/d...-us/architec/8_
> > ar_da2_1uzr.asp
> > > > 4) Can anyone shed light on the error message 'Write on ... <my path
> > > here>... failed, status = 112. BACKUP LOG is terminating abnormally'?
I
> > get
> > > this when trying to manually backup the Transaction Log 'All Tasks -
> > Backup'
> > I don't know what this error is, at a guess there is a lack of disk
space.
> > Maybe there is more information in the SQL Server log file or in the
Event
> > log. You will also get errors if you backup to a mapped network drive.
> > John
> > > > > Thanks for any replies to my ignorance.
> > >|||John you've nearly solved my dilemma!!
As per your excellent like I was able to work out that running the 2
following lines will reduce the Transaction File back to it's size!!!
Hooray!!
BACKUP LOG MyDb WITH TRUNCATE_ONLY
DBCC SHRINKFILE (MyDb_log)
However, because MyDb has it's Transaction File full, hence I can't execute
the above two lines. How do I run these commands when MyDb won't let me do
anything to it? To test that the two commands worked I created a dummy MyDb,
grew its Transaction File then executed the two lines and it worked 100%.
Thank you so much for your suggestions!
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:3ef98e4f$0$10627$ed9e5944@.reading.news.pipex. net...
> Your transction logs are held in the ldf file which sp_help would give e.g
> for Northwind you would get something like:
> Name FileId filename filegroup Size Maxsize Growth Usage
> Northwind 1 E:\MSSQL\DATA\northwnd.mdf PRIMARY 3008 KB
> Unlimited 10% data only
> Northwind_log 2 E:\MSSQL\DATA\northwnd.ldf NULL 1024 KB Unlimited
> 10% log only
> Northwind_log is the internal logical name for the Transaction Log file
> located at E:\MSSQL\DATA\northwnd.ldf. The log only usage shows it is a
log
> file.
> The log file will not automatically shrink on backup, see the link I
posted
> in the last reply regarding how to shrink it.
> John
> "TZoner" <tzoner@.hotmail.com> wrote in message
> news:3ef9813b$0$31280$afc38c87@.news.optusnet.com.a u...
> > John, thanks for the valuable information.
> > Where is the 'Transaction Log' located? I can't find the answer
> sp_helpfile
> > or after endless searches on google.
> > Does a Transaction Log exist per database in SQL Server? When backup
> occurs,
> > does these Transaction Log shrink?
> > "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> > news:3ef95a3b$0$18495$ed9e5944@.reading.news.pipex. net...
> > > See inline:
> > > "TZoner" <tzoner@.hotmail.com> wrote in message
> > > news:3ef952a0$0$31277$afc38c87@.news.optusnet.com.a u...
> > > > 1) Can one find the location of the 'Transaction Log' at: <Hard
> > > > Disk>\Program Files\Microsoft SQL Server\MSSQL\Data\MyDb_Log.ldf?
> > > I am not sure what you are asking but sp_helpfile will give the names
> and
> > > locations of the files associated with a current database.
> > > > > > 2) Is it safe to delete it, as SQL will create a new Transaction Log
> > when
> > > it
> > > > realises none already exist?
> > > I would not recommend deleting any logfile. If SQLServer is running
then
> > you
> > > won't be able to as the file is locked. If you have detatched the
> database
> > > or SQL Server is not running, you may have problems re-attaching the
> > > database or connecting to it once SQL Server is running.
> > > > > > > 3) When trying to do 2) I get error message that file is in use,
even
> > > though
> > > > SQL Server is closed. Any suggestions?
> > > I doubt if you have stopped the service, but in any case you should
not
> be
> > > deleting it.
> > > If all you want to do is move the file then check out
> > > http://support.microsoft.com/defaul...kb;EN-US;224071
> > > > If you want to shrink it check out
> http://msdn.microsoft.com/library/d...-us/architec/8_
> > > ar_da2_1uzr.asp
> > > > > > > 4) Can anyone shed light on the error message 'Write on ... <my path
> > > > here>... failed, status = 112. BACKUP LOG is terminating
abnormally'?
> I
> > > get
> > > > this when trying to manually backup the Transaction Log 'All Tasks -
> > > Backup'
> > > I don't know what this error is, at a guess there is a lack of disk
> space.
> > > Maybe there is more information in the SQL Server log file or in the
> Event
> > > log. You will also get errors if you backup to a mapped network drive.
> > > > John
> > > > > > > > Thanks for any replies to my ignorance.
> > > > > > > >|||Hi
I am not sure what you mean by not work. As in the link previously posted,
if you last virtual log is in use the file will not shrink
"TZoner" <tzoner@.hotmail.com> wrote in message
news:3ef9a575$0$31280$afc38c87@.news.optusnet.com.a u...
> John you've nearly solved my dilemma!!
> As per your excellent like I was able to work out that running the 2
> following lines will reduce the Transaction File back to it's size!!!
> Hooray!!
> BACKUP LOG MyDb WITH TRUNCATE_ONLY
> DBCC SHRINKFILE (MyDb_log)
> However, because MyDb has it's Transaction File full, hence I can't
execute
> the above two lines. How do I run these commands when MyDb won't let me do
> anything to it? To test that the two commands worked I created a dummy
MyDb,
> grew its Transaction File then executed the two lines and it worked 100%.
> Thank you so much for your suggestions!
>
>
>
>
>
>
> "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> news:3ef98e4f$0$10627$ed9e5944@.reading.news.pipex. net...
> > Your transction logs are held in the ldf file which sp_help would give
e.g
> > for Northwind you would get something like:
> > Name FileId filename filegroup Size Maxsize Growth
Usage
> > Northwind 1 E:\MSSQL\DATA\northwnd.mdf PRIMARY 3008 KB
> > Unlimited 10% data only
> > Northwind_log 2 E:\MSSQL\DATA\northwnd.ldf NULL 1024 KB
Unlimited
> > 10% log only
> > Northwind_log is the internal logical name for the Transaction Log file
> > located at E:\MSSQL\DATA\northwnd.ldf. The log only usage shows it is a
> log
> > file.
> > The log file will not automatically shrink on backup, see the link I
> posted
> > in the last reply regarding how to shrink it.
> > John
> > "TZoner" <tzoner@.hotmail.com> wrote in message
> > news:3ef9813b$0$31280$afc38c87@.news.optusnet.com.a u...
> > > John, thanks for the valuable information.
> > > > Where is the 'Transaction Log' located? I can't find the answer
> > sp_helpfile
> > > or after endless searches on google.
> > > > Does a Transaction Log exist per database in SQL Server? When backup
> > occurs,
> > > does these Transaction Log shrink?
> > > > > > > > > > > > > > > > > > "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> > > news:3ef95a3b$0$18495$ed9e5944@.reading.news.pipex. net...
> > > > See inline:
> > > > "TZoner" <tzoner@.hotmail.com> wrote in message
> > > > news:3ef952a0$0$31277$afc38c87@.news.optusnet.com.a u...
> > > > > 1) Can one find the location of the 'Transaction Log' at: <Hard
> > > > > Disk>\Program Files\Microsoft SQL Server\MSSQL\Data\MyDb_Log.ldf?
> > > > I am not sure what you are asking but sp_helpfile will give the
names
> > and
> > > > locations of the files associated with a current database.
> > > > > > > > 2) Is it safe to delete it, as SQL will create a new Transaction
Log
> > > when
> > > > it
> > > > > realises none already exist?
> > > > I would not recommend deleting any logfile. If SQLServer is running
> then
> > > you
> > > > won't be able to as the file is locked. If you have detatched the
> > database
> > > > or SQL Server is not running, you may have problems re-attaching the
> > > > database or connecting to it once SQL Server is running.
> > > > > > > > > > 3) When trying to do 2) I get error message that file is in use,
> even
> > > > though
> > > > > SQL Server is closed. Any suggestions?
> > > > I doubt if you have stopped the service, but in any case you should
> not
> > be
> > > > deleting it.
> > > > If all you want to do is move the file then check out
> > > > http://support.microsoft.com/defaul...kb;EN-US;224071
> > > > > > If you want to shrink it check out
> > > http://msdn.microsoft.com/library/d...-us/architec/8_
> > > > ar_da2_1uzr.asp
> > > > > > > > > > 4) Can anyone shed light on the error message 'Write on ... <my
path
> > > > > here>... failed, status = 112. BACKUP LOG is terminating
> abnormally'?
> > I
> > > > get
> > > > > this when trying to manually backup the Transaction Log 'All
Tasks -
> > > > Backup'
> > > > I don't know what this error is, at a guess there is a lack of disk
> > space.
> > > > Maybe there is more information in the SQL Server log file or in the
> > Event
> > > > log. You will also get errors if you backup to a mapped network
drive.
> > > > > > John
> > > > > > > > > > > Thanks for any replies to my ignorance.
> > > > > > > > > > > > > > >|||Hi
I am not sure what you mean by the transaction log being full. It would
normally wrap around or expand if you have the disk space.
What does DBCC SQLPERF(LOGSPACE) say?
Have you looked at the output from DBCC OPENTRAN ( 'database_name' )?
You may want to look at:
http://www.support.microsoft.com/?id=256650
http://support.microsoft.com/defaul...kb;EN-US;110139
http://support.microsoft.com/defaul...=kb;EN-US;62866
John
"TZoner" <tzoner@.hotmail.com> wrote in message
news:3ef9a575$0$31280$afc38c87@.news.optusnet.com.a u...
> John you've nearly solved my dilemma!!
> As per your excellent like I was able to work out that running the 2
> following lines will reduce the Transaction File back to it's size!!!
> Hooray!!
> BACKUP LOG MyDb WITH TRUNCATE_ONLY
> DBCC SHRINKFILE (MyDb_log)
> However, because MyDb has it's Transaction File full, hence I can't
execute
> the above two lines. How do I run these commands when MyDb won't let me do
> anything to it? To test that the two commands worked I created a dummy
MyDb,
> grew its Transaction File then executed the two lines and it worked 100%.
> Thank you so much for your suggestions!
>
>
>
>
>
>
> "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> news:3ef98e4f$0$10627$ed9e5944@.reading.news.pipex. net...
> > Your transction logs are held in the ldf file which sp_help would give
e.g
> > for Northwind you would get something like:
> > Name FileId filename filegroup Size Maxsize Growth
Usage
> > Northwind 1 E:\MSSQL\DATA\northwnd.mdf PRIMARY 3008 KB
> > Unlimited 10% data only
> > Northwind_log 2 E:\MSSQL\DATA\northwnd.ldf NULL 1024 KB
Unlimited
> > 10% log only
> > Northwind_log is the internal logical name for the Transaction Log file
> > located at E:\MSSQL\DATA\northwnd.ldf. The log only usage shows it is a
> log
> > file.
> > The log file will not automatically shrink on backup, see the link I
> posted
> > in the last reply regarding how to shrink it.
> > John
> > "TZoner" <tzoner@.hotmail.com> wrote in message
> > news:3ef9813b$0$31280$afc38c87@.news.optusnet.com.a u...
> > > John, thanks for the valuable information.
> > > > Where is the 'Transaction Log' located? I can't find the answer
> > sp_helpfile
> > > or after endless searches on google.
> > > > Does a Transaction Log exist per database in SQL Server? When backup
> > occurs,
> > > does these Transaction Log shrink?
> > > > > > > > > > > > > > > > > > "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> > > news:3ef95a3b$0$18495$ed9e5944@.reading.news.pipex. net...
> > > > See inline:
> > > > "TZoner" <tzoner@.hotmail.com> wrote in message
> > > > news:3ef952a0$0$31277$afc38c87@.news.optusnet.com.a u...
> > > > > 1) Can one find the location of the 'Transaction Log' at: <Hard
> > > > > Disk>\Program Files\Microsoft SQL Server\MSSQL\Data\MyDb_Log.ldf?
> > > > I am not sure what you are asking but sp_helpfile will give the
names
> > and
> > > > locations of the files associated with a current database.
> > > > > > > > 2) Is it safe to delete it, as SQL will create a new Transaction
Log
> > > when
> > > > it
> > > > > realises none already exist?
> > > > I would not recommend deleting any logfile. If SQLServer is running
> then
> > > you
> > > > won't be able to as the file is locked. If you have detatched the
> > database
> > > > or SQL Server is not running, you may have problems re-attaching the
> > > > database or connecting to it once SQL Server is running.
> > > > > > > > > > 3) When trying to do 2) I get error message that file is in use,
> even
> > > > though
> > > > > SQL Server is closed. Any suggestions?
> > > > I doubt if you have stopped the service, but in any case you should
> not
> > be
> > > > deleting it.
> > > > If all you want to do is move the file then check out
> > > > http://support.microsoft.com/defaul...kb;EN-US;224071
> > > > > > If you want to shrink it check out
> > > http://msdn.microsoft.com/library/d...-us/architec/8_
> > > > ar_da2_1uzr.asp
> > > > > > > > > > 4) Can anyone shed light on the error message 'Write on ... <my
path
> > > > > here>... failed, status = 112. BACKUP LOG is terminating
> abnormally'?
> > I
> > > > get
> > > > > this when trying to manually backup the Transaction Log 'All
Tasks -
> > > > Backup'
> > > > I don't know what this error is, at a guess there is a lack of disk
> > space.
> > > > Maybe there is more information in the SQL Server log file or in the
> > Event
> > > > log. You will also get errors if you backup to a mapped network
drive.
> > > > > > John
> > > > > > > > > > > Thanks for any replies to my ignorance.
> > > > > > > > > > > > > > >|||Ooops!!!
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:3ef9abc1$0$10629$ed9e5944@.reading.news.pipex. net...
> Hi
> I am not sure what you mean by not work. As in the link previously posted,
> if you last virtual log is in use the file will not shrink
>
> "TZoner" <tzoner@.hotmail.com> wrote in message
> news:3ef9a575$0$31280$afc38c87@.news.optusnet.com.a u...
> > John you've nearly solved my dilemma!!
> > As per your excellent like I was able to work out that running the 2
> > following lines will reduce the Transaction File back to it's size!!!
> > Hooray!!
> > BACKUP LOG MyDb WITH TRUNCATE_ONLY
> > DBCC SHRINKFILE (MyDb_log)
> > However, because MyDb has it's Transaction File full, hence I can't
> execute
> > the above two lines. How do I run these commands when MyDb won't let me
do
> > anything to it? To test that the two commands worked I created a dummy
> MyDb,
> > grew its Transaction File then executed the two lines and it worked
100%.
> > Thank you so much for your suggestions!
> > "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> > news:3ef98e4f$0$10627$ed9e5944@.reading.news.pipex. net...
> > > Your transction logs are held in the ldf file which sp_help would give
> e.g
> > > for Northwind you would get something like:
> > > > Name FileId filename filegroup Size Maxsize Growth
> Usage
> > > Northwind 1 E:\MSSQL\DATA\northwnd.mdf PRIMARY 3008 KB
> > > Unlimited 10% data only
> > > Northwind_log 2 E:\MSSQL\DATA\northwnd.ldf NULL 1024 KB
> Unlimited
> > > 10% log only
> > > > Northwind_log is the internal logical name for the Transaction Log
file
> > > located at E:\MSSQL\DATA\northwnd.ldf. The log only usage shows it is
a
> > log
> > > file.
> > > > The log file will not automatically shrink on backup, see the link I
> > posted
> > > in the last reply regarding how to shrink it.
> > > > John
> > > > "TZoner" <tzoner@.hotmail.com> wrote in message
> > > news:3ef9813b$0$31280$afc38c87@.news.optusnet.com.a u...
> > > > John, thanks for the valuable information.
> > > > > > Where is the 'Transaction Log' located? I can't find the answer
> > > sp_helpfile
> > > > or after endless searches on google.
> > > > > > Does a Transaction Log exist per database in SQL Server? When backup
> > > occurs,
> > > > does these Transaction Log shrink?
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> > > > news:3ef95a3b$0$18495$ed9e5944@.reading.news.pipex. net...
> > > > > See inline:
> > > > > "TZoner" <tzoner@.hotmail.com> wrote in message
> > > > > news:3ef952a0$0$31277$afc38c87@.news.optusnet.com.a u...
> > > > > > 1) Can one find the location of the 'Transaction Log' at: <Hard
> > > > > > Disk>\Program Files\Microsoft SQL
Server\MSSQL\Data\MyDb_Log.ldf?
> > > > > I am not sure what you are asking but sp_helpfile will give the
> names
> > > and
> > > > > locations of the files associated with a current database.
> > > > > > > > > > 2) Is it safe to delete it, as SQL will create a new Transaction
> Log
> > > > when
> > > > > it
> > > > > > realises none already exist?
> > > > > I would not recommend deleting any logfile. If SQLServer is
running
> > then
> > > > you
> > > > > won't be able to as the file is locked. If you have detatched the
> > > database
> > > > > or SQL Server is not running, you may have problems re-attaching
the
> > > > > database or connecting to it once SQL Server is running.
> > > > > > > > > > > > > 3) When trying to do 2) I get error message that file is in use,
> > even
> > > > > though
> > > > > > SQL Server is closed. Any suggestions?
> > > > > I doubt if you have stopped the service, but in any case you
should
> > not
> > > be
> > > > > deleting it.
> > > > > If all you want to do is move the file then check out
> > > > > http://support.microsoft.com/defaul...kb;EN-US;224071
> > > > > > > > If you want to shrink it check out
> > > > > > http://msdn.microsoft.com/library/d...-us/architec/8_
> > > > > ar_da2_1uzr.asp
> > > > > > > > > > > > > 4) Can anyone shed light on the error message 'Write on ... <my
> path
> > > > > > here>... failed, status = 112. BACKUP LOG is terminating
> > abnormally'?
> > > I
> > > > > get
> > > > > > this when trying to manually backup the Transaction Log 'All
> Tasks -
> > > > > Backup'
> > > > > I don't know what this error is, at a guess there is a lack of
disk
> > > space.
> > > > > Maybe there is more information in the SQL Server log file or in
the
> > > Event
> > > > > log. You will also get errors if you backup to a mapped network
> drive.
> > > > > > > > John
> > > > > > > > > > > > > > Thanks for any replies to my ignorance.
> > > > > > > > > > > > > > > > > > > > > > > >|||John
BACKUP LOG MyDb WITH TRUNCATE_ONLY
DBCC SHRINKFILE (MyDb_log)
If a Transaction File has grown from originally 1Mb to 100Mb, executing the
above 2 lines in a stored procedure will shrink that Transaction File to as
close to 1Mb as possible. This is exactly what I urgently need to do.
However, if the Transaction File is full, hence I'm prevented from running
the stored procedure, how do I execute these 2 lines of code against MyDb?
I've tried using the Query Analyser. Line 1 executes correctly. However line
2 causes the error "Server: Msg 8985, Level 16, State 1, Line 1. Could not
locate file 'MyDb_Log' in sysfiles". I've manually verified that MyDb_Log
does indeed exist in the sysfiles table of MyDb.
Any suggestions?
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:3ef9abc1$0$10629$ed9e5944@.reading.news.pipex. net...
> Hi
> I am not sure what you mean by not work. As in the link previously posted,
> if you last virtual log is in use the file will not shrink
>
> "TZoner" <tzoner@.hotmail.com> wrote in message
> news:3ef9a575$0$31280$afc38c87@.news.optusnet.com.a u...
> > John you've nearly solved my dilemma!!
> > As per your excellent like I was able to work out that running the 2
> > following lines will reduce the Transaction File back to it's size!!!
> > Hooray!!
> > BACKUP LOG MyDb WITH TRUNCATE_ONLY
> > DBCC SHRINKFILE (MyDb_log)
> > However, because MyDb has it's Transaction File full, hence I can't
> execute
> > the above two lines. How do I run these commands when MyDb won't let me
do
> > anything to it? To test that the two commands worked I created a dummy
> MyDb,
> > grew its Transaction File then executed the two lines and it worked
100%.
> > Thank you so much for your suggestions!
> > "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> > news:3ef98e4f$0$10627$ed9e5944@.reading.news.pipex. net...
> > > Your transction logs are held in the ldf file which sp_help would give
> e.g
> > > for Northwind you would get something like:
> > > > Name FileId filename filegroup Size Maxsize Growth
> Usage
> > > Northwind 1 E:\MSSQL\DATA\northwnd.mdf PRIMARY 3008 KB
> > > Unlimited 10% data only
> > > Northwind_log 2 E:\MSSQL\DATA\northwnd.ldf NULL 1024 KB
> Unlimited
> > > 10% log only
> > > > Northwind_log is the internal logical name for the Transaction Log
file
> > > located at E:\MSSQL\DATA\northwnd.ldf. The log only usage shows it is
a
> > log
> > > file.
> > > > The log file will not automatically shrink on backup, see the link I
> > posted
> > > in the last reply regarding how to shrink it.
> > > > John
> > > > "TZoner" <tzoner@.hotmail.com> wrote in message
> > > news:3ef9813b$0$31280$afc38c87@.news.optusnet.com.a u...
> > > > John, thanks for the valuable information.
> > > > > > Where is the 'Transaction Log' located? I can't find the answer
> > > sp_helpfile
> > > > or after endless searches on google.
> > > > > > Does a Transaction Log exist per database in SQL Server? When backup
> > > occurs,
> > > > does these Transaction Log shrink?
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> > > > news:3ef95a3b$0$18495$ed9e5944@.reading.news.pipex. net...
> > > > > See inline:
> > > > > "TZoner" <tzoner@.hotmail.com> wrote in message
> > > > > news:3ef952a0$0$31277$afc38c87@.news.optusnet.com.a u...
> > > > > > 1) Can one find the location of the 'Transaction Log' at: <Hard
> > > > > > Disk>\Program Files\Microsoft SQL
Server\MSSQL\Data\MyDb_Log.ldf?
> > > > > I am not sure what you are asking but sp_helpfile will give the
> names
> > > and
> > > > > locations of the files associated with a current database.
> > > > > > > > > > 2) Is it safe to delete it, as SQL will create a new Transaction
> Log
> > > > when
> > > > > it
> > > > > > realises none already exist?
> > > > > I would not recommend deleting any logfile. If SQLServer is
running
> > then
> > > > you
> > > > > won't be able to as the file is locked. If you have detatched the
> > > database
> > > > > or SQL Server is not running, you may have problems re-attaching
the
> > > > > database or connecting to it once SQL Server is running.
> > > > > > > > > > > > > 3) When trying to do 2) I get error message that file is in use,
> > even
> > > > > though
> > > > > > SQL Server is closed. Any suggestions?
> > > > > I doubt if you have stopped the service, but in any case you
should
> > not
> > > be
> > > > > deleting it.
> > > > > If all you want to do is move the file then check out
> > > > > http://support.microsoft.com/defaul...kb;EN-US;224071
> > > > > > > > If you want to shrink it check out
> > > > > > http://msdn.microsoft.com/library/d...-us/architec/8_
> > > > > ar_da2_1uzr.asp
> > > > > > > > > > > > > 4) Can anyone shed light on the error message 'Write on ... <my
> path
> > > > > > here>... failed, status = 112. BACKUP LOG is terminating
> > abnormally'?
> > > I
> > > > > get
> > > > > > this when trying to manually backup the Transaction Log 'All
> Tasks -
> > > > > Backup'
> > > > > I don't know what this error is, at a guess there is a lack of
disk
> > > space.
> > > > > Maybe there is more information in the SQL Server log file or in
the
> > > Event
> > > > > log. You will also get errors if you backup to a mapped network
> drive.
> > > > > > > > John
> > > > > > > > > > > > > > Thanks for any replies to my ignorance.
> > > > > > > > > > > > > > > > > > > > > > > >|||Hi
Try using the file id instead of the logical file name.
sp_helpfile will give your bother the logical name and the file id.
John
"TZoner" <tzoner@.hotmail.com> wrote in message
news:3ef9aec4$0$31274$afc38c87@.news.optusnet.com.a u...
> John
> BACKUP LOG MyDb WITH TRUNCATE_ONLY
> DBCC SHRINKFILE (MyDb_log)
> If a Transaction File has grown from originally 1Mb to 100Mb, executing
the
> above 2 lines in a stored procedure will shrink that Transaction File to
as
> close to 1Mb as possible. This is exactly what I urgently need to do.
> However, if the Transaction File is full, hence I'm prevented from running
> the stored procedure, how do I execute these 2 lines of code against MyDb?
> I've tried using the Query Analyser. Line 1 executes correctly. However
line
> 2 causes the error "Server: Msg 8985, Level 16, State 1, Line 1. Could not
> locate file 'MyDb_Log' in sysfiles". I've manually verified that MyDb_Log
> does indeed exist in the sysfiles table of MyDb.
> Any suggestions?
>
>
>
>
>
> "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> news:3ef9abc1$0$10629$ed9e5944@.reading.news.pipex. net...
> > Hi
> > I am not sure what you mean by not work. As in the link previously
posted,
> > if you last virtual log is in use the file will not shrink
> > "TZoner" <tzoner@.hotmail.com> wrote in message
> > news:3ef9a575$0$31280$afc38c87@.news.optusnet.com.a u...
> > > John you've nearly solved my dilemma!!
> > > > As per your excellent like I was able to work out that running the 2
> > > following lines will reduce the Transaction File back to it's size!!!
> > > Hooray!!
> > > > BACKUP LOG MyDb WITH TRUNCATE_ONLY
> > > DBCC SHRINKFILE (MyDb_log)
> > > > However, because MyDb has it's Transaction File full, hence I can't
> > execute
> > > the above two lines. How do I run these commands when MyDb won't let
me
> do
> > > anything to it? To test that the two commands worked I created a dummy
> > MyDb,
> > > grew its Transaction File then executed the two lines and it worked
> 100%.
> > > > Thank you so much for your suggestions!
> > > > > > > > > > > > > > > > "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> > > news:3ef98e4f$0$10627$ed9e5944@.reading.news.pipex. net...
> > > > Your transction logs are held in the ldf file which sp_help would
give
> > e.g
> > > > for Northwind you would get something like:
> > > > > > Name FileId filename filegroup Size Maxsize Growth
> > Usage
> > > > Northwind 1 E:\MSSQL\DATA\northwnd.mdf PRIMARY 3008
KB
> > > > Unlimited 10% data only
> > > > Northwind_log 2 E:\MSSQL\DATA\northwnd.ldf NULL 1024 KB
> > Unlimited
> > > > 10% log only
> > > > > > Northwind_log is the internal logical name for the Transaction Log
> file
> > > > located at E:\MSSQL\DATA\northwnd.ldf. The log only usage shows it
is
> a
> > > log
> > > > file.
> > > > > > The log file will not automatically shrink on backup, see the link I
> > > posted
> > > > in the last reply regarding how to shrink it.
> > > > > > John
> > > > > > "TZoner" <tzoner@.hotmail.com> wrote in message
> > > > news:3ef9813b$0$31280$afc38c87@.news.optusnet.com.a u...
> > > > > John, thanks for the valuable information.
> > > > > > > > Where is the 'Transaction Log' located? I can't find the answer
> > > > sp_helpfile
> > > > > or after endless searches on google.
> > > > > > > > Does a Transaction Log exist per database in SQL Server? When
backup
> > > > occurs,
> > > > > does these Transaction Log shrink?
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> > > > > news:3ef95a3b$0$18495$ed9e5944@.reading.news.pipex. net...
> > > > > > See inline:
> > > > > > "TZoner" <tzoner@.hotmail.com> wrote in message
> > > > > > news:3ef952a0$0$31277$afc38c87@.news.optusnet.com.a u...
> > > > > > > 1) Can one find the location of the 'Transaction Log' at:
<Hard
> > > > > > > Disk>\Program Files\Microsoft SQL
> Server\MSSQL\Data\MyDb_Log.ldf?
> > > > > > I am not sure what you are asking but sp_helpfile will give the
> > names
> > > > and
> > > > > > locations of the files associated with a current database.
> > > > > > > > > > > > 2) Is it safe to delete it, as SQL will create a new
Transaction
> > Log
> > > > > when
> > > > > > it
> > > > > > > realises none already exist?
> > > > > > I would not recommend deleting any logfile. If SQLServer is
> running
> > > then
> > > > > you
> > > > > > won't be able to as the file is locked. If you have detatched
the
> > > > database
> > > > > > or SQL Server is not running, you may have problems re-attaching
> the
> > > > > > database or connecting to it once SQL Server is running.
> > > > > > > > > > > > > > > > 3) When trying to do 2) I get error message that file is in
use,
> > > even
> > > > > > though
> > > > > > > SQL Server is closed. Any suggestions?
> > > > > > I doubt if you have stopped the service, but in any case you
> should
> > > not
> > > > be
> > > > > > deleting it.
> > > > > > If all you want to do is move the file then check out
> > > > > > http://support.microsoft.com/defaul...kb;EN-US;224071
> > > > > > > > > > If you want to shrink it check out
> > > > > > > > > > http://msdn.microsoft.com/library/d...-us/architec/8_
> > > > > > ar_da2_1uzr.asp
> > > > > > > > > > > > > > > > 4) Can anyone shed light on the error message 'Write on ...
<my
> > path
> > > > > > > here>... failed, status = 112. BACKUP LOG is terminating
> > > abnormally'?
> > > > I
> > > > > > get
> > > > > > > this when trying to manually backup the Transaction Log 'All
> > Tasks -
> > > > > > Backup'
> > > > > > I don't know what this error is, at a guess there is a lack of
> disk
> > > > space.
> > > > > > Maybe there is more information in the SQL Server log file or in
> the
> > > > Event
> > > > > > log. You will also get errors if you backup to a mapped network
> > drive.
> > > > > > > > > > John
> > > > > > > > > > > > > > > > > Thanks for any replies to my ignorance.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >|||Hi there, I've also got the error "Server: Msg 8985, Level 16, State 1, Line 1. Could not locate file 'MyDb_Log' in sysfiles" when trying to shrink one of my databases's log files. I think I know the cause of the problem. When you de-attach a database, rename the database file and then re-attach the database then this error message will apear. The solution, delete that current database and create a new one but NEVER EVER rename the file name of the database
Saturday, February 11, 2012
3-way joins
cant remember it now...
I have three tables: Location, Hotels, PrefHotels
Locations: A list of locations that people in my company travel to.
Hotels: A list of hotel chains, inc URL etc that we may use
PrefHotels: Identifies preferred hotels for each location - consists of
LocationID from 1st table, and HotelID from 2nd table.
In my query, I want to list the preferred hotels (chains) for a given
location...
I've tied myself in knots with various JOINs and sub-selects...
Can anyone point me in the right direction please..
Cheers
ChrisThis is a multi-part message in MIME format.
--=_NextPart_000_0DBC_01C3B4CF.B3825940
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: 7bit
If you post your DDL, we can give a better solution:
select
ph.*
from
PrefHotels as ph
join
Hotels as h on h.HotelID = ph.HotelID
join
Locations as l on l.LocationID = ph.LocationID
where
l.Location = 'Grand Cayman'
--
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"CJM" <cjmwork@.yahoo.co.uk> wrote in message
news:epgVifPtDHA.1512@.TK2MSFTNGP10.phx.gbl...
I'm afraid my brain is melting on this one... I've done this before, but
cant remember it now...
I have three tables: Location, Hotels, PrefHotels
Locations: A list of locations that people in my company travel to.
Hotels: A list of hotel chains, inc URL etc that we may use
PrefHotels: Identifies preferred hotels for each location - consists of
LocationID from 1st table, and HotelID from 2nd table.
In my query, I want to list the preferred hotels (chains) for a given
location...
I've tied myself in knots with various JOINs and sub-selects...
Can anyone point me in the right direction please..
Cheers
Chris
--=_NextPart_000_0DBC_01C3B4CF.B3825940
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&
If you post your DDL, we can give a =better solution:
select
=ph.*
from
PrefHotels =as ph
join
Hotels as h =on h.HotelID =3D ph.HotelID
join
Locations as =l on l.LocationID =3D ph.LocationID
where
l.Location ==3D 'Grand Cayman'
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"CJM"
--=_NextPart_000_0DBC_01C3B4CF.B3825940--|||This is a multi-part message in MIME format.
--=_NextPart_000_006A_01C3B4FB.64A8F050
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
Tom thanks for that... but once again I have been an idoit! For a change =I'm working in Access 2k!
Before I repost to an Access group, would you happen to know the =difference between Access and SQLServer - ie I tried this SQL in Access =but it didn't work - Syntax error of some sort...
Cheers
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:%23jGhfmPtDHA.3416@.tk2msftngp13.phx.gbl...
If you post your DDL, we can give a better solution:
select
ph.*
from
PrefHotels as ph
join
Hotels as h on h.HotelID =3D ph.HotelID
join
Locations as l on l.LocationID =3D ph.LocationID
where
l.Location =3D 'Grand Cayman'
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"CJM" <cjmwork@.yahoo.co.uk> wrote in message =news:epgVifPtDHA.1512@.TK2MSFTNGP10.phx.gbl...
I'm afraid my brain is melting on this one... I've done this before, =but
cant remember it now...
I have three tables: Location, Hotels, PrefHotels
Locations: A list of locations that people in my company travel to.
Hotels: A list of hotel chains, inc URL etc that we may use
PrefHotels: Identifies preferred hotels for each location - consists =of
LocationID from 1st table, and HotelID from 2nd table.
In my query, I want to list the preferred hotels (chains) for a given
location...
I've tied myself in knots with various JOINs and sub-selects...
Can anyone point me in the right direction please..
Cheers
Chris
--=_NextPart_000_006A_01C3B4FB.64A8F050
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&
Tom thanks for that... but once again I =have been an idoit! For a change I'm working in Access 2k!
Before I repost to an Access group, =would you happen to know the difference between Access and SQLServer - ie I tried =this SQL in Access but it didn't work - Syntax error of some sort...
Cheers
"Tom Moreau"
If you post your DDL, we can give a =better solution:
select
=ph.*
from
PrefHotels =as ph
join
Hotels as =h on h.HotelID =3D ph.HotelID
join
Locations =as l on l.LocationID =3D ph.LocationID
where
l.Location ==3D 'Grand Cayman'
-- Tom
=---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"CJM"
--=_NextPart_000_006A_01C3B4FB.64A8F050--|||This is a multi-part message in MIME format.
--=_NextPart_000_0E18_01C3B4D4.32C825F0
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: 7bit
Well, I haven't done any Access SQL in a long time. You could try changing
the JOIN to INNER JOIN, listing the columns explicitly, instead of ph.* and
using double quotes vs. single quotes.
You're probably best to take my query to the Access newsgroup and see what
you can get.
--
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"CJM" <cjmwork@.yahoo.co.uk> wrote in message
news:udVDmtPtDHA.684@.TK2MSFTNGP09.phx.gbl...
Tom thanks for that... but once again I have been an idoit! For a change I'm
working in Access 2k!
Before I repost to an Access group, would you happen to know the difference
between Access and SQLServer - ie I tried this SQL in Access but it didn't
work - Syntax error of some sort...
Cheers
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:%23jGhfmPtDHA.3416@.tk2msftngp13.phx.gbl...
If you post your DDL, we can give a better solution:
select
ph.*
from
PrefHotels as ph
join
Hotels as h on h.HotelID = ph.HotelID
join
Locations as l on l.LocationID = ph.LocationID
where
l.Location = 'Grand Cayman'
--
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"CJM" <cjmwork@.yahoo.co.uk> wrote in message
news:epgVifPtDHA.1512@.TK2MSFTNGP10.phx.gbl...
I'm afraid my brain is melting on this one... I've done this before, but
cant remember it now...
I have three tables: Location, Hotels, PrefHotels
Locations: A list of locations that people in my company travel to.
Hotels: A list of hotel chains, inc URL etc that we may use
PrefHotels: Identifies preferred hotels for each location - consists of
LocationID from 1st table, and HotelID from 2nd table.
In my query, I want to list the preferred hotels (chains) for a given
location...
I've tied myself in knots with various JOINs and sub-selects...
Can anyone point me in the right direction please..
Cheers
Chris
--=_NextPart_000_0E18_01C3B4D4.32C825F0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&
Well, I haven't done any Access SQL in =a long time. You could try changing the JOIN to INNER JOIN, listing the =columns explicitly, instead of ph.* and using double quotes vs. single quotes.
You're probably best to take my query =to the Access newsgroup and see what you can get.
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"CJM"
Tom thanks for that... but once again I =have been an idoit! For a change I'm working in Access 2k!
Before I repost to an Access group, =would you happen to know the difference between Access and SQLServer - ie I tried =this SQL in Access but it didn't work - Syntax error of some sort...
Cheers
"Tom Moreau"
If you post your DDL, we can give a =better solution:
select
=ph.*
from
PrefHotels =as ph
join
Hotels as =h on h.HotelID =3D ph.HotelID
join
Locations =as l on l.LocationID =3D ph.LocationID
where
l.Location ==3D 'Grand Cayman'
-- Tom
=---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"CJM"
--=_NextPart_000_0E18_01C3B4D4.32C825F0--|||Hi Cjmwork, Tom
Thank you for using MSDN Newsgroup! It's my pleasure to assist you with
your issue.
I noticed this issue is duplicated with one in
microsoft.public.sqlserver.programming. I think it is an issue of
programming and I will close this one here.
You can still discuss the problem in microsoft.public.sqlserver.programming
and thanks for using MSDN Newsgroup!
Best regards
Baisong Wei
Microsoft Online Support
----
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only. Thanks.