Showing posts with label records. Show all posts
Showing posts with label records. Show all posts

Wednesday, March 28, 2012

Scheduling Montly Report

Hi all,

I currently have a report which needs to be scheduled to run on every 1st of the month to get records of last month. For example, on Feb. 01 the report will get all records by the date range of Jan. 01 to Jan. 31. My current report does not have any defined report parameter. It gets all the date range it finds from the table.

Please advise how can I start with this.

Any help is much appreciated! Thanks!

Hi,

Couldnt get it completely.

you want to run a report on monthly basis, then you need to have two datetime parameters i.e. from_time and to_time, then you want default value to be last months dates, use expression for the defualt value....

your expr. for "from time" should be like

=switch(month(now())=1,"01/01/2007",

month(now())=2,"02/01/2007, and in same way you can have it for to time frame....

HTH

Priyank

|||

Hi

As i understand the requirement over here is to have a report which shows the data for previous month

say the report is executed on mar 1st then the report should display data till feb28th correct?

For this a report has to be created with 2 parameters Startdate and EndDate.

However subscription can be created in Report Manager.

Regards

Smitha

|||

You don't need a param for this, although to give you an perfectly appropriate example it would be good to know if you are calling a stored procedure or writing the query directly in the report, or what.

Let's say you are writing the query directly in the report, not a stored procedure.

You already know that you can schedule it to run on the first of the month, right? Here is a query that will do what you want, given that you know you are running it every month on the first:

Code Snippet

select <WHATEVER> from <YOUR TABLE> where

DATEDIFF(month,GETDATE()-1,<YOUR DATE COLUMN>) = 0

' the default behavior of the date subtraction is by days, see?

' and you're running the subscription on the first of the month,

' so this works.

Let's make it better. Here is a query that will do what you want, no matter what date of the month it is run on, which is : provide the results for the month *before* the month in which it is run:

Code Snippet

select <WHATEVER> from <YOUR TABLE> where

DATEDIFF(month,DATEADD(month,-1,GETDATE()),

<YOUR DATE COLUMN>) = 0

Now, if you prefer, you can add a parameter and give your parameter the default value of Today (you may have to do some CASTing in here, not checking this):

Code Snippet

select <WHATEVER> from <YOUR TABLE> where

DATEDIFF(month,DATEADD(month,-1,@.YourParam),

<YOUR DATE COLUMN>) = 0

... hope this helps,

>L<

|||

Thank you all for the helpful solutions.

Yes basically it is just to get a report of previous month when it is scheduled to run.

|||

Lisa that's a cool little function!

Only question I have it whether it would work if you had data for more than one year in the table? i.e If you had 2 rows, one with July 2006 and one with July 2007 wouldn't the DateDiff(month, etc) return 0 for that even though the year is different?

As my own $0.02 I usually use something like

Beginning of last month

DATEADD(month,DATEDIFF(month,0,getdate)-1,0)

Beginning of this month

DATEADD(month,DATEDIFF(month,0,getdate),0)

Beginning of next month

DATEADD(month,DATEDIFF(month,0,getdate)+1,0)

which is sort of based off similar logic. Found it on a forum, and loved it. Can also do days/weeks by just switching the period name.

|||

>> whether it would work if you had data for more than one year in the table

It will actually work fine, D, check it out:

select datediff(month, '1/1/2007','1/1/2004')

will return -36 even though both dates are (obviously) in January. 3 * 12.

It's a *difference of months*. Not a difference of *month numbers* <s>.

>L<

|||Right you are - I should have run it through Query Analyzer first Smile

Scheduling Montly Report

Hi all,

I currently have a report which needs to be scheduled to run on every 1st of the month to get records of last month. For example, on Feb. 01 the report will get all records by the date range of Jan. 01 to Jan. 31. My current report does not have any defined report parameter. It gets all the date range it finds from the table.

Please advise how can I start with this.

Any help is much appreciated! Thanks!

Hi,

Couldnt get it completely.

you want to run a report on monthly basis, then you need to have two datetime parameters i.e. from_time and to_time, then you want default value to be last months dates, use expression for the defualt value....

your expr. for "from time" should be like

=switch(month(now())=1,"01/01/2007",

month(now())=2,"02/01/2007, and in same way you can have it for to time frame....

HTH

Priyank

|||

Hi

As i understand the requirement over here is to have a report which shows the data for previous month

say the report is executed on mar 1st then the report should display data till feb28th correct?

For this a report has to be created with 2 parameters Startdate and EndDate.

However subscription can be created in Report Manager.

Regards

Smitha

|||

You don't need a param for this, although to give you an perfectly appropriate example it would be good to know if you are calling a stored procedure or writing the query directly in the report, or what.

Let's say you are writing the query directly in the report, not a stored procedure.

You already know that you can schedule it to run on the first of the month, right? Here is a query that will do what you want, given that you know you are running it every month on the first:

Code Snippet

select <WHATEVER> from <YOUR TABLE> where

DATEDIFF(month,GETDATE()-1,<YOUR DATE COLUMN>) = 0

' the default behavior of the date subtraction is by days, see?

' and you're running the subscription on the first of the month,

' so this works.

Let's make it better. Here is a query that will do what you want, no matter what date of the month it is run on, which is : provide the results for the month *before* the month in which it is run:

Code Snippet

select <WHATEVER> from <YOUR TABLE> where

DATEDIFF(month,DATEADD(month,-1,GETDATE()),

<YOUR DATE COLUMN>) = 0

Now, if you prefer, you can add a parameter and give your parameter the default value of Today (you may have to do some CASTing in here, not checking this):

Code Snippet

select <WHATEVER> from <YOUR TABLE> where

DATEDIFF(month,DATEADD(month,-1,@.YourParam),

<YOUR DATE COLUMN>) = 0

... hope this helps,

>L<

|||

Thank you all for the helpful solutions.

Yes basically it is just to get a report of previous month when it is scheduled to run.

|||

Lisa that's a cool little function!

Only question I have it whether it would work if you had data for more than one year in the table? i.e If you had 2 rows, one with July 2006 and one with July 2007 wouldn't the DateDiff(month, etc) return 0 for that even though the year is different?

As my own $0.02 I usually use something like

Beginning of last month

DATEADD(month,DATEDIFF(month,0,getdate)-1,0)

Beginning of this month

DATEADD(month,DATEDIFF(month,0,getdate),0)

Beginning of next month

DATEADD(month,DATEDIFF(month,0,getdate)+1,0)

which is sort of based off similar logic. Found it on a forum, and loved it. Can also do days/weeks by just switching the period name.

|||

>> whether it would work if you had data for more than one year in the table

It will actually work fine, D, check it out:

select datediff(month, '1/1/2007','1/1/2004')

will return -36 even though both dates are (obviously) in January. 3 * 12.

It's a *difference of months*. Not a difference of *month numbers* <s>.

>L<

|||Right you are - I should have run it through Query Analyzer first Smile

Monday, March 26, 2012

scheduling a query

I need to scheduling a query to update some records.
I have to use a script in windows task manager or there is another way?
Many ThanksThe SQL Agent is a wonderful wat to schedule a query. Create a job and out
your query in a step.
"Simone" wrote:

> I need to scheduling a query to update some records.
> I have to use a script in windows task manager or there is another way?
> Many Thanks
>
>|||If you are using an edition of SQL Server which has an enterprise
manager and therefor a UI for SQL Server Agent, you can just create a
job with your query. Add a new job, add a new step (Transact SQL
Execution), paste your statement in there and add a schedule for it and
voil=E1, you=B4re done. iof you do=B4n=B4t have a GUI, you can use the
goold old fashioned AT to do your jobs. Just schedule your job by the
Windows Scheduler or AT, suing OSQL to run the query: OSQL -SServername
-UUsername -PPassword -Q"Here is my query".
HTH, jens Suessmeyer.|||you can create a job and schedule that
Jobs are under management-->Sql Server agent-->Jobs
make it a one step job paste your query or proc call in the step
command window and schedule the job
http://sqlservercode.blogspot.com/

scheduling a query

I need to scheduling a query to update some records.
I have to use a script in windows task manager or there is another way?
Many ThanksIf you are using an edition of SQL Server which has an enterprise
manager and therefor a UI for SQL Server Agent, you can just create a
job with your query. Add a new job, add a new step (Transact SQL
Execution), paste your statement in there and add a schedule for it and
voil=E1, you=B4re done. iof you do=B4n=B4t have a GUI, you can use the
goold old fashioned AT to do your jobs. Just schedule your job by the
Windows Scheduler or AT, suing OSQL to run the query: OSQL -SServername
-UUsername -PPassword -Q"Here is my query".
HTH, jens Suessmeyer.|||The SQL Agent is a wonderful wat to schedule a query. Create a job and out
your query in a step.
"Simone" wrote:
> I need to scheduling a query to update some records.
> I have to use a script in windows task manager or there is another way?
> Many Thanks
>
>|||you can create a job and schedule that
Jobs are under management-->Sql Server agent-->Jobs
make it a one step job paste your query or proc call in the step
command window and schedule the job
http://sqlservercode.blogspot.com/

scheduling a query

I need to scheduling a query to update some records.
I have to use a script in windows task manager or there is another way?
Many Thanks
The SQL Agent is a wonderful wat to schedule a query. Create a job and out
your query in a step.
"Simone" wrote:

> I need to scheduling a query to update some records.
> I have to use a script in windows task manager or there is another way?
> Many Thanks
>
>
|||If you are using an edition of SQL Server which has an enterprise
manager and therefor a UI for SQL Server Agent, you can just create a
job with your query. Add a new job, add a new step (Transact SQL
Execution), paste your statement in there and add a schedule for it and
voil=E1, you=B4re done. iof you do=B4n=B4t have a GUI, you can use the
goold old fashioned AT to do your jobs. Just schedule your job by the
Windows Scheduler or AT, suing OSQL to run the query: OSQL -SServername
-UUsername -PPassword -Q"Here is my query".
HTH, jens Suessmeyer.
|||you can create a job and schedule that
Jobs are under management-->Sql Server agent-->Jobs
make it a one step job paste your query or proc call in the step
command window and schedule the job
http://sqlservercode.blogspot.com/

Tuesday, March 20, 2012

Scheduled Job History

Is there a way to increase the number of records preserved in job
history? I have 82 jobs on my box, 30 of them run every 20 minutes
for 23 hours a day, every 30 days. Another 30 run once, every 30
days. The system seems to have a limit of 50 history records for any
job that hasn't run since yesterday and purges all history records if
the job is more than a week old. I didn't know if there might be a
configuration record buried in MSDB or somewhere else that would allow
me to increase this size or perhaps a system SP that prunes job
history that I could modify.

It isn't critical as the system is set to notify me when jobs fail,
but still, I'd like to be able to look at a given day and verify that
everything went normally."P.D.N. Tame" <wwphx@.hotmail.com> wrote in message
news:bcc5d277.0312090628.5061b581@.posting.google.c om...
> Is there a way to increase the number of records preserved in job
> history? I have 82 jobs on my box, 30 of them run every 20 minutes
> for 23 hours a day, every 30 days. Another 30 run once, every 30
> days. The system seems to have a limit of 50 history records for any
> job that hasn't run since yesterday and purges all history records if
> the job is more than a week old. I didn't know if there might be a
> configuration record buried in MSDB or somewhere else that would allow
> me to increase this size or perhaps a system SP that prunes job
> history that I could modify.
> It isn't critical as the system is set to notify me when jobs fail,
> but still, I'd like to be able to look at a given day and verify that
> everything went normally.

In Enterprise Manage, right-click SQL Server Agent, then pick Properties,
Job System, and set the history options as you want. You can also use
sp_set_sqlagent_properties, but this procedure isn't documented, so it may
not be the best way to go.

Simon

Friday, March 9, 2012

Schedule Stored Procedures

Hello all,

I created a stored proceduce to delete specific records from a table. I want it to run every week.

How can I schedule a stored procedure?

I tried with SQL Server Agent -> Jobs, but it isn't a transact SQL-script.

Any ideas?

Thanks in advance.just a thought.... and if you write "exec yourProc" as transact SQL-script?..|||Hello Konstantin,

Thanks for the quick reply. It's working! That simple...

Best regards.

Wednesday, March 7, 2012

schedule job to set database to single user mode

Task Summary:
I have a remote user to sending records every 5 minutes by DTS package.
I think the best way to handle this is to create a job that will up the
database
into single user mode, set the remote user to the single user.
allow the job to run 10 to 15 minutes then take it out of single user mode.
Task Break down:
1:
Put the database into single user mode.
assign myself as the user.
(How do I define which user has access?)
2:
Backup the database
unassign myself as the single user
assign remote user as the single user
3:
Scheduled the job to execute for 15 minutes
4:
take database out of single user mode
5:
Schedule job to execute evey 6 hours.
Hi
"mj" wrote:

> Task Summary:
> I have a remote user to sending records every 5 minutes by DTS package.
> I think the best way to handle this is to create a job that will up the
> database
> into single user mode, set the remote user to the single user.
> allow the job to run 10 to 15 minutes then take it out of single user mode.
>
> Task Break down:
> 1:
> Put the database into single user mode.
> assign myself as the user.
> (How do I define which user has access?)
> 2:
> Backup the database
> unassign myself as the single user
> assign remote user as the single user
> 3:
> Scheduled the job to execute for 15 minutes
> 4:
> take database out of single user mode
> 5:
> Schedule job to execute evey 6 hours.
>
You can not assign another user to be the single user in single user mode!
If you are not connected to the database when it is set in single user mode
then potentially anyone could get in and be that single user.
I am not sure why the remote user is send things every 5 minutes and you
will only want him to send something for a 15 minute period every 6 hours.
What may be a better scenario is that every 6 hours you fetch the information
from the remote location and then processes it in one batch, then the process
is controlled by the server. A different approach you be to have a second
database that the user updates (local or remote) and then use replication to
merge the differences. With SQL 2005 service broker may possibly be useful.
John
|||What is the justification for this attempt to "lock the database into
single-user mode for a specific user"?
TheSQLGuru
President
Indicium Resources, Inc.
"mj" <mj@.discussions.microsoft.com> wrote in message
news:137E0713-D3ED-4915-95CD-E4CD4D766A57@.microsoft.com...
> Task Summary:
> I have a remote user to sending records every 5 minutes by DTS package.
> I think the best way to handle this is to create a job that will up the
> database
> into single user mode, set the remote user to the single user.
> allow the job to run 10 to 15 minutes then take it out of single user
> mode.
>
> Task Break down:
> 1:
> Put the database into single user mode.
> assign myself as the user.
> (How do I define which user has access?)
> 2:
> Backup the database
> unassign myself as the single user
> assign remote user as the single user
> 3:
> Scheduled the job to execute for 15 minutes
> 4:
> take database out of single user mode
> 5:
> Schedule job to execute evey 6 hours.
>
>
|||Thanks John and SQLGuRu for the interest;
More Background Details:
The remote user has developed an extensive DTS package.
When the transformations have been completed, then the transformed
data is sent to a central server.
For this reason I can not just go get the data.
To ensure the migration is completed without interuption, I need to put the
server into single user mode.
To preserve the data prior to the migration, I need to perform a backup.
My current solution looks like this:
Procedure MySolution AS
Alter database Set Single_User
Perform back up of database
perform backup of logs
alter database Set Multi_User
End Procedure
Create Job
Call Procedure Mysolution
Schedule Job 6hrs
"TheSQLGuru" wrote:

> What is the justification for this attempt to "lock the database into
> single-user mode for a specific user"?
> --
> TheSQLGuru
> President
> Indicium Resources, Inc.
> "mj" <mj@.discussions.microsoft.com> wrote in message
> news:137E0713-D3ED-4915-95CD-E4CD4D766A57@.microsoft.com...
>
>
|||Hi
"mj" wrote:
[vbcol=seagreen]
> Thanks John and SQLGuRu for the interest;
>
> More Background Details:
> The remote user has developed an extensive DTS package.
> When the transformations have been completed, then the transformed
> data is sent to a central server.
> For this reason I can not just go get the data.
> To ensure the migration is completed without interuption, I need to put the
> server into single user mode.
> To preserve the data prior to the migration, I need to perform a backup.
> My current solution looks like this:
> ----
> Procedure MySolution AS
> Alter database Set Single_User
> Perform back up of database
> perform backup of logs
> alter database Set Multi_User
> End Procedure
> Create Job
> Call Procedure Mysolution
> Schedule Job 6hrs
> ----
>
> "TheSQLGuru" wrote:
I can only assume that this is not a system with users, as a period of
unavailability every 6 hours is not the sort of service level that would be
classed as acceptable!!
Who do you need to load this every 6 hours?
Have you considered replication?
If you have a proper sequence of log backups you may not need to do the full
backup if you accept that you will need to restore the last full backup and
roll forward to return to the state prior to your process running.
Alternatively a differential backup would remove the need to restore some of
the log backups.
If you set the database into single user mode, then you can not guarantee
getting access to the database (for that single user) in subsequent job steps.
What do you do with the files that the process has transferred?
John

schedule job to set database to single user mode

Task Summary:
I have a remote user to sending records every 5 minutes by DTS package.
I think the best way to handle this is to create a job that will up the
database
into single user mode, set the remote user to the single user.
allow the job to run 10 to 15 minutes then take it out of single user mode.
Task Break down:
1:
Put the database into single user mode.
assign myself as the user.
(How do I define which user has access?)
2:
Backup the database
unassign myself as the single user
assign remote user as the single user
3:
Scheduled the job to execute for 15 minutes
4:
take database out of single user mode
5:
Schedule job to execute evey 6 hours.Hi
"mj" wrote:

> Task Summary:
> I have a remote user to sending records every 5 minutes by DTS package.
> I think the best way to handle this is to create a job that will up the
> database
> into single user mode, set the remote user to the single user.
> allow the job to run 10 to 15 minutes then take it out of single user mode
.
>
> Task Break down:
> 1:
> Put the database into single user mode.
> assign myself as the user.
> (How do I define which user has access?)
> 2:
> Backup the database
> unassign myself as the single user
> assign remote user as the single user
> 3:
> Scheduled the job to execute for 15 minutes
> 4:
> take database out of single user mode
> 5:
> Schedule job to execute evey 6 hours.
>
You can not assign another user to be the single user in single user mode!
If you are not connected to the database when it is set in single user mode
then potentially anyone could get in and be that single user.
I am not sure why the remote user is send things every 5 minutes and you
will only want him to send something for a 15 minute period every 6 hours.
What may be a better scenario is that every 6 hours you fetch the informatio
n
from the remote location and then processes it in one batch, then the proces
s
is controlled by the server. A different approach you be to have a second
database that the user updates (local or remote) and then use replication to
merge the differences. With SQL 2005 service broker may possibly be useful.
John|||What is the justification for this attempt to "lock the database into
single-user mode for a specific user"'
TheSQLGuru
President
Indicium Resources, Inc.
"mj" <mj@.discussions.microsoft.com> wrote in message
news:137E0713-D3ED-4915-95CD-E4CD4D766A57@.microsoft.com...
> Task Summary:
> I have a remote user to sending records every 5 minutes by DTS package.
> I think the best way to handle this is to create a job that will up the
> database
> into single user mode, set the remote user to the single user.
> allow the job to run 10 to 15 minutes then take it out of single user
> mode.
>
> Task Break down:
> 1:
> Put the database into single user mode.
> assign myself as the user.
> (How do I define which user has access?)
> 2:
> Backup the database
> unassign myself as the single user
> assign remote user as the single user
> 3:
> Scheduled the job to execute for 15 minutes
> 4:
> take database out of single user mode
> 5:
> Schedule job to execute evey 6 hours.
>
>|||Thanks John and SQLGuRu for the interest;
More Background Details:
The remote user has developed an extensive DTS package.
When the transformations have been completed, then the transformed
data is sent to a central server.
For this reason I can not just go get the data.
To ensure the migration is completed without interuption, I need to put the
server into single user mode.
To preserve the data prior to the migration, I need to perform a backup.
My current solution looks like this:
----
--
Procedure MySolution AS
Alter database Set Single_User
Perform back up of database
perform backup of logs
alter database Set Multi_User
End Procedure
Create Job
Call Procedure Mysolution
Schedule Job 6hrs
----
--
"TheSQLGuru" wrote:

> What is the justification for this attempt to "lock the database into
> single-user mode for a specific user"'
> --
> TheSQLGuru
> President
> Indicium Resources, Inc.
> "mj" <mj@.discussions.microsoft.com> wrote in message
> news:137E0713-D3ED-4915-95CD-E4CD4D766A57@.microsoft.com...
>
>|||Hi
"mj" wrote:
[vbcol=seagreen]
> Thanks John and SQLGuRu for the interest;
>
> More Background Details:
> The remote user has developed an extensive DTS package.
> When the transformations have been completed, then the transformed
> data is sent to a central server.
> For this reason I can not just go get the data.
> To ensure the migration is completed without interuption, I need to put th
e
> server into single user mode.
> To preserve the data prior to the migration, I need to perform a backup.
> My current solution looks like this:
> ----
--
> Procedure MySolution AS
> Alter database Set Single_User
> Perform back up of database
> perform backup of logs
> alter database Set Multi_User
> End Procedure
> Create Job
> Call Procedure Mysolution
> Schedule Job 6hrs
> ----
--
>
> "TheSQLGuru" wrote:
>
I can only assume that this is not a system with users, as a period of
unavailability every 6 hours is not the sort of service level that would be
classed as acceptable!!
Who do you need to load this every 6 hours?
Have you considered replication?
If you have a proper sequence of log backups you may not need to do the full
backup if you accept that you will need to restore the last full backup and
roll forward to return to the state prior to your process running.
Alternatively a differential backup would remove the need to restore some of
the log backups.
If you set the database into single user mode, then you can not guarantee
getting access to the database (for that single user) in subsequent job step
s.
What do you do with the files that the process has transferred?
John

schedule job to set database to single user mode

Task Summary:
I have a remote user to sending records every 5 minutes by DTS package.
I think the best way to handle this is to create a job that will up the
database
into single user mode, set the remote user to the single user.
allow the job to run 10 to 15 minutes then take it out of single user mode.
Task Break down:
1:
Put the database into single user mode.
assign myself as the user.
(How do I define which user has access?)
2:
Backup the database
unassign myself as the single user
assign remote user as the single user
3:
Scheduled the job to execute for 15 minutes
4:
take database out of single user mode
5:
Schedule job to execute evey 6 hours.Hi
"mj" wrote:
> Task Summary:
> I have a remote user to sending records every 5 minutes by DTS package.
> I think the best way to handle this is to create a job that will up the
> database
> into single user mode, set the remote user to the single user.
> allow the job to run 10 to 15 minutes then take it out of single user mode.
>
> Task Break down:
> 1:
> Put the database into single user mode.
> assign myself as the user.
> (How do I define which user has access?)
> 2:
> Backup the database
> unassign myself as the single user
> assign remote user as the single user
> 3:
> Scheduled the job to execute for 15 minutes
> 4:
> take database out of single user mode
> 5:
> Schedule job to execute evey 6 hours.
>
You can not assign another user to be the single user in single user mode!
If you are not connected to the database when it is set in single user mode
then potentially anyone could get in and be that single user.
I am not sure why the remote user is send things every 5 minutes and you
will only want him to send something for a 15 minute period every 6 hours.
What may be a better scenario is that every 6 hours you fetch the information
from the remote location and then processes it in one batch, then the process
is controlled by the server. A different approach you be to have a second
database that the user updates (local or remote) and then use replication to
merge the differences. With SQL 2005 service broker may possibly be useful.
John|||What is the justification for this attempt to "lock the database into
single-user mode for a specific user"'
--
TheSQLGuru
President
Indicium Resources, Inc.
"mj" <mj@.discussions.microsoft.com> wrote in message
news:137E0713-D3ED-4915-95CD-E4CD4D766A57@.microsoft.com...
> Task Summary:
> I have a remote user to sending records every 5 minutes by DTS package.
> I think the best way to handle this is to create a job that will up the
> database
> into single user mode, set the remote user to the single user.
> allow the job to run 10 to 15 minutes then take it out of single user
> mode.
>
> Task Break down:
> 1:
> Put the database into single user mode.
> assign myself as the user.
> (How do I define which user has access?)
> 2:
> Backup the database
> unassign myself as the single user
> assign remote user as the single user
> 3:
> Scheduled the job to execute for 15 minutes
> 4:
> take database out of single user mode
> 5:
> Schedule job to execute evey 6 hours.
>
>|||Thanks John and SQLGuRu for the interest;
More Background Details:
The remote user has developed an extensive DTS package.
When the transformations have been completed, then the transformed
data is sent to a central server.
For this reason I can not just go get the data.
To ensure the migration is completed without interuption, I need to put the
server into single user mode.
To preserve the data prior to the migration, I need to perform a backup.
My current solution looks like this:
----
Procedure MySolution AS
Alter database Set Single_User
Perform back up of database
perform backup of logs
alter database Set Multi_User
End Procedure
Create Job
Call Procedure Mysolution
Schedule Job 6hrs
----
"TheSQLGuru" wrote:
> What is the justification for this attempt to "lock the database into
> single-user mode for a specific user"'
> --
> TheSQLGuru
> President
> Indicium Resources, Inc.
> "mj" <mj@.discussions.microsoft.com> wrote in message
> news:137E0713-D3ED-4915-95CD-E4CD4D766A57@.microsoft.com...
> >
> > Task Summary:
> > I have a remote user to sending records every 5 minutes by DTS package.
> > I think the best way to handle this is to create a job that will up the
> > database
> > into single user mode, set the remote user to the single user.
> > allow the job to run 10 to 15 minutes then take it out of single user
> > mode.
> >
> >
> > Task Break down:
> >
> > 1:
> > Put the database into single user mode.
> > assign myself as the user.
> > (How do I define which user has access?)
> >
> > 2:
> > Backup the database
> >
> > unassign myself as the single user
> >
> > assign remote user as the single user
> >
> > 3:
> >
> > Scheduled the job to execute for 15 minutes
> >
> > 4:
> > take database out of single user mode
> >
> > 5:
> > Schedule job to execute evey 6 hours.
> >
> >
> >
> >
>
>|||Hi
"mj" wrote:
> Thanks John and SQLGuRu for the interest;
>
> More Background Details:
> The remote user has developed an extensive DTS package.
> When the transformations have been completed, then the transformed
> data is sent to a central server.
> For this reason I can not just go get the data.
> To ensure the migration is completed without interuption, I need to put the
> server into single user mode.
> To preserve the data prior to the migration, I need to perform a backup.
> My current solution looks like this:
> ----
> Procedure MySolution AS
> Alter database Set Single_User
> Perform back up of database
> perform backup of logs
> alter database Set Multi_User
> End Procedure
> Create Job
> Call Procedure Mysolution
> Schedule Job 6hrs
> ----
>
> "TheSQLGuru" wrote:
> > What is the justification for this attempt to "lock the database into
> > single-user mode for a specific user"'
> >
> > --
> > TheSQLGuru
> > President
> > Indicium Resources, Inc.
> >
> > "mj" <mj@.discussions.microsoft.com> wrote in message
> > news:137E0713-D3ED-4915-95CD-E4CD4D766A57@.microsoft.com...
> > >
> > > Task Summary:
> > > I have a remote user to sending records every 5 minutes by DTS package.
> > > I think the best way to handle this is to create a job that will up the
> > > database
> > > into single user mode, set the remote user to the single user.
> > > allow the job to run 10 to 15 minutes then take it out of single user
> > > mode.
> > >
> > >
> > > Task Break down:
> > >
> > > 1:
> > > Put the database into single user mode.
> > > assign myself as the user.
> > > (How do I define which user has access?)
> > >
> > > 2:
> > > Backup the database
> > >
> > > unassign myself as the single user
> > >
> > > assign remote user as the single user
> > >
> > > 3:
> > >
> > > Scheduled the job to execute for 15 minutes
> > >
> > > 4:
> > > take database out of single user mode
> > >
> > > 5:
> > > Schedule job to execute evey 6 hours.
I can only assume that this is not a system with users, as a period of
unavailability every 6 hours is not the sort of service level that would be
classed as acceptable!!
Who do you need to load this every 6 hours?
Have you considered replication?
If you have a proper sequence of log backups you may not need to do the full
backup if you accept that you will need to restore the last full backup and
roll forward to return to the state prior to your process running.
Alternatively a differential backup would remove the need to restore some of
the log backups.
If you set the database into single user mode, then you can not guarantee
getting access to the database (for that single user) in subsequent job steps.
What do you do with the files that the process has transferred?
John