Friday, March 23, 2012
Scheduling a job !
i am trying to automate the following process using TSQL.
1. Import table 'A' from Database 'x' to my Database 'Y'
2. After the import is complete , insert an identity column in table A, make it a Primary key and then rename it as 'B'.
I was successful in Scheduling a job to import the table from database 'X' to "Y'. but i am not able to insert the identity column and rename the table.
Can anyone please help me !
thanks in advance !
AraoCan't you let the job first do a Create Table to create the new table with the name you want it to have, then imort into that table?|||i will try doing that. but i need to drop the previous table which has the same name. and the job is erroring out at this point. it says " the @.newname value is already in use as a object name and would cause duplicate that is not permitted. the step failed " but it's not in use by any of the users. i tried several times but it will never drop the table ! the following is my code.
if exists (select * from sysobjects where id = object_id(N'[dbo].[AR_ACCOUNTS') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AR_ACCOUNTS]
GO
EXEC sp_rename 'AR1_CUSTOMERMASTER', 'AR_ACCOUNTS'
GO
thanks,
anithasql
Scheduling a backup
I want to schedule a backup of three databases on a daily basis.
I've written the code to run the 3 backups in TSQL and was wondering how
best to automate this procedure?
Should I put the code in an sproc and then schedule running that command
in the DTS or should I just add the TSQL into a DTS command?? Or is
there a better way of doing this?
I then prefer to use DTSRUNUI to generate the syntax and then schedule
this from the windows scheduler as opposed to the SQL SCheduler in EM
(is this the best way?)
Help would be appreciated
M3ckon
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!"m3ckon" <anonymous@.devdex.com> wrote in message
news:40cdbb60$0$25520$c397aba@.news.newsgroups.ws.. .
> Hi,
> I want to schedule a backup of three databases on a daily basis.
> I've written the code to run the 3 backups in TSQL and was wondering how
> best to automate this procedure?
> Should I put the code in an sproc and then schedule running that command
> in the DTS or should I just add the TSQL into a DTS command?? Or is
> there a better way of doing this?
> I then prefer to use DTSRUNUI to generate the syntax and then schedule
> this from the windows scheduler as opposed to the SQL SCheduler in EM
> (is this the best way?)
> Help would be appreciated
> M3ckon
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!
Putting the code in a procedure may be best, because it's simpler to manage,
and you don't get awkward problems working with EM or other tools which
allow only a very limited area for viewing code. If you're executing a DTS
package, then your geenral approach above seems OK, although the Windows
scheduler is rather limited compared to the MSSQL one, so unless there is a
very good reason not to, I would use the MSSQL scheduler.
Having said all that, using DTS as a backup mechanism is a little unusual,
unless your backups are part of a larger workflow. For simple backups,
maintenance plans are a convenient solution, although since they have some
limitations, you might have to write your own TSQL code sooner or later. But
scheduling a stored procedure in MSSQL is generally less complicated than
scheduling a DTS package, unless you need some extra functionality.
Simon|||Hi
You can do it in serveral ways, but I would control it through a SQL Agent
job. If you run the backup
See sp_add_job, sp_add_jobschedule, and sp_add_jobstep
http://msdn.microsoft.com/library/d...asp?frame=true
If you want see a backup job programmed there is a schedule option at the
bottom of the backup wizard screen in Enterprise Manager.
John
"m3ckon" <anonymous@.devdex.com> wrote in message
news:40cdbb60$0$25520$c397aba@.news.newsgroups.ws.. .
> Hi,
> I want to schedule a backup of three databases on a daily basis.
> I've written the code to run the 3 backups in TSQL and was wondering how
> best to automate this procedure?
> Should I put the code in an sproc and then schedule running that command
> in the DTS or should I just add the TSQL into a DTS command?? Or is
> there a better way of doing this?
> I then prefer to use DTSRUNUI to generate the syntax and then schedule
> this from the windows scheduler as opposed to the SQL SCheduler in EM
> (is this the best way?)
> Help would be appreciated
> M3ckon
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!
Wednesday, March 21, 2012
Scheduled sql cannot access the network drives?
I have a stored procedure performing several tsql operations with MS
Access and Excel files stored into the network file system, and
therefore using OpenDataSouce with these files in the network,
accessible through mapped network drives.
My user has a profile that maps the necessary network drives at boot.
SQL Server runs on the server with an account created for that. This
accont has also a profile mapping the necessary network drives.
The stored procedure runs fine only if I launch it with SQL Server
Management Studio on the server, logging in directly on the server (at
this point the network drives are mapped correctly).
If I launch the Stored Procedure with SQL Server Management Studio on
my client, it doesn't find the network drives and fails.
The same happens when I schedule the stored procedure on the server
with SQL Server Agent, which runs with an account performing the
mapping in its profile.
A suggestion in common, don′t use mapped network driver, use UNC paths !
If you want to use ressources within the network you will need appropiate permissions either for the service account SQL Server Service is running with or the service account SQL Server Agent is running with (if you do that within a scheduled job). An alternative would be to setup a proxy account for the service [1]
[1] http://www.databasejournal.com/features/mssql/article.php/1580041
In SQL Server 2005 proxy accounts can also be configured through the Configuration interface which you will find in the program collection.
HTH, Jens SUessmeyer.
http://www.sqlserver2005.de
Tuesday, March 20, 2012
Scheduled Jobs Failing
fine on but wont run as a scheduled jobs with any steps. TSQL steps run fine
but
DTSRUN /S<server> /E /N<localpackagename>
fails even though it runs on its own.
I noticed that on SQL Server Agent Properties and the Job System tab there
is a checkbox at the bottom relating to CmdExec. On setting this on my
laptop then unsetting it the job does not run on that either now.
Can someone get me out of this hole
Thanks
Andy Willis
Have a look at this:
http://www.support.microsoft.com/?id=269074 How to Run a DTS Package as a
Scheduled Job
Andrew J. Kelly SQL MVP
"Andy Willis" <andrewrwillis@.blueyonder.co.uk> wrote in message
news:e8qeFIT4EHA.208@.TK2MSFTNGP12.phx.gbl...
>I have some Local Packages to import data from Access into SQL which run
> fine on but wont run as a scheduled jobs with any steps. TSQL steps run
> fine
> but
> DTSRUN /S<server> /E /N<localpackagename>
> fails even though it runs on its own.
> I noticed that on SQL Server Agent Properties and the Job System tab there
> is a checkbox at the bottom relating to CmdExec. On setting this on my
> laptop then unsetting it the job does not run on that either now.
> Can someone get me out of this hole
> Thanks
> Andy Willis
>
Scheduled Job Sometimes Error Sometimes Not
using CmdExec 'DTSRun', step 2 using TSQL to execute just simple query.
This job execute recurely every day, every 6 hours.
The problem is, sometimes this job was successfull, but sometimes
failed with error as below :
...
...
Process Exit Code -1073741819. The step failed.
Please help me, what the cause of the error?
Any help would be greatly appreciated.Resant (resant_v@.yahoo.com) writes:
> I have a scheduled job contain 2 steps. Step 1 is execute DTS Package
> using CmdExec 'DTSRun', step 2 using TSQL to execute just simple query.
> This job execute recurely every day, every 6 hours.
> The problem is, sometimes this job was successfull, but sometimes
> failed with error as below :
> ...
> ...
> Process Exit Code -1073741819. The step failed.
> Please help me, what the cause of the error?
> Any help would be greatly appreciated.
In View Job History, there is a check box for "Show step details". Check
that box, and you may find some more details.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Thanks for your reply.
The error that I've post is taken after I've checked "Show step
details". OK, I'll post the error again completely :
Executed as user: XXXX\xxxx. ...un OnStart:
DTSStep_DTSExecuteSQLTask_6 DTSRun OnFinish:
DTSStep_DTSExecuteSQLTask_6 DTSRun OnStart:
DTSStep_DTSExecuteSQLTask_10 DTSRun OnFinish:
DTSStep_DTSExecuteSQLTask_10 DTSRun OnStart:
DTSStep_DTSDataPumpTask_1 DTSRun OnStart: DTSStep_DTSDataPumpTask_2
DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
DTSStep_DTSDataPumpTask_3 DTSRun OnStart: DTSStep_DTSDataPumpTask_2
DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTSDataPumpTask_4
DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTSDataPumpTask_4
DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTSDataPumpTask_4
DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTS... Process
Exit Code -1073741819. The step failed.|||Resant (resant_v@.yahoo.com) writes:
> Thanks for your reply.
> The error that I've post is taken after I've checked "Show step
> details". OK, I'll post the error again completely :
> Executed as user: XXXX\xxxx. ...un OnStart:
> DTSStep_DTSExecuteSQLTask_6 DTSRun OnFinish:
> DTSStep_DTSExecuteSQLTask_6 DTSRun OnStart:
> DTSStep_DTSExecuteSQLTask_10 DTSRun OnFinish:
> DTSStep_DTSExecuteSQLTask_10 DTSRun OnStart:
> DTSStep_DTSDataPumpTask_1 DTSRun OnStart: DTSStep_DTSDataPumpTask_2
> DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
> DTSStep_DTSDataPumpTask_3 DTSRun OnStart: DTSStep_DTSDataPumpTask_2
> DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
> DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTSDataPumpTask_4
> DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
> DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTSDataPumpTask_4
> DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
> DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTSDataPumpTask_4
> DTSRun OnStart: DTSStep_DTSDataPumpTask_4 DTSRun OnStart:
> DTSStep_DTSDataPumpTask_4 DTSRun OnStart: DTSStep_DTS... Process
> Exit Code -1073741819. The step failed.
That's pretty anonymous. Unfortunately I don't know DTS, so I don't
have any suggestions to offer. Maybe the people in
microsoft.public.sqlserver.dts has any ideas.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Some Googling suggests that the error may be caused by a Windows bug:
http://support.microsoft.com/defaul...kb;EN-US;306497
http://groups-beta.google.com/group...lr=&sa=N&tab=wg
If you don't already have the latest servicepacks for Windows and
MSSQL, it would probably be worth installing them to see if that
resolves the issue. Since a few people seem to have seen this error in
connection with a virus infection, that would be something else to
check. If this doesn't help, then it might be worth calling Microsoft.
Simon