Wednesday, March 28, 2012
Mapping from flatfile to SQL server database...
Im trying to find existing software to map from flatfiles (mostly .txt) to a
database running on MS SQL Server. The files are recieved by mail, and made
available to my program, and are supposed to be read and processed in a way
that extracts the data from the files and inserts it into the database.
If I had the time and skill, I would love to do this myself, but under the
current circumstances i need to find some sort of existing SDK to do this (o
r
an easy way to program it).
Any suggestions?Christian Johansen wrote:
> Hi!
> Im trying to find existing software to map from flatfiles (mostly .txt) to
a
> database running on MS SQL Server. The files are recieved by mail, and mad
e
> available to my program, and are supposed to be read and processed in a wa
y
> that extracts the data from the files and inserts it into the database.
> If I had the time and skill, I would love to do this myself, but under the
> current circumstances i need to find some sort of existing SDK to do this
(or
> an easy way to program it).
> Any suggestions?
Have you considered using DTS or Integration Services?
http://www.sqldts.com/
www.microsoft.com/sql/technologies/...on/default.mspx
Alternatively, there are many integration tool vendors whose products
will do the job. Here is a selection:
www.abinitio.com
ibm.ascential.com
www.datamirror.com
www.datawatch.com
www.embarcadero.com
www.informatica.com
www.pervasive.com
David Portas
SQL Server MVP
--|||
"David Portas" wrote:
> Christian Johansen wrote:
>
> Have you considered using DTS or Integration Services?
> http://www.sqldts.com/
> www.microsoft.com/sql/technologies/...on/default.mspx
> Alternatively, there are many integration tool vendors whose products
> will do the job. Here is a selection:
> www.abinitio.com
> ibm.ascential.com
> www.datamirror.com
> www.datawatch.com
> www.embarcadero.com
> www.informatica.com
> www.pervasive.com
> --
> David Portas
> SQL Server MVP
> --
>
Ahh, just what I was looking for!
Thank you very much. Merry Christmas :)
Wednesday, March 21, 2012
many mistakes, one big mess
I have remote access to the server where the Database is, so this morning
I've detached the database, replace it with a newer version and re-attached...
I forgot to change the attribute and I re-attached as "read only". First big
mistake. Somebody tried to update a record and the project was "hanging" so
they press Ctr+Alt+Del and stop the Access project.
The database shows there is still one user connected
Trying to fix this, I've stopped the server... thinking this will disconnect
the user... nope.
Please help me to fix this mess and learn few big lessons (like never attach
a read only db)
How can I connect the Instance again? The service manager is not letting me
re-connect, everything is "disabled"
How can I disconnect the user so I can detach the read only database and
re-attache the good one?
Any help would be more than appreciated,
gaba
hi,
gaba wrote:
> Hi there. I'm learning about MSDE, .adp and how to handle the files
> in between. I have remote access to the server where the Database is,
> so this morning
> I've detached the database, replace it with a newer version and
> re-attached... I forgot to change the attribute and I re-attached as
> "read only". First big mistake. Somebody tried to update a record and
> the project was "hanging" so they press Ctr+Alt+Del and stop the
> Access project.
> The database shows there is still one user connected
> Trying to fix this, I've stopped the server... thinking this will
> disconnect the user... nope.
> Please help me to fix this mess and learn few big lessons (like never
> attach
> a read only db)
> How can I connect the Instance again? The service manager is not
> letting me re-connect, everything is "disabled"
> How can I disconnect the user so I can detach the read only database
> and re-attache the good one?
> Any help would be more than appreciated,
if your MSDE instance is running and you want to see/kill a certain user,
you can run, on oSql.exe the
EXEC sp_who
system stored procedure to identify who you want to eventually kill, and
then exeute the
KILL nr#
statement, where nr# states for the actual related spid of the "user" you
want to kill..
Andrea Montanari
http://www.asql.biz/DbaMgr.shtm
DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||Hi Andrea,
Thanks for your response. The MSDE instance is not running, acually is
trying to stop. Under SQL Server Service Manager, SQL server for this
instance says "stopping". It shows it is still connected to one user. I've
tried to delete the db, no luck.
Please advise
gaba
"Andrea Montanari" wrote:
> hi,
> gaba wrote:
> if your MSDE instance is running and you want to see/kill a certain user,
> you can run, on oSql.exe the
> EXEC sp_who
> system stored procedure to identify who you want to eventually kill, and
> then exeute the
> KILL nr#
> statement, where nr# states for the actual related spid of the "user" you
> want to kill..
> --
> Andrea Montanari
> http://www.asql.biz/DbaMgr.shtm
> DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
> (my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
> interface)
> -- remove DMO to reply
>
>
|||Andrea,
Is there any solution to this mess or should I uninstalled the instance and
re-install it? right now the server manager is greyed out and I can't do
anything. I'm using remote access to the server and have to let everybody
know if I'm going to re-start the server.
Thanks.
gaba
"Andrea Montanari" wrote:
> hi,
> gaba wrote:
> if your MSDE instance is running and you want to see/kill a certain user,
> you can run, on oSql.exe the
> EXEC sp_who
> system stored procedure to identify who you want to eventually kill, and
> then exeute the
> KILL nr#
> statement, where nr# states for the actual related spid of the "user" you
> want to kill..
> --
> Andrea Montanari
> http://www.asql.biz/DbaMgr.shtm
> DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
> (my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
> interface)
> -- remove DMO to reply
>
>
|||hi,
gaba wrote:
> Andrea,
> Is there any solution to this mess or should I uninstalled the
> instance and re-install it? right now the server manager is greyed
> out and I can't do anything. I'm using remote access to the server
> and have to let everybody know if I'm going to re-start the server.
> Thanks.
actually I'm trying to figure out what's happening...
you have the server "stopping" but not able to complete the process "becouse
some user's still connected"...
actually this should not prevent the SQL Server service to stop at all...
ok.. before uninstalling...
try managing the service applet to start MSDE manually and not automatic..
shut down the machine.. possibly "softly", and then physically if it does
not work :D
once restarted MSDE should not be running.. delete the db files you are
interested with...
start MSDE manually... the database should be marked as corrupted or the
like..
drop the database via
DROP DATABASE xxxx
statement... you should be then ok with that.. repristinate the automatic
startup of the service...
Andrea Montanari
http://www.asql.biz/DbaMgr.shtm
DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||Andrea,
please forgive my ignarance,
what do you mean by "shut down the machine possibly "softly"?
Thanks so much for your help
gaba
"Andrea Montanari" wrote:
> hi,
> gaba wrote:
> actually I'm trying to figure out what's happening...
> you have the server "stopping" but not able to complete the process "becouse
> some user's still connected"...
> actually this should not prevent the SQL Server service to stop at all...
> ok.. before uninstalling...
> try managing the service applet to start MSDE manually and not automatic..
> shut down the machine.. possibly "softly", and then physically if it does
> not work :D
> once restarted MSDE should not be running.. delete the db files you are
> interested with...
> start MSDE manually... the database should be marked as corrupted or the
> like..
> drop the database via
> DROP DATABASE xxxx
> statement... you should be then ok with that.. repristinate the automatic
> startup of the service...
> --
> Andrea Montanari
> http://www.asql.biz/DbaMgr.shtm
> DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
> (my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
> interface)
> -- remove DMO to reply
>
>
|||hi,
gaba wrote:
> Andrea,
> please forgive my ignarance,
> what do you mean by "shut down the machine possibly "softly"?
> Thanks so much for your help
I just meant using the "standard" shut down Windows features and not
pressing the pc's interrupt :D:D
Andrea Montanari
http://www.asql.biz/DbaMgr.shtm
DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||Hi Andrea,
THANK YOU. I re-started the server and drop the database, attach the good
one and we are back in business.
I've recreated my mistakes... oh Boy
I work on my cpu, test and then burn a copy of the project and database to a
cd, paste into server.
1) Didn't stop the SQL Server on my computer BEFORE copying files: 1 user
still connected
2) When pasting files from CD, didn't make them ARCHIVES, they were read only
3) Instead of disconnecting the user (Kill nr#) and drop corrupted db, I've
tried to stop the SQL Server.
Thanks so much for you help. I know one way of learning and to get
experience is by making mistakes and fixing them... but Oh Boy I really had a
BAD day: I've made one after the other. Maybe somebody else can learn too
from them.
I want to learn SQL Server and do it right, can you recomend any material or
book for Beginners? Thanks
gaba
|||hi,
gaba wrote:
> 1) Didn't stop the SQL Server on my computer BEFORE copying files: 1
> user still connected
another lesson, if I can help... please always DETACH dbs before copying
them ... detaching a database for later re-attach is the only proper and
supported way for doing that kind of operations, and stopping the server is
not needed...
ok. both way, detaching and stopping the server, should provide a proper db
closing... but stay the documented way :D:D
> I want to learn SQL Server and do it right, can you recomend any
> material or book for Beginners? Thanks
I'd recommend the SQL bible, "Inside SQL Server 2000",
http://www.amazon.com/exec/obidos/tg...books&n=507846 ,
not about Transact-SQL but the actual engines and related architecture...,
by Notre Dame SQL Server Kalen Delaney.. :D
Andrea Montanari
http://www.asql.biz/DbaMgr.shtm
DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||Andrea,
Thanks a lot for your help and advise.
I'm using the DbaMGR2k, actually I'm reading the help files first ;)
Thanks for a great product!
I'll get the book tomorrow.
I'm sure we'll "talk" again,
gaba
sql
Many data files, SAME Filegroup, SAME drive
files, SAME filegroup, SAME drive... Say you have a
database, where 4 data files reside on the one PRIMARY
Filegroup.
my_db_Data_1.MDF
my_db_Data_2.NDF
my_db_Data_3.NDF
my_db_Data_4.NDF
When you do an action like BULK INSERT a large amount of
data to a table, SQL Server will scatter that table's data
across the 4 data files.
I understand the reasons one might WANT to have 4 files on
teh same drive, like if they want to copy smaller data
files around, etc... But, performance-wise, I'd think it
would be at LEAST somewhat slower writing to 4 files, then
writing to ONE file on the same drive. Any ideas on that?
Also, wouldn't you have to deal with 4 shrinkings instead
of just one?
THanks, BruceBruce
What is a perfomance gain do you get by putting all files on the same
physical disk and the same filegroup?
"Bruce de Freitas" <bruce@.defreitas.com> wrote in message
news:01b801c34bc6$55421db0$a401280a@.phx.gbl...
> Hello. I'm looking for any pros/cons to having multiple
> files, SAME filegroup, SAME drive... Say you have a
> database, where 4 data files reside on the one PRIMARY
> Filegroup.
> my_db_Data_1.MDF
> my_db_Data_2.NDF
> my_db_Data_3.NDF
> my_db_Data_4.NDF
> When you do an action like BULK INSERT a large amount of
> data to a table, SQL Server will scatter that table's data
> across the 4 data files.
> I understand the reasons one might WANT to have 4 files on
> teh same drive, like if they want to copy smaller data
> files around, etc... But, performance-wise, I'd think it
> would be at LEAST somewhat slower writing to 4 files, then
> writing to ONE file on the same drive. Any ideas on that?
> Also, wouldn't you have to deal with 4 shrinkings instead
> of just one?
> THanks, Brucesql
many BULK INSERTs and error "cannot obtain a lock"...
I still have problem with my script that perform a sequence of
many
data files with a BULK INSERT in a loop and rarely (about 10% of
times) fails with "cannot obtain a lock" (see the original post
below).
Since this happens also on a dedicate server without any other
activity
(both sql server and the O.S. are idle apart for the BULK INSERT
loop)
I start thinking the cause could be in the ODBC connection and cursor
that are
constantly re-used during the whole loop (the odbc connection is
in autocommit) and so
A friend of mine suggested me that I could try to enforce a checkpoint
could a ' cursor.execute("CHECKPOINT") ' statement issued before
any BULK INSERT
solve my issue?
TIA!
bye,
PiErre
on 2007-02-16 PiErre wrote:
> Subject: suggestion to avoid error "cannot obtain a lock"
> Hi,
> I have a script (actually the same python script
> that runs locally on several ms sql 2000sp4
> server - connecting via mxodbc)
> that every night tries to bulk insert about 20 files
> of various size (from less than 10 MB
> to more than 300 MB - about 900 MB in total )
> and sometimes (about 5% of the times)
> the importation fails (randomly on
> one or more of the servers) with the error like
> 'S1000', 1204, '[Microsoft][ODBC SQL Server Driver][SQL Server]
> The SQL Server cannot obtain a LOCK resource at this time...
>
> There is no other activity on the db server at the error time and
> so I cannot detect what is the cause of the resource lock.
> The db is normally configured with recovery-model set to simple
> and autoshrink enabled (not my decision
> and I must provide clear evidence to have
> that "standard" changed), but even after
> disable it the errors still appear.
>
> What can I do to detect the actual lock cause?
> More important: what can I do to avoid
> such errors? I heard something
> about to set a checkpoint after every bulk insert
> but I don't know how to do that...
>
> Thanks in advance for your help!
> bye,
> PiErreTry specifying TABLOCK on the BULK INSERT statement.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"PiErre" <siggy2@.supereva.it> wrote in message
news:1178184835.364450.30740@.y80g2000hsf.googlegroups.com...
> Hi,
> I still have problem with my script that perform a sequence of
> many
> data files with a BULK INSERT in a loop and rarely (about 10% of
> times) fails with "cannot obtain a lock" (see the original post
> below).
> Since this happens also on a dedicate server without any other
> activity
> (both sql server and the O.S. are idle apart for the BULK INSERT
> loop)
> I start thinking the cause could be in the ODBC connection and cursor
> that are
> constantly re-used during the whole loop (the odbc connection is
> in autocommit) and so
> A friend of mine suggested me that I could try to enforce a checkpoint
> could a ' cursor.execute("CHECKPOINT") ' statement issued before
> any BULK INSERT
> solve my issue?
> TIA!
> bye,
> PiErre
> on 2007-02-16 PiErre wrote:
>> Subject: suggestion to avoid error "cannot obtain a lock"
>> Hi,
>> I have a script (actually the same python script
>> that runs locally on several ms sql 2000sp4
>> server - connecting via mxodbc)
>> that every night tries to bulk insert about 20 files
>> of various size (from less than 10 MB
>> to more than 300 MB - about 900 MB in total )
>> and sometimes (about 5% of the times)
>> the importation fails (randomly on
>> one or more of the servers) with the error like
>> 'S1000', 1204, '[Microsoft][ODBC SQL Server Driver][SQL Server]
>> The SQL Server cannot obtain a LOCK resource at this time...
>> There is no other activity on the db server at the error time and
>> so I cannot detect what is the cause of the resource lock.
>> The db is normally configured with recovery-model set to simple
>> and autoshrink enabled (not my decision
>> and I must provide clear evidence to have
>> that "standard" changed), but even after
>> disable it the errors still appear.
>> What can I do to detect the actual lock cause?
>> More important: what can I do to avoid
>> such errors? I heard something
>> about to set a checkpoint after every bulk insert
>> but I don't know how to do that...
>> Thanks in advance for your help!
>> bye,
>> PiErre
>|||On 3 Mag, 12:08, "Dan Guzman" <guzma...@.nospam-online.sbcglobal.net>
wrote:
> Try specifying TABLOCK on the BULK INSERT statement.
>
There are good chance that your hint was EXACTLY what I was looking
for...
Thanks a lot!
bye,
PiErre
Monday, March 19, 2012
Manually roll-forward transactions
the full). The data files have been deleted, but I do have the transaction
log. After the last transaction log backup, there where a few important
transactions that happened that I need to roll-forward. Is there a way to
get those transactions back if I only have the transaction log, and not a
backup of it?
Thanks in advance.Use the following command:
BACKUP LOG databasename WITH NO_TRUNCATE
This will back up your current log even if the data files are not available.
Then you'll be able to restore your database using your last full backup and
subsequent log backups.
--
Carlos E. Rojas
SQL Server MVP
Co-Author SQL Server 2000 Programming by Example
"Paul Bergstedt" <Paul@.nospam.com> wrote in message
news:u1ehu4p6DHA.1052@.TK2MSFTNGP12.phx.gbl...
> I have a full backup of my database, a transaction log backup (taken after
> the full). The data files have been deleted, but I do have the
transaction
> log. After the last transaction log backup, there where a few important
> transactions that happened that I need to roll-forward. Is there a way to
> get those transactions back if I only have the transaction log, and not a
> backup of it?
> Thanks in advance.
>|||So if I start up SQL Server, after I have lost my data files (from a lost
disk that housed them), I will be able to do a backup of the log? Wouldn't
the currpted status of my database prevent me from doing the tran log
backup?
Paul
"Carlos Eduardo Rojas" <carloser@.mindspring.com> wrote in message
news:uurB46p6DHA.1948@.TK2MSFTNGP12.phx.gbl...
> Use the following command:
> BACKUP LOG databasename WITH NO_TRUNCATE
> This will back up your current log even if the data files are not
available.
> Then you'll be able to restore your database using your last full backup
and
> subsequent log backups.
> --
> Carlos E. Rojas
> SQL Server MVP
> Co-Author SQL Server 2000 Programming by Example
>
> "Paul Bergstedt" <Paul@.nospam.com> wrote in message
> news:u1ehu4p6DHA.1052@.TK2MSFTNGP12.phx.gbl...
> > I have a full backup of my database, a transaction log backup (taken
after
> > the full). The data files have been deleted, but I do have the
> transaction
> > log. After the last transaction log backup, there where a few important
> > transactions that happened that I need to roll-forward. Is there a way
to
> > get those transactions back if I only have the transaction log, and not
a
> > backup of it?
> >
> > Thanks in advance.
> >
> >
>|||No, it doesn't prevent you from doing it. Actually, it's something very easy
to test. Just stop sql server, delete data files, restart sql server and
then issue the "magic" command.
--
Carlos E. Rojas
SQL Server MVP
Co-Author SQL Server 2000 Programming by Example
"Paul Bergstedt" <Paul@.nospam.com> wrote in message
news:uKVQ0$p6DHA.2644@.TK2MSFTNGP11.phx.gbl...
> So if I start up SQL Server, after I have lost my data files (from a lost
> disk that housed them), I will be able to do a backup of the log?
Wouldn't
> the currpted status of my database prevent me from doing the tran log
> backup?
> Paul
> "Carlos Eduardo Rojas" <carloser@.mindspring.com> wrote in message
> news:uurB46p6DHA.1948@.TK2MSFTNGP12.phx.gbl...
> > Use the following command:
> > BACKUP LOG databasename WITH NO_TRUNCATE
> > This will back up your current log even if the data files are not
> available.
> > Then you'll be able to restore your database using your last full backup
> and
> > subsequent log backups.
> >
> > --
> > Carlos E. Rojas
> > SQL Server MVP
> > Co-Author SQL Server 2000 Programming by Example
> >
> >
> > "Paul Bergstedt" <Paul@.nospam.com> wrote in message
> > news:u1ehu4p6DHA.1052@.TK2MSFTNGP12.phx.gbl...
> > > I have a full backup of my database, a transaction log backup (taken
> after
> > > the full). The data files have been deleted, but I do have the
> > transaction
> > > log. After the last transaction log backup, there where a few
important
> > > transactions that happened that I need to roll-forward. Is there a
way
> to
> > > get those transactions back if I only have the transaction log, and
not
> a
> > > backup of it?
> > >
> > > Thanks in advance.
> > >
> > >
> >
> >
>
Manually roll-forward transactions
the full). The data files have been deleted, but I do have the transaction
log. After the last transaction log backup, there where a few important
transactions that happened that I need to roll-forward. Is there a way to
get those transactions back if I only have the transaction log, and not a
backup of it?
Thanks in advance.Use the following command:
BACKUP LOG databasename WITH NO_TRUNCATE
This will back up your current log even if the data files are not available.
Then you'll be able to restore your database using your last full backup and
subsequent log backups.
Carlos E. Rojas
SQL Server MVP
Co-Author SQL Server 2000 programming by Example
"Paul Bergstedt" <Paul@.nospam.com> wrote in message
news:u1ehu4p6DHA.1052@.TK2MSFTNGP12.phx.gbl...
quote:
> I have a full backup of my database, a transaction log backup (taken after
> the full). The data files have been deleted, but I do have the
transaction
quote:|||So if I start up SQL Server, after I have lost my data files (from a lost
> log. After the last transaction log backup, there where a few important
> transactions that happened that I need to roll-forward. Is there a way to
> get those transactions back if I only have the transaction log, and not a
> backup of it?
> Thanks in advance.
>
disk that housed them), I will be able to do a backup of the log? Wouldn't
the currpted status of my database prevent me from doing the tran log
backup?
Paul
"Carlos Eduardo Rojas" <carloser@.mindspring.com> wrote in message
news:uurB46p6DHA.1948@.TK2MSFTNGP12.phx.gbl...
quote:
> Use the following command:
> BACKUP LOG databasename WITH NO_TRUNCATE
> This will back up your current log even if the data files are not
available.
quote:
> Then you'll be able to restore your database using your last full backup
and
quote:|||No, it doesn't prevent you from doing it. Actually, it's something very easy
> subsequent log backups.
> --
> Carlos E. Rojas
> SQL Server MVP
> Co-Author SQL Server 2000 programming by Example
>
> "Paul Bergstedt" <Paul@.nospam.com> wrote in message
> news:u1ehu4p6DHA.1052@.TK2MSFTNGP12.phx.gbl...
after[QUOTE]
> transaction
to[QUOTE]
a[QUOTE]
>
to test. Just stop sql server, delete data files, restart sql server and
then issue the "magic" command.
Carlos E. Rojas
SQL Server MVP
Co-Author SQL Server 2000 programming by Example
"Paul Bergstedt" <Paul@.nospam.com> wrote in message
news:uKVQ0$p6DHA.2644@.TK2MSFTNGP11.phx.gbl...
quote:
> So if I start up SQL Server, after I have lost my data files (from a lost
> disk that housed them), I will be able to do a backup of the log?
Wouldn't
quote:
> the currpted status of my database prevent me from doing the tran log
> backup?
> Paul
> "Carlos Eduardo Rojas" <carloser@.mindspring.com> wrote in message
> news:uurB46p6DHA.1948@.TK2MSFTNGP12.phx.gbl...
> available.
> and
> after
important[QUOTE]
way[QUOTE]
> to
not[QUOTE]
> a
>
Manually Grow database files
the "auto grow" provides. I would like to be able to run a nightly
script that can determine the unallocated space in a file (eg.
sp_spaceused) and if it falls below a certain percent, say 15% then
have it grow the file by say 25GB. I want to prevent the files from
growing in the middle of the day because of performance and
fragmentation.
Any help would be great.
-Will
Will
ALTER DATABASE dbname
MODIFY FILE
(NAME = logical file name,
SIZE = 25GB)
GO
Note , it is going to take pretty long time, what is your SQL Server
version?
"Will" <WillCWirtz@.yahoo.com> wrote in message
news:8422a1b9-6c8a-4a8e-8c55-c163dba38b71@.i12g2000prf.googlegroups.com...
> I'm looking for a way to manually perform the same functionality that
> the "auto grow" provides. I would like to be able to run a nightly
> script that can determine the unallocated space in a file (eg.
> sp_spaceused) and if it falls below a certain percent, say 15% then
> have it grow the file by say 25GB. I want to prevent the files from
> growing in the middle of the day because of performance and
> fragmentation.
> Any help would be great.
> -Will
|||Uri, thanks for your help. We're using SQL 2005.
I was hoping to avoid the ALTER DATABASE command if possible. It just
seems a little risky, but I don't know why.
It looks like it doesn't exist, but I was hoping that SQL may provide
a API for doing that in a more controlled way like DBCC(mydb.mdf,
20GB) or something.
You mention that it will be slow. Slower than an Auto Grow of the
same size? If so, Why? This would back up my desire to call the same
code that runs when the "auto grow" is initiated.
Will
|||Will
It is considered a good practice to allocate ( get on target) the size for
db and manually gwoing it.
Please read up this article
http://www.sqlskills.com/blogs/kimberly/2007/03/04/InstantInitializationWhatWhyAndHow.aspx
"Will" <WillCWirtz@.yahoo.com> wrote in message
news:9277d876-a967-4907-bc4a-c424a4a1fcae@.s19g2000prg.googlegroups.com...
> Uri, thanks for your help. We're using SQL 2005.
> I was hoping to avoid the ALTER DATABASE command if possible. It just
> seems a little risky, but I don't know why.
> It looks like it doesn't exist, but I was hoping that SQL may provide
> a API for doing that in a more controlled way like DBCC(mydb.mdf,
> 20GB) or something.
> You mention that it will be slow. Slower than an Auto Grow of the
> same size? If so, Why? This would back up my desire to call the same
> code that runs when the "auto grow" is initiated.
> Will
Manually Grow database files
the "auto grow" provides. I would like to be able to run a nightly
script that can determine the unallocated space in a file (eg.
sp_spaceused) and if it falls below a certain percent, say 15% then
have it grow the file by say 25GB. I want to prevent the files from
growing in the middle of the day because of performance and
fragmentation.
Any help would be great.
-WillWill
ALTER DATABASE dbname
MODIFY FILE
(NAME = logical file name,
SIZE = 25GB)
GO
Note , it is going to take pretty long time, what is your SQL Server
version?
"Will" <WillCWirtz@.yahoo.com> wrote in message
news:8422a1b9-6c8a-4a8e-8c55-c163dba38b71@.i12g2000prf.googlegroups.com...
> I'm looking for a way to manually perform the same functionality that
> the "auto grow" provides. I would like to be able to run a nightly
> script that can determine the unallocated space in a file (eg.
> sp_spaceused) and if it falls below a certain percent, say 15% then
> have it grow the file by say 25GB. I want to prevent the files from
> growing in the middle of the day because of performance and
> fragmentation.
> Any help would be great.
> -Will|||Uri, thanks for your help. We're using SQL 2005.
I was hoping to avoid the ALTER DATABASE command if possible. It just
seems a little risky, but I don't know why.
It looks like it doesn't exist, but I was hoping that SQL may provide
a API for doing that in a more controlled way like DBCC(mydb.mdf,
20GB) or something.
You mention that it will be slow. Slower than an Auto Grow of the
same size? If so, Why? This would back up my desire to call the same
code that runs when the "auto grow" is initiated.
Will|||Will
It is considered a good practice to allocate ( get on target) the size for
db and manually gwoing it.
Please read up this article
http://www.sqlskills.com/blogs/kimberly/2007/03/04/InstantInitializationWhatWhyAndHow.aspx
"Will" <WillCWirtz@.yahoo.com> wrote in message
news:9277d876-a967-4907-bc4a-c424a4a1fcae@.s19g2000prg.googlegroups.com...
> Uri, thanks for your help. We're using SQL 2005.
> I was hoping to avoid the ALTER DATABASE command if possible. It just
> seems a little risky, but I don't know why.
> It looks like it doesn't exist, but I was hoping that SQL may provide
> a API for doing that in a more controlled way like DBCC(mydb.mdf,
> 20GB) or something.
> You mention that it will be slow. Slower than an Auto Grow of the
> same size? If so, Why? This would back up my desire to call the same
> code that runs when the "auto grow" is initiated.
> Will|||> I was hoping to avoid the ALTER DATABASE command if possible. It just
> seems a little risky, but I don't know why.
There's noting inherently "risky" with ALTER DATABASE.
> It looks like it doesn't exist, but I was hoping that SQL may provide
> a API for doing that in a more controlled way like DBCC(mydb.mdf,
> 20GB) or something.
Imagine you are working in the SQL Server dev team for MS. You have implemented code that expend the
size of a database file. You now have to determine the TSQL command which will invoke your command.
Should it be some DBCC command? Or some ALTER DATABASE? What I'm trying to say is that the command
is just an interface to the functionality within SQL Server. MS are in fact moving away from DBCC
and system stored procedures in favor of DDL.
> You mention that it will be slow. Slower than an Auto Grow of the
> same size?
No, it is the same functionality in the engine in the end. It will actually be perceieved quicker
because you don't have one or several persons waiting for the grow (because you grow before it is
full).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Will" <WillCWirtz@.yahoo.com> wrote in message
news:9277d876-a967-4907-bc4a-c424a4a1fcae@.s19g2000prg.googlegroups.com...
> Uri, thanks for your help. We're using SQL 2005.
> I was hoping to avoid the ALTER DATABASE command if possible. It just
> seems a little risky, but I don't know why.
> It looks like it doesn't exist, but I was hoping that SQL may provide
> a API for doing that in a more controlled way like DBCC(mydb.mdf,
> 20GB) or something.
> You mention that it will be slow. Slower than an Auto Grow of the
> same size? If so, Why? This would back up my desire to call the same
> code that runs when the "auto grow" is initiated.
> Will|||> have it grow the file by say 25GB. I want to prevent the files from
> growing in the middle of the day because of performance and
> fragmentation.
If you are using sql 2005 on a windows server 2003, then you should read up
on Windows Instant File Initialization. Basically it means, that sql server
data files can be created instantly, without zeroing out all bytes in the
file. The account under which the sql server service runs, needs to be added
to the "Perform Volume Maintenance Tasks" security policy in windows. It
should be easy to find blog postings about this subject.
If you ARE running sql 2005 on a windows 2k3 server, and if you have set up
the user account for the "perform volume maintenance tasks", then you should
not worry about the performance hit when creating new data files og growing
them, since the growth happens instantly.
BUT! This only applies to data files. The log files will still need to zero
out all bytes on creation or growth, and that will have some performance
impact.
/Sjang|||> have it grow the file by say 25GB. I want to prevent the files from
> growing in the middle of the day because of performance and
> fragmentation.
If you are using sql 2005 on a windows server 2003, then you should read up
on Windows Instant File Initialization. Basically it means, that sql server
data files can be created instantly, without zeroing out all bytes in the
file. The account under which the sql server service runs, needs to be added
to the "Perform Volume Maintenance Tasks" security policy in windows. It
should be easy to find blog postings about this subject.
If you ARE running sql 2005 on a windows 2k3 server, and if you have set up
the user account for the "perform volume maintenance tasks", then you should
not worry about the performance hit when creating new data files og growing
them, since the growth happens instantly.
BUT! This only applies to data files. The log files will still need to zero
out all bytes on creation or growth, and that will have some performance
impact.
/Sjang
Monday, March 12, 2012
Mantanace Plan not deleting old files
for on nagging item. The plan does both full backups and
transaction log backups each day. It is supposed to
delete files older than 3 days old but does not. I have
to manually go and clear the old files on a regular basis
to keep from filling up the disk. I have not seen any
error or know what to look for to see if something is
wrong. I thought that if a full backup was done that it
emptyed the transaction logs but that dies not appear to
be the case either and is why I have the transition logs
in the mainance plan. Any information on how to get the
old fikes to delete?
Here is a good summary of the normal issues related to this by Bill from MS:
http://support.microsoft.com/default...;en-us;Q303292
This is likely to be either a permissions problem or a sharing violation
problem. The maintenance plan is run as a job, and jobs are run by the
SQLServerAgent service.
Permissions:
1. Determine the startup account for the SQLServerAgent service
(Start|Programs|Administrative tools|Services|SQLServerAgent|Startup). This
account is the security context for jobs, and thus the maintenance plan.
2. If SQLServerAgent is started using LocalSystem (as opposed to a domain
account) then skip step 3.
3. On that box, log onto NT as that account. Using Explorer, attempt to
delete an expired backup. If that succeeds then go to Sharing Violation
section.
4. Log onto NT with an account that is an administrator and use Explorer to
look at the Properties|Security of the folder (where the backups reside)
and ensure the SQLServerAgent startup account has Full Control. If the
SQLServerAgent startup account is LocalSystem, then the account to consider
is SYSTEM.
5. In NT, if an account is a member of an NT group, and if that group has
Access is Denied, then that account will have Access is Denied, even if
that account is also a member of the Administrators group. Thus you may
need to check group permissions (if the Startup Account is a member of a
group).
6. Keep in mind that permissions (by default) are inherited from a parent
folder. Thus, if the backups are stored in C:\bak, and if someone had
denied permission to the SQLServerAgent startup account for C:\, then
C:\bak will inherit access is denied.
Sharing violation:
This is likely to be rooted in a timing issue, with the most likely cause
being another scheduled process (such as NT Backup or Anti-Virus software)
having the backup file open at the time when the SQLServerAgent (i.e., the
maintenance plan job) tried to delete it.
1. Download filemon and handle from www.sysinternals.com.
2. I am not sure whether filemon can be scheduled, or you might be able to
use NT scheduling services to start filemon just before the maintenance
plan job is started, but the filemon log can become very large, so it would
be best to start it some short time before the maintenance plan starts.
3. Inspect the filemon log for another process that has that backup file
open (if your lucky enough to have started filemon before this other
process grabs the backup folder), and inspect the log for the results when
the SQLServerAgent agent attempts to open that same file.
4. Schedule the job or that other process to do their work at different
times.
5. You can use the handle utility if you are around at the time when the
job is scheduled to run.
If the backup files are going to a \\share or a mapped drive (as opposed to
local drive), then you will need to modify the above (with respect to where
the tests and utilities are run).
Finally, inspection of the maintenance plan's history report might be
useful.
Thanks,
Bill Hollinshead
Microsoft, SQL Server
Andrew J. Kelly SQL MVP
"Jim Abel" <jim.abel@.lmco.com> wrote in message
news:177f01c49cbe$504699e0$a301280a@.phx.gbl...
> I have a maintanace Plan establishe that is working excep
> for on nagging item. The plan does both full backups and
> transaction log backups each day. It is supposed to
> delete files older than 3 days old but does not. I have
> to manually go and clear the old files on a regular basis
> to keep from filling up the disk. I have not seen any
> error or know what to look for to see if something is
> wrong. I thought that if a full backup was done that it
> emptyed the transaction logs but that dies not appear to
> be the case either and is why I have the transition logs
> in the mainance plan. Any information on how to get the
> old fikes to delete?
|||i had the same problem. RIght-click on the maintenance plan and look at the
job history for any errors.
The problem I had was someone set up a maintenance plan to backup ALL
databases and to do transaction lo backups periodically. The trouble with
that is the system DBs (and any user DBs that are not set to FULL recovery
mode) cannot have Transaction log backups performed on them. So the Backups
were running, but the delete step was not running because the transaction log
backup step failed for some of the DBs.
hope that helps
"Andrew J. Kelly" wrote:
> Here is a good summary of the normal issues related to this by Bill from MS:
>
> http://support.microsoft.com/default...;en-us;Q303292
> This is likely to be either a permissions problem or a sharing violation
> problem. The maintenance plan is run as a job, and jobs are run by the
> SQLServerAgent service.
> Permissions:
> 1. Determine the startup account for the SQLServerAgent service
> (Start|Programs|Administrative tools|Services|SQLServerAgent|Startup). This
> account is the security context for jobs, and thus the maintenance plan.
> 2. If SQLServerAgent is started using LocalSystem (as opposed to a domain
> account) then skip step 3.
> 3. On that box, log onto NT as that account. Using Explorer, attempt to
> delete an expired backup. If that succeeds then go to Sharing Violation
> section.
> 4. Log onto NT with an account that is an administrator and use Explorer to
> look at the Properties|Security of the folder (where the backups reside)
> and ensure the SQLServerAgent startup account has Full Control. If the
> SQLServerAgent startup account is LocalSystem, then the account to consider
> is SYSTEM.
> 5. In NT, if an account is a member of an NT group, and if that group has
> Access is Denied, then that account will have Access is Denied, even if
> that account is also a member of the Administrators group. Thus you may
> need to check group permissions (if the Startup Account is a member of a
> group).
> 6. Keep in mind that permissions (by default) are inherited from a parent
> folder. Thus, if the backups are stored in C:\bak, and if someone had
> denied permission to the SQLServerAgent startup account for C:\, then
> C:\bak will inherit access is denied.
> Sharing violation:
> This is likely to be rooted in a timing issue, with the most likely cause
> being another scheduled process (such as NT Backup or Anti-Virus software)
> having the backup file open at the time when the SQLServerAgent (i.e., the
> maintenance plan job) tried to delete it.
> 1. Download filemon and handle from www.sysinternals.com.
> 2. I am not sure whether filemon can be scheduled, or you might be able to
> use NT scheduling services to start filemon just before the maintenance
> plan job is started, but the filemon log can become very large, so it would
> be best to start it some short time before the maintenance plan starts.
> 3. Inspect the filemon log for another process that has that backup file
> open (if your lucky enough to have started filemon before this other
> process grabs the backup folder), and inspect the log for the results when
> the SQLServerAgent agent attempts to open that same file.
> 4. Schedule the job or that other process to do their work at different
> times.
> 5. You can use the handle utility if you are around at the time when the
> job is scheduled to run.
> If the backup files are going to a \\share or a mapped drive (as opposed to
> local drive), then you will need to modify the above (with respect to where
> the tests and utilities are run).
> Finally, inspection of the maintenance plan's history report might be
> useful.
> Thanks,
> Bill Hollinshead
> Microsoft, SQL Server
>
> --
> Andrew J. Kelly SQL MVP
>
> "Jim Abel" <jim.abel@.lmco.com> wrote in message
> news:177f01c49cbe$504699e0$a301280a@.phx.gbl...
>
>
Mantanace Plan not deleting old files
for on nagging item. The plan does both full backups and
transaction log backups each day. It is supposed to
delete files older than 3 days old but does not. I have
to manually go and clear the old files on a regular basis
to keep from filling up the disk. I have not seen any
error or know what to look for to see if something is
wrong. I thought that if a full backup was done that it
emptyed the transaction logs but that dies not appear to
be the case either and is why I have the transition logs
in the mainance plan. Any information on how to get the
old fikes to delete?Here is a good summary of the normal issues related to this by Bill from MS:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q303292
This is likely to be either a permissions problem or a sharing violation
problem. The maintenance plan is run as a job, and jobs are run by the
SQLServerAgent service.
Permissions:
1. Determine the startup account for the SQLServerAgent service
(Start|Programs|Administrative tools|Services|SQLServerAgent|Startup). This
account is the security context for jobs, and thus the maintenance plan.
2. If SQLServerAgent is started using LocalSystem (as opposed to a domain
account) then skip step 3.
3. On that box, log onto NT as that account. Using Explorer, attempt to
delete an expired backup. If that succeeds then go to Sharing Violation
section.
4. Log onto NT with an account that is an administrator and use Explorer to
look at the Properties|Security of the folder (where the backups reside)
and ensure the SQLServerAgent startup account has Full Control. If the
SQLServerAgent startup account is LocalSystem, then the account to consider
is SYSTEM.
5. In NT, if an account is a member of an NT group, and if that group has
Access is Denied, then that account will have Access is Denied, even if
that account is also a member of the Administrators group. Thus you may
need to check group permissions (if the Startup Account is a member of a
group).
6. Keep in mind that permissions (by default) are inherited from a parent
folder. Thus, if the backups are stored in C:\bak, and if someone had
denied permission to the SQLServerAgent startup account for C:\, then
C:\bak will inherit access is denied.
Sharing violation:
This is likely to be rooted in a timing issue, with the most likely cause
being another scheduled process (such as NT Backup or Anti-Virus software)
having the backup file open at the time when the SQLServerAgent (i.e., the
maintenance plan job) tried to delete it.
1. Download filemon and handle from www.sysinternals.com.
2. I am not sure whether filemon can be scheduled, or you might be able to
use NT scheduling services to start filemon just before the maintenance
plan job is started, but the filemon log can become very large, so it would
be best to start it some short time before the maintenance plan starts.
3. Inspect the filemon log for another process that has that backup file
open (if your lucky enough to have started filemon before this other
process grabs the backup folder), and inspect the log for the results when
the SQLServerAgent agent attempts to open that same file.
4. Schedule the job or that other process to do their work at different
times.
5. You can use the handle utility if you are around at the time when the
job is scheduled to run.
If the backup files are going to a \\share or a mapped drive (as opposed to
local drive), then you will need to modify the above (with respect to where
the tests and utilities are run).
Finally, inspection of the maintenance plan's history report might be
useful.
Thanks,
Bill Hollinshead
Microsoft, SQL Server
Andrew J. Kelly SQL MVP
"Jim Abel" <jim.abel@.lmco.com> wrote in message
news:177f01c49cbe$504699e0$a301280a@.phx.gbl...
> I have a maintanace Plan establishe that is working excep
> for on nagging item. The plan does both full backups and
> transaction log backups each day. It is supposed to
> delete files older than 3 days old but does not. I have
> to manually go and clear the old files on a regular basis
> to keep from filling up the disk. I have not seen any
> error or know what to look for to see if something is
> wrong. I thought that if a full backup was done that it
> emptyed the transaction logs but that dies not appear to
> be the case either and is why I have the transition logs
> in the mainance plan. Any information on how to get the
> old fikes to delete?|||i had the same problem. RIght-click on the maintenance plan and look at the
job history for any errors.
The problem I had was someone set up a maintenance plan to backup ALL
databases and to do transaction lo backups periodically. The trouble with
that is the system DBs (and any user DBs that are not set to FULL recovery
mode) cannot have Transaction log backups performed on them. So the Backups
were running, but the delete step was not running because the transaction log
backup step failed for some of the DBs.
hope that helps
"Andrew J. Kelly" wrote:
> Here is a good summary of the normal issues related to this by Bill from MS:
>
> http://support.microsoft.com/default.aspx?scid=kb;en-us;Q303292
> This is likely to be either a permissions problem or a sharing violation
> problem. The maintenance plan is run as a job, and jobs are run by the
> SQLServerAgent service.
> Permissions:
> 1. Determine the startup account for the SQLServerAgent service
> (Start|Programs|Administrative tools|Services|SQLServerAgent|Startup). This
> account is the security context for jobs, and thus the maintenance plan.
> 2. If SQLServerAgent is started using LocalSystem (as opposed to a domain
> account) then skip step 3.
> 3. On that box, log onto NT as that account. Using Explorer, attempt to
> delete an expired backup. If that succeeds then go to Sharing Violation
> section.
> 4. Log onto NT with an account that is an administrator and use Explorer to
> look at the Properties|Security of the folder (where the backups reside)
> and ensure the SQLServerAgent startup account has Full Control. If the
> SQLServerAgent startup account is LocalSystem, then the account to consider
> is SYSTEM.
> 5. In NT, if an account is a member of an NT group, and if that group has
> Access is Denied, then that account will have Access is Denied, even if
> that account is also a member of the Administrators group. Thus you may
> need to check group permissions (if the Startup Account is a member of a
> group).
> 6. Keep in mind that permissions (by default) are inherited from a parent
> folder. Thus, if the backups are stored in C:\bak, and if someone had
> denied permission to the SQLServerAgent startup account for C:\, then
> C:\bak will inherit access is denied.
> Sharing violation:
> This is likely to be rooted in a timing issue, with the most likely cause
> being another scheduled process (such as NT Backup or Anti-Virus software)
> having the backup file open at the time when the SQLServerAgent (i.e., the
> maintenance plan job) tried to delete it.
> 1. Download filemon and handle from www.sysinternals.com.
> 2. I am not sure whether filemon can be scheduled, or you might be able to
> use NT scheduling services to start filemon just before the maintenance
> plan job is started, but the filemon log can become very large, so it would
> be best to start it some short time before the maintenance plan starts.
> 3. Inspect the filemon log for another process that has that backup file
> open (if your lucky enough to have started filemon before this other
> process grabs the backup folder), and inspect the log for the results when
> the SQLServerAgent agent attempts to open that same file.
> 4. Schedule the job or that other process to do their work at different
> times.
> 5. You can use the handle utility if you are around at the time when the
> job is scheduled to run.
> If the backup files are going to a \\share or a mapped drive (as opposed to
> local drive), then you will need to modify the above (with respect to where
> the tests and utilities are run).
> Finally, inspection of the maintenance plan's history report might be
> useful.
> Thanks,
> Bill Hollinshead
> Microsoft, SQL Server
>
> --
> Andrew J. Kelly SQL MVP
>
> "Jim Abel" <jim.abel@.lmco.com> wrote in message
> news:177f01c49cbe$504699e0$a301280a@.phx.gbl...
> > I have a maintanace Plan establishe that is working excep
> > for on nagging item. The plan does both full backups and
> > transaction log backups each day. It is supposed to
> > delete files older than 3 days old but does not. I have
> > to manually go and clear the old files on a regular basis
> > to keep from filling up the disk. I have not seen any
> > error or know what to look for to see if something is
> > wrong. I thought that if a full backup was done that it
> > emptyed the transaction logs but that dies not appear to
> > be the case either and is why I have the transition logs
> > in the mainance plan. Any information on how to get the
> > old fikes to delete?
>
>
Manipulate the 'deleted record' flag on DBF files
Hi,
I am using OLE DB provider for Foxpro (VFPOLEDB.1) to query DBF files. I need to migrate the content of these files to a SQL Server 2005 database.
These DBF files have some (actually a lot) records marked as deleted using the DBF 'deleted' flag. When I submit a SELECT command to the OLE DB Provider, it returns me all the non-deleted records from the file.
It is very Ok as long as the 'deleted' rows actually have no more business value, but in my case, I need to do some processing on them, and even to migrate their data.
What are the options available for me to be able to query and differentiate the 'deleted' records ?
Thank you in advance,
Bertrand Larsy
Hi Bertrand,
Here's some example VB code to work with the deleted status of a row:
Try
Dim cn1 As New OleDbConnection( _
"Provider=VFPOLEDB.1;Data Source=C:\Temp\;")
cn1.Open()
'-- Make some VFP data to play with
Dim cmd1 As New OleDbCommand( _
"Create Table TestDBF (Field1 I, Field2 C(10))", cn1)
Dim cmd2 As New OleDbCommand( _
"Insert Into TestDBF Values (1, 'Hello')", cn1)
Dim cmd3 As New OleDbCommand( _
"Insert Into TestDBF Values (2, 'World')", cn1)
Dim cmd4 As New OleDbCommand( _
"Delete From TestDBF Where Field1 = 1", cn1)
cmd1.ExecuteNonQuery()
cmd2.ExecuteNonQuery()
cmd3.ExecuteNonQuery()
cmd4.ExecuteNonQuery()
cn1.Close()
Dim cn2 As New OleDbConnection( _
"Provider=VFPOLEDB.1;Data Source=C:\Temp\;")
cn2.Open()
Dim cmd5 As New OleDbCommand( _
"Select * From TestDBF", cn2)
Dim da1 As New OleDbDataAdapter(cmd5)
Dim ds1 As New DataSet
Dim dr1 As DataRow
da1.Fill(ds1)
For Each dr1 In ds1.Tables(0).Rows
Console.WriteLine( _
dr1.Item(0).ToString() & ", " & dr1.Item(1).ToString)
Next
Console.ReadLine()
cn2.Close()
Dim cn3 As New OleDbConnection( _
"Provider=VFPOLEDB.1;Data Source=C:\Temp\;")
cn3.Open()
Dim cmd6 As New OleDbCommand( _
"Set Deleted Off", cn3)
cmd6.ExecuteNonQuery()
Dim cmd7 As New OleDbCommand( _
"Select Deleted('TestDBF') As IsDeleted, TestDBF.* From TestDBF", cn3)
Dim da2 As New OleDbDataAdapter(cmd7)
Dim ds2 As New DataSet
Dim dr2 As DataRow
da2.Fill(ds2)
For Each dr2 In ds2.Tables(0).Rows
Console.WriteLine( _
dr2.Item(0).ToString() & ", " & dr2.Item(1).ToString() & ", " & dr2.Item(2).ToString())
Next
Console.ReadLine()
cn2.Close()
Catch e As Exception
MsgBox(e.ToString())
End Try
Thank you,
This is indeed a workable solution.
Now, is there a way to perform the same work in a T-SQL script ?
I tried, but could not manage to "chain" successfully a 'SET DELETED OFF' statement and a SELECT with OPENQUERY or OPENDATASOURCE:
SELECT [name]
FROM OPENQUERY(linkedServer,'SELECT name FROM Members')
This returns all records, but not the deleted ones
SELECT [name]
FROM OPENQUERY(linkedServer,'SET Deleted OFF;
SELECT name FROM Members')
This produces the error '
Msg 7357, Level 16, State 2, Line 1
Cannot process the object "SET Deleted OFF;
SELECT name FROM Members". The OLE DB provider "VFPOLEDB" for linked server "linkedServer" indicates that either the object has no columns or the current user does not have permissions on that object.
'When doing it with an EXECUTE statement as pass-through query on a linked server (using OLE DB provider for FoxPro, of course), it says it successfully executes, but does not return the result of the select query:
DECLARE @.Query varchar(max)
SET @.Query='SELECT name FROM Members'
EXECUTE (@.Query) AT linkedServer
This returns all records, but not the deleted ones
DECLARE @.Query varchar(max)
SET @.Query='SET Deleted OFF' + CHAR(13) + 'SELECT name FROM Members'
EXECUTE (@.Query) AT linkedServer
This produces the query output 'Command(s) completed successfully.', but does not return any result.
Kind regards,
Bertrand Larsy
|||Hi Bertrand,
I don't have time to try it now but it might work with a semicolon: "Set Deleted Off;Select * From MyTable..."
|||Neither of the 2 following samples give any result:
DECLARE @.Query varchar(max)
SET @.Query='SET Deleted OFF;SELECT name FROM Members'
EXECUTE (@.Query) AT linkedServer
DECLARE @.Query varchar(max)
SET @.Query='SET Deleted OFF;' + CHAR(13) + 'SELECT name FROM Members'
EXECUTE (@.Query) AT linkedServer
Anyway, thank you for your answers, I will make a CLR stored procedure of your first reply.
Kind regards,
Bertrand Larsy
Wednesday, March 7, 2012
Managing Multiple Excel incoming files?
I have this situation. I have a client which have several locations they
work primary with excel forms and they are thinking in doing reports with
them. What they want is to import those Excel files into SQL Server for
later using crystal reports or maybe asp.net for reporting. Those files
will come every week from diferent locations then go to SQL Server and then
they should be stored in a folder in the server for backup. So this means
that i have to deal with the importing but also with the file naming. This
is because they want the reports to be date based. So i have to ask them to
include the date as part of the file name or changing the file name after
procesing the file if I want to store them all in the same folder after
procesing.
So the real question is how do I deal with multiple file in regular basis
bye changing the name of the file or enforcing they send me the file with
the date already included. If the recomendation is the second one how can i
tell the system to change the files after the procesing?
Is there any easy way or tool to achive this? is there any way i can
configure DTS to do that?
EliezerThe easiest way would probably be to use a script task in DTS and us the
File System Object to manipulate the files. It can be done from TSQL but its
pretty kludgy. Using FSO from DTS will allow you a lot more flexibility and
control.
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Eliezer Figueroa" <efigueroa@.propoint.com.do> wrote in message
news:Xns9479AA48BF55Aefigueroapropointco
m@.216.196.97.132...
quote:
> Managing Multiple Excel incoming files?
> I have this situation. I have a client which have several locations they
> work primary with excel forms and they are thinking in doing reports with
> them. What they want is to import those Excel files into SQL Server for
> later using crystal reports or maybe asp.net for reporting. Those files
> will come every week from diferent locations then go to SQL Server and
then
quote:
> they should be stored in a folder in the server for backup. So this means
> that i have to deal with the importing but also with the file naming. This
> is because they want the reports to be date based. So i have to ask them
to
quote:
> include the date as part of the file name or changing the file name after
> procesing the file if I want to store them all in the same folder after
> procesing.
> So the real question is how do I deal with multiple file in regular basis
> bye changing the name of the file or enforcing they send me the file with
> the date already included. If the recomendation is the second one how can
i
quote:
> tell the system to change the files after the procesing?
> Is there any easy way or tool to achive this? is there any way i can
> configure DTS to do that?
>
> Eliezer
Managing Multiple Excel incoming files?
I have this situation. I have a client which have several locations they
work primary with excel forms and they are thinking in doing reports with
them. What they want is to import those Excel files into SQL Server for
later using crystal reports or maybe asp.net for reporting. Those files
will come every week from diferent locations then go to SQL Server and then
they should be stored in a folder in the server for backup. So this means
that i have to deal with the importing but also with the file naming. This
is because they want the reports to be date based. So i have to ask them to
include the date as part of the file name or changing the file name after
procesing the file if I want to store them all in the same folder after
procesing.
So the real question is how do I deal with multiple file in regular basis
bye changing the name of the file or enforcing they send me the file with
the date already included. If the recomendation is the second one how can i
tell the system to change the files after the procesing?
Is there any easy way or tool to achive this? is there any way i can
configure DTS to do that?
EliezerThe easiest way would probably be to use a script task in DTS and us the
File System Object to manipulate the files. It can be done from TSQL but its
pretty kludgy. Using FSO from DTS will allow you a lot more flexibility and
control.
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Eliezer Figueroa" <efigueroa@.propoint.com.do> wrote in message
news:Xns9479AA48BF55Aefigueroapropointcom@.216.196.97.132...
> Managing Multiple Excel incoming files?
> I have this situation. I have a client which have several locations they
> work primary with excel forms and they are thinking in doing reports with
> them. What they want is to import those Excel files into SQL Server for
> later using crystal reports or maybe asp.net for reporting. Those files
> will come every week from diferent locations then go to SQL Server and
then
> they should be stored in a folder in the server for backup. So this means
> that i have to deal with the importing but also with the file naming. This
> is because they want the reports to be date based. So i have to ask them
to
> include the date as part of the file name or changing the file name after
> procesing the file if I want to store them all in the same folder after
> procesing.
> So the real question is how do I deal with multiple file in regular basis
> bye changing the name of the file or enforcing they send me the file with
> the date already included. If the recomendation is the second one how can
i
> tell the system to change the files after the procesing?
> Is there any easy way or tool to achive this? is there any way i can
> configure DTS to do that?
>
> Eliezer
Saturday, February 25, 2012
Managing backup files using SQL Agent
are backed up to disk using maintenance plans. This client wants to copy SQL
backup files on the disks of these servers to an additional server with a
tape drive to do consolidated backup to tape.
Is the best way to copy backup files already on disk to a network share to
use a DOS copy command through SQL Agent?
If so, is it best to run SQL Agent using a domain account with substantial
rights to ensure that SQL agent has appropriate file permissions both locally
and on network paths? When SQL agent runs under the local system account,
file copy operations fail with "Access denied" messages.
Does anyone have suggestions on how to do this task?
Larry Menzin
American Techsystems Corp.
I run my SQL Agent using a Domain User account that is local administrator
on the server.
In your case, just add a step to the jobs that the maintenance plans created
that calls XP_Cmdshell to do a DOS copy of the files after the backup is
complete.
Kevin Hill
President
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
www.DallasDBAs.com/forum - new DB forum for Dallas/Ft. Worth area DBAs.
www.experts-exchange.com - experts compete for points to answer your
questions
"Larry Menzin" <LarryMenzin@.discussions.microsoft.com> wrote in message
news:B52A63D9-A817-430C-9B0F-17139F121FBC@.microsoft.com...
> My client has about 3 servers with several databases on each. These
> databases
> are backed up to disk using maintenance plans. This client wants to copy
> SQL
> backup files on the disks of these servers to an additional server with a
> tape drive to do consolidated backup to tape.
> Is the best way to copy backup files already on disk to a network share to
> use a DOS copy command through SQL Agent?
> If so, is it best to run SQL Agent using a domain account with substantial
> rights to ensure that SQL agent has appropriate file permissions both
> locally
> and on network paths? When SQL agent runs under the local system account,
> file copy operations fail with "Access denied" messages.
> Does anyone have suggestions on how to do this task?
> --
> Larry Menzin
> American Techsystems Corp.
|||Hi
Do it as a OperatingSystemCommand (cmdExec) in SQL Agent.
Something like:
xcopy *.bak \\servername\sharename\*.* /E /Y
SQL Server has to use a domain account to run under, otherwise it does not
have a way to authenticate itself with the other server.
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Larry Menzin" <LarryMenzin@.discussions.microsoft.com> wrote in message
news:B52A63D9-A817-430C-9B0F-17139F121FBC@.microsoft.com...
> My client has about 3 servers with several databases on each. These
> databases
> are backed up to disk using maintenance plans. This client wants to copy
> SQL
> backup files on the disks of these servers to an additional server with a
> tape drive to do consolidated backup to tape.
> Is the best way to copy backup files already on disk to a network share to
> use a DOS copy command through SQL Agent?
> If so, is it best to run SQL Agent using a domain account with substantial
> rights to ensure that SQL agent has appropriate file permissions both
> locally
> and on network paths? When SQL agent runs under the local system account,
> file copy operations fail with "Access denied" messages.
> Does anyone have suggestions on how to do this task?
> --
> Larry Menzin
> American Techsystems Corp.
Managing backup files using SQL Agent
s
are backed up to disk using maintenance plans. This client wants to copy SQL
backup files on the disks of these servers to an additional server with a
tape drive to do consolidated backup to tape.
Is the best way to copy backup files already on disk to a network share to
use a DOS copy command through SQL Agent?
If so, is it best to run SQL Agent using a domain account with substantial
rights to ensure that SQL agent has appropriate file permissions both locall
y
and on network paths? When SQL agent runs under the local system account,
file copy operations fail with "Access denied" messages.
Does anyone have suggestions on how to do this task?
Larry Menzin
American Techsystems Corp.I run my SQL Agent using a Domain User account that is local administrator
on the server.
In your case, just add a step to the jobs that the maintenance plans created
that calls XP_Cmdshell to do a DOS copy of the files after the backup is
complete.
Kevin Hill
President
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
www.DallasDBAs.com/forum - new DB forum for Dallas/Ft. Worth area DBAs.
www.experts-exchange.com - experts compete for points to answer your
questions
"Larry Menzin" <LarryMenzin@.discussions.microsoft.com> wrote in message
news:B52A63D9-A817-430C-9B0F-17139F121FBC@.microsoft.com...
> My client has about 3 servers with several databases on each. These
> databases
> are backed up to disk using maintenance plans. This client wants to copy
> SQL
> backup files on the disks of these servers to an additional server with a
> tape drive to do consolidated backup to tape.
> Is the best way to copy backup files already on disk to a network share to
> use a DOS copy command through SQL Agent?
> If so, is it best to run SQL Agent using a domain account with substantial
> rights to ensure that SQL agent has appropriate file permissions both
> locally
> and on network paths? When SQL agent runs under the local system account,
> file copy operations fail with "Access denied" messages.
> Does anyone have suggestions on how to do this task?
> --
> Larry Menzin
> American Techsystems Corp.|||Hi
Do it as a OperatingSystemCommand (cmdExec) in SQL Agent.
Something like:
xcopy *.bak \\servername\sharename\*.* /E /Y
SQL Server has to use a domain account to run under, otherwise it does not
have a way to authenticate itself with the other server.
--
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Larry Menzin" <LarryMenzin@.discussions.microsoft.com> wrote in message
news:B52A63D9-A817-430C-9B0F-17139F121FBC@.microsoft.com...
> My client has about 3 servers with several databases on each. These
> databases
> are backed up to disk using maintenance plans. This client wants to copy
> SQL
> backup files on the disks of these servers to an additional server with a
> tape drive to do consolidated backup to tape.
> Is the best way to copy backup files already on disk to a network share to
> use a DOS copy command through SQL Agent?
> If so, is it best to run SQL Agent using a domain account with substantial
> rights to ensure that SQL agent has appropriate file permissions both
> locally
> and on network paths? When SQL agent runs under the local system account,
> file copy operations fail with "Access denied" messages.
> Does anyone have suggestions on how to do this task?
> --
> Larry Menzin
> American Techsystems Corp.
Managing backup files using SQL Agent
are backed up to disk using maintenance plans. This client wants to copy SQL
backup files on the disks of these servers to an additional server with a
tape drive to do consolidated backup to tape.
Is the best way to copy backup files already on disk to a network share to
use a DOS copy command through SQL Agent?
If so, is it best to run SQL Agent using a domain account with substantial
rights to ensure that SQL agent has appropriate file permissions both locally
and on network paths? When SQL agent runs under the local system account,
file copy operations fail with "Access denied" messages.
Does anyone have suggestions on how to do this task?
--
Larry Menzin
American Techsystems Corp.I run my SQL Agent using a Domain User account that is local administrator
on the server.
In your case, just add a step to the jobs that the maintenance plans created
that calls XP_Cmdshell to do a DOS copy of the files after the backup is
complete.
--
Kevin Hill
President
3NF Consulting
www.3nf-inc.com/NewsGroups.htm
www.DallasDBAs.com/forum - new DB forum for Dallas/Ft. Worth area DBAs.
www.experts-exchange.com - experts compete for points to answer your
questions
"Larry Menzin" <LarryMenzin@.discussions.microsoft.com> wrote in message
news:B52A63D9-A817-430C-9B0F-17139F121FBC@.microsoft.com...
> My client has about 3 servers with several databases on each. These
> databases
> are backed up to disk using maintenance plans. This client wants to copy
> SQL
> backup files on the disks of these servers to an additional server with a
> tape drive to do consolidated backup to tape.
> Is the best way to copy backup files already on disk to a network share to
> use a DOS copy command through SQL Agent?
> If so, is it best to run SQL Agent using a domain account with substantial
> rights to ensure that SQL agent has appropriate file permissions both
> locally
> and on network paths? When SQL agent runs under the local system account,
> file copy operations fail with "Access denied" messages.
> Does anyone have suggestions on how to do this task?
> --
> Larry Menzin
> American Techsystems Corp.|||Hi
Do it as a OperatingSystemCommand (cmdExec) in SQL Agent.
Something like:
xcopy *.bak \\servername\sharename\*.* /E /Y
SQL Server has to use a domain account to run under, otherwise it does not
have a way to authenticate itself with the other server.
--
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Larry Menzin" <LarryMenzin@.discussions.microsoft.com> wrote in message
news:B52A63D9-A817-430C-9B0F-17139F121FBC@.microsoft.com...
> My client has about 3 servers with several databases on each. These
> databases
> are backed up to disk using maintenance plans. This client wants to copy
> SQL
> backup files on the disks of these servers to an additional server with a
> tape drive to do consolidated backup to tape.
> Is the best way to copy backup files already on disk to a network share to
> use a DOS copy command through SQL Agent?
> If so, is it best to run SQL Agent using a domain account with substantial
> rights to ensure that SQL agent has appropriate file permissions both
> locally
> and on network paths? When SQL agent runs under the local system account,
> file copy operations fail with "Access denied" messages.
> Does anyone have suggestions on how to do this task?
> --
> Larry Menzin
> American Techsystems Corp.
Monday, February 20, 2012
Management Studio: connect again to load each SQL file
On Management Studio, can we choose to open any SQL files in the same Query window?
Right now, whenever we open a SQL file, we always have to "Connect to Database Engine" each time. In the new Query window, we have to select a database each time. For example, if we want to run 3 SQL scripts in the database "DB1", we have to do the following steps:
1. Click "Open File" to load the SQL file "S1.sql"; Connect to Database Engine; On the new Query window, select the database "DB1"; Execute;
2. Click "Open File" to load the SQL file "S2.sql"; Connect to Database Engine; On the new Query window, select the database "DB1"; Execute;
3. Click "Open File" to load the SQL file "S3.sql"; Connect to Database Engine; On the new Query window, select the database "DB1"; Execute;
Is there any easier way to run a few SQL files in the same database without signing on and selecting the database so many times?
Thanks,
Tony
i.e.
sqlcmd.exe -E -S%computername% -dpubs -ifile1.sql
sqlcmd.exe -E -S%computername% -dpubs -ifile2.sql
sqlcmd.exe -E -S%computername% -dpubs -ifile3.sql|||Thanks, Greg.
As a DBA, I use "SQL Server 2000 Enterprise Manager" and "Query Analyzer" daily to administer and run SQL scripts among a lot of database servers. I do use your suggested commands to run a few fix scripts by SQL jobs or Task schedulers. But for some ad hoc SQL scripts, query analyzer gives me a nice way to load and run any SQL script file in any database.
Some users also logged a suggestion on MSDN product feedback center to request this for SQL Server 2005. According to Microsoft:
Resolved as By Design by Microsoft on 2005-05-24 at 09:19:03
Hi,
This will significantly improve with the June CTP. The New Query command is more aware of where you are in the UI to guess your connection. If the connection can't be established within 5 seconds, we will then display the connection dialog to allow you to Cancel the connection.
Thank you,
Bill Ramos
We are using the June CTP. The "New Query" command works great. But the "Open File" command is still awkward. Hope Microsoft can improve the "Open File" command also. There is a workaround though. I can use "notepad" to open all SQL script files. Then copy and paste to the same query window to run them one at a time. It is ironic by doing so in this next-generation SQL Server. But at least, this workaround is better than logging on and selecting a database for each "Open File" command.|||
I dug around a bit, and found a solution that may/may not work for you. Here's what I did:
In SQL Enterprise Manager:
- create a new Project.
- Add all your SQL Files to your project in "Queries"
- Create a new connection ( or multiple connections if you have multiple servers to connect to) in "Connections". Make sure to set a default database.
Once this is done, every time you double-click on your file in "Queries", it will open it in the server and database entry specified in "Connections".
As far as doing the same thing in "Open File", my guess is we'd need a whole new icon to do this, similar to how we have "New Query", which opens a new window based on the existing connection, and "Database Engine Query", which opens a new window and prompts for a new connection, regardless what connections you have open.
|||I logged a suggestion with Microsoft to add a "Load SQL Script" command within the current existing query window. See the details:http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=8098e484-1019-4331-aaba-1d11828d887a
They will take it under consideration for the next release. At meantime, they also suggested to use "Project" to hold connections and queries. I tried it. The only thing I do not like is that we cannot change its "Associated Connection" in the query properties. That means I cannot run the same query in another server. I have to save a copy of the same query for each different connection.|||Thanks to Erland Sommarskog for his post on my suggestion, we can use "Edit -> Insert File as Text". It is perfect.|||
Not quite perfect. I'd like to be able to select several files in Windows Explorer at once, hit "Enter", and have them open with my current cnxn or prompt me once for the cnxn to be used for all files.
Even better:
1. If I'm opening several files at once, and I am not currently connected to a server or the tab/window that has focus isn't connected, prompt me for the first file's cnxn and ask if I want to apply that cnxn to the subsequent files.
2. If I am connected then presume I want to use the existing cnxn of the tab/window I have focus on (in the case I have several tabs open with different cnxns).
Management Studio: connect again to load each SQL file
On Management Studio, can we choose to open any SQL files in the same Query window?
Right now, whenever we open a SQL file, we always have to "Connect to Database Engine" each time. In the new Query window, we have to select a database each time. For example, if we want to run 3 SQL scripts in the database "DB1", we have to do the following steps:
1. Click "Open File" to load the SQL file "S1.sql"; Connect to Database Engine; On the new Query window, select the database "DB1"; Execute;
2. Click "Open File" to load the SQL file "S2.sql"; Connect to Database Engine; On the new Query window, select the database "DB1"; Execute;
3. Click "Open File" to load the SQL file "S3.sql"; Connect to Database Engine; On the new Query window, select the database "DB1"; Execute;
Is there any easier way to run a few SQL files in the same database without signing on and selecting the database so many times?
Thanks,
Tony
i.e.
sqlcmd.exe -E -S%computername% -dpubs -ifile1.sql
sqlcmd.exe -E -S%computername% -dpubs -ifile2.sql
sqlcmd.exe -E -S%computername% -dpubs -ifile3.sql
|||Thanks, Greg.
As a DBA, I use "SQL Server 2000 Enterprise Manager" and "Query Analyzer" daily to administer and run SQL scripts among a lot of database servers. I do use your suggested commands to run a few fix scripts by SQL jobs or Task schedulers. But for some ad hoc SQL scripts, query analyzer gives me a nice way to load and run any SQL script file in any database.
Some users also logged a suggestion on MSDN product feedback center to request this for SQL Server 2005. According to Microsoft:
Resolved as By Design by Microsoft on 2005-05-24 at 09:19:03
Hi,
This will significantly improve with the June CTP. The New Query command is more aware of where you are in the UI to guess your connection. If the connection can't be established within 5 seconds, we will then display the connection dialog to allow you to Cancel the connection.
Thank you,
Bill Ramos
We are using the June CTP. The "New Query" command works great. But the "Open File" command is still awkward. Hope Microsoft can improve the "Open File" command also. There is a workaround though. I can use "notepad" to open all SQL script files. Then copy and paste to the same query window to run them one at a time. It is ironic by doing so in this next-generation SQL Server. But at least, this workaround is better than logging on and selecting a database for each "Open File" command.|||
I dug around a bit, and found a solution that may/may not work for you. Here's what I did:
In SQL Enterprise Manager:
- create a new Project.
- Add all your SQL Files to your project in "Queries"
- Create a new connection ( or multiple connections if you have multiple servers to connect to) in "Connections". Make sure to set a default database.
Once this is done, every time you double-click on your file in "Queries", it will open it in the server and database entry specified in "Connections".
As far as doing the same thing in "Open File", my guess is we'd need a whole new icon to do this, similar to how we have "New Query", which opens a new window based on the existing connection, and "Database Engine Query", which opens a new window and prompts for a new connection, regardless what connections you have open.
|||I logged a suggestion with Microsoft to add a "Load SQL Script" command within the current existing query window. See the details:http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=8098e484-1019-4331-aaba-1d11828d887a
They will take it under consideration for the next release. At meantime, they also suggested to use "Project" to hold connections and queries. I tried it. The only thing I do not like is that we cannot change its "Associated Connection" in the query properties. That means I cannot run the same query in another server. I have to save a copy of the same query for each different connection.|||Thanks to Erland Sommarskog for his post on my suggestion, we can use "Edit -> Insert File as Text". It is perfect.
|||
Not quite perfect. I'd like to be able to select several files in Windows Explorer at once, hit "Enter", and have them open with my current cnxn or prompt me once for the cnxn to be used for all files.
Even better:
1. If I'm opening several files at once, and I am not currently connected to a server or the tab/window that has focus isn't connected, prompt me for the first file's cnxn and ask if I want to apply that cnxn to the subsequent files.
2. If I am connected then presume I want to use the existing cnxn of the tab/window I have focus on (in the case I have several tabs open with different cnxns).