Thursday, March 29, 2012
database name
to use this to determine if a script should proceed. It should only proceed
if the current database is not a system database.
I was thinking something like,
IF (select dbid < 6) THEN RAISERROR.
Thoughts? Thanks!
Check books online for db_name.
If you execute something like:
select db_name()
you will get the current database name.
-Sue
On Mon, 13 Sep 2004 16:41:12 -0700, "Bevo"
<Bevo@.discussions.microsoft.com> wrote:
>Is there a way to determine the current database the session is using? I want
>to use this to determine if a script should proceed. It should only proceed
>if the current database is not a system database.
>I was thinking something like,
>IF (select dbid < 6) THEN RAISERROR.
>Thoughts? Thanks!
|||if ( db_name != 'mydb') Raiserror ('Incorrect database',16,1)
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Bevo" <Bevo@.discussions.microsoft.com> wrote in message
news:4A5919FA-B5A6-4B2E-BF05-F681FBA08019@.microsoft.com...
> Is there a way to determine the current database the session is using? I
want
> to use this to determine if a script should proceed. It should only
proceed
> if the current database is not a system database.
> I was thinking something like,
> IF (select dbid < 6) THEN RAISERROR.
> Thoughts? Thanks!
|||I will not know the name of the database to be used, but I will know that it
is not a system database.
Can I be sure that all database ids greater than 6 are not system databases?
If so, the logic would be this:
if ( db_id(db_name()) < 6) Raiserror ('Must not be a system database',16,1)
"Wayne Snyder" wrote:
> if ( db_name != 'mydb') Raiserror ('Incorrect database',16,1)
>
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Bevo" <Bevo@.discussions.microsoft.com> wrote in message
> news:4A5919FA-B5A6-4B2E-BF05-F681FBA08019@.microsoft.com...
> want
> proceed
>
>
|||There is no need for db_name().
e.g.
If (db_id()<6) Raiserror ('Must not be a system included database',16,1)
Howerver, it's best to be explicit because you would never know if there
would be more than 6 system included databases. Plus, the db_id for the 7th
might be >6. Thus,
If (db_name() in ('master','msdb','tempdb','model','Northwind','Pub s'))
Raiserror ('Must not be a system included database',16,1)
"Bevo" <Bevo@.discussions.microsoft.com> wrote in message
news:10284D82-E541-46F4-B3C3-C76AA021BA40@.microsoft.com...
> I will not know the name of the database to be used, but I will know that
it
> is not a system database.
> Can I be sure that all database ids greater than 6 are not system
databases?
> If so, the logic would be this:
> if ( db_id(db_name()) < 6) Raiserror ('Must not be a system
database',16,1)[vbcol=seagreen]
>
sql
database name
to use this to determine if a script should proceed. It should only proceed
if the current database is not a system database.
I was thinking something like,
IF (select dbid < 6) THEN RAISERROR.
Thoughts' Thanks!Check books online for db_name.
If you execute something like:
select db_name()
you will get the current database name.
-Sue
On Mon, 13 Sep 2004 16:41:12 -0700, "Bevo"
<Bevo@.discussions.microsoft.com> wrote:
>Is there a way to determine the current database the session is using? I want
>to use this to determine if a script should proceed. It should only proceed
>if the current database is not a system database.
>I was thinking something like,
>IF (select dbid < 6) THEN RAISERROR.
>Thoughts' Thanks!|||if ( db_name != 'mydb') Raiserror ('Incorrect database',16,1)
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Bevo" <Bevo@.discussions.microsoft.com> wrote in message
news:4A5919FA-B5A6-4B2E-BF05-F681FBA08019@.microsoft.com...
> Is there a way to determine the current database the session is using? I
want
> to use this to determine if a script should proceed. It should only
proceed
> if the current database is not a system database.
> I was thinking something like,
> IF (select dbid < 6) THEN RAISERROR.
> Thoughts' Thanks!|||I will not know the name of the database to be used, but I will know that it
is not a system database.
Can I be sure that all database ids greater than 6 are not system databases?
If so, the logic would be this:
if ( db_id(db_name()) < 6) Raiserror ('Must not be a system database',16,1)
"Wayne Snyder" wrote:
> if ( db_name != 'mydb') Raiserror ('Incorrect database',16,1)
>
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Bevo" <Bevo@.discussions.microsoft.com> wrote in message
> news:4A5919FA-B5A6-4B2E-BF05-F681FBA08019@.microsoft.com...
> > Is there a way to determine the current database the session is using? I
> want
> > to use this to determine if a script should proceed. It should only
> proceed
> > if the current database is not a system database.
> >
> > I was thinking something like,
> >
> > IF (select dbid < 6) THEN RAISERROR.
> >
> > Thoughts' Thanks!
>
>|||There is no need for db_name().
e.g.
If (db_id()<6) Raiserror ('Must not be a system included database',16,1)
Howerver, it's best to be explicit because you would never know if there
would be more than 6 system included databases. Plus, the db_id for the 7th
might be >6. Thus,
If (db_name() in ('master','msdb','tempdb','model','Northwind','Pubs'))
Raiserror ('Must not be a system included database',16,1)
"Bevo" <Bevo@.discussions.microsoft.com> wrote in message
news:10284D82-E541-46F4-B3C3-C76AA021BA40@.microsoft.com...
> I will not know the name of the database to be used, but I will know that
it
> is not a system database.
> Can I be sure that all database ids greater than 6 are not system
databases?
> If so, the logic would be this:
> if ( db_id(db_name()) < 6) Raiserror ('Must not be a system
database',16,1)
>
> >
Wednesday, March 21, 2012
database migration
I wonder wether a software or a device (or script) allowing to migrate data
from an existant database to a new database by using correspondant ODBC
drivers existed.
Thanks for your help.How about BACKUP /RESTORE database commans
"ben" <bdugenet@.supralog.com> wrote in message
news:dqieie$rb$1@.news.tiscali.fr...
> Hi,
> I wonder wether a software or a device (or script) allowing to migrate
> data
> from an existant database to a new database by using correspondant ODBC
> drivers existed.
> Thanks for your help.
>
database migration
I wonder wether a software or a device (or script) allowing to migrate data
from an existant database to a new database by using correspondant ODBC
drivers existed.
Thanks for your help.
Ben,
Why wouldn't you use possibilities that SQL Server gives you? You can use
backup / restore, Data Transformation Services, ...
Dejan Sarka, SQL Server MVP
Mentor, www.SolidQualityLearning.com
Anything written in this message represents solely the point of view of the
sender.
This message does not imply endorsement from Solid Quality Learning, and it
does not represent the point of view of Solid Quality Learning or any other
person, company or institution mentioned in this message
"ben" <bdugenet@.supralog.com> wrote in message
news:dqieit$s5$1@.news.tiscali.fr...
> Hi,
> I wonder wether a software or a device (or script) allowing to migrate
> data
> from an existant database to a new database by using correspondant ODBC
> drivers existed.
> Thanks for your help.
>
database migration
I wonder wether a software or a device (or script) allowing to migrate data
from an existant database to a new database by using correspondant ODBC
drivers existed.
Thanks for your help.Hello Ben,
> I wonder wether a software or a device (or script) allowing to migrate
data
> from an existant database to a new database by using correspondant ODBC
> drivers existed.
Yes, there's such software.
Try our tool, Database Workbench, at www.upscene.com
Here's some info on the Schema Migrator:
http://www.upscene.com/documentatio...emamigrator.htm
--
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com|||ben wrote:
> Hi,
> I wonder wether a software or a device (or script) allowing to migrate data
> from an existant database to a new database by using correspondant ODBC
> drivers existed.
> Thanks for your help.
Do you have some specific problem in mind or is this just a general
enquiry? There are many, many solutions that exist to migrate data
between different data sources. I've included a few links below.
Whether you'll want any of the third party products depends on your
budget and how sophisticated your requirements are.
If you are using SQL Server then first take a look at either using a
linked server or DTS (SQL Server 2000) or Integration Services (SQL
Server 2005). Information on those features can be found in Books
Online.
http://www.microsoft.com/sql/techno...on/default.mspx
www-306.ibm.com/software/data/integration/dis/
www.abinitio.com
www.datamirror.com
www.datawatch.com
www.embarcadero.com/products/dtstudio/index.html
www.informatica.com
www.pervasive.com/solutions/
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/...US,SQL.90).aspx
--
Wednesday, March 7, 2012
Database Maintenance Plan
I have a built a Database Maintenance Plan for my databases which includes
the following...
Intra-daily:
Transactional Backup Script
Daily:
Differential Backup Script
Weekly:
CheckDB Script
IndexDefrag/Reindex Script
Full Backup Script
Backup MSAS DB Script
Monthly:
Check Login Script (LDAP Query Script checks for changes to Windows Groups)
Clear old Backup History Script
Is there anything else anybody has, that they find useful as part of their
DB Maintenance Plans? I still run the CheckDBs more out of habit than
anything else, does anyone else still run it?You didn't specify what version of SQL Server, so I assume 2000.
You mentioned weekly IndexDefrag/Reindex. I take it that you only do one of these operations, or
that you conditionally do only one of the operations per index. Also, don't defrag if the data isn't
fragmented in the first place (maint wiz doesn't take this into account). See for instance
http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx
> I still run the CheckDBs more out of habit than
> anything else, does anyone else still run it?
Yes, and I try to run int even more often. In the unlikely (but unfortunate) case of a corruption, I
can restore the most recent clean backup and then restore all subsequent log backup. The fewer log
backups I have, the more likely that the corruption will *not* re-appear when I restore them. I.e.,
of you have a problem in the database, you want to know ASAP.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"BenUK" <BenUK@.discussions.microsoft.com> wrote in message
news:9F683BA8-999D-424F-909C-8782747F683A@.microsoft.com...
> Hi All,
> I have a built a Database Maintenance Plan for my databases which includes
> the following...
> Intra-daily:
> Transactional Backup Script
> Daily:
> Differential Backup Script
> Weekly:
> CheckDB Script
> IndexDefrag/Reindex Script
> Full Backup Script
> Backup MSAS DB Script
> Monthly:
> Check Login Script (LDAP Query Script checks for changes to Windows Groups)
> Clear old Backup History Script
> Is there anything else anybody has, that they find useful as part of their
> DB Maintenance Plans? I still run the CheckDBs more out of habit than
> anything else, does anyone else still run it?|||Yep, sorry, it's 2000...
...my maintenance plan is all done via scripts/jobs as opposed to the maint
wiz, the InDefrag/Reindex is a conditional operation based on Logical
Fragmentation and Page Density and is based on the level of fragmentation in
each...
"Tibor Karaszi" wrote:
> You didn't specify what version of SQL Server, so I assume 2000.
> You mentioned weekly IndexDefrag/Reindex. I take it that you only do one of these operations, or
> that you conditionally do only one of the operations per index. Also, don't defrag if the data isn't
> fragmented in the first place (maint wiz doesn't take this into account). See for instance
> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx
>
> > I still run the CheckDBs more out of habit than
> > anything else, does anyone else still run it?
> Yes, and I try to run int even more often. In the unlikely (but unfortunate) case of a corruption, I
> can restore the most recent clean backup and then restore all subsequent log backup. The fewer log
> backups I have, the more likely that the corruption will *not* re-appear when I restore them. I.e.,
> of you have a problem in the database, you want to know ASAP.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "BenUK" <BenUK@.discussions.microsoft.com> wrote in message
> news:9F683BA8-999D-424F-909C-8782747F683A@.microsoft.com...
> > Hi All,
> >
> > I have a built a Database Maintenance Plan for my databases which includes
> > the following...
> >
> > Intra-daily:
> > Transactional Backup Script
> >
> > Daily:
> > Differential Backup Script
> >
> > Weekly:
> > CheckDB Script
> > IndexDefrag/Reindex Script
> > Full Backup Script
> > Backup MSAS DB Script
> >
> > Monthly:
> > Check Login Script (LDAP Query Script checks for changes to Windows Groups)
> > Clear old Backup History Script
> >
> > Is there anything else anybody has, that they find useful as part of their
> > DB Maintenance Plans? I still run the CheckDBs more out of habit than
> > anything else, does anyone else still run it?
>
>