Showing posts with label run. Show all posts
Showing posts with label run. Show all posts

Wednesday, March 28, 2012

How to show duplicate rows in Report Builder ?

Hi!
I've created a report in Report Builder, based on a query. When I run the report in Report Builder, it doesn't show the duplicates rows, even if it works fine in Data source view.

How can I see al rows in Report Builder(even if they're duplicates) ?

Thank you in advance.

Best regards,
VV
Report Builder shows groups of data, if the data you gropued does not contain a unique column, the data will be grouped, if you want to display all rows, you will need to display column which is different in the mutli-instanced rows.

Jens K. Suessmeyer.

http://www.sqlserver2005.de

Monday, March 19, 2012

How to set up a regular job which will put the quesry result into file and email

Dear forum people,

I created a query which suppose to run every 2 weeks. I know how to schedule a job, my question is how to get the query result into a text or excel file.
If I need to use DTS package, please give me a step by step explanation how to move the result into text file and how to email this file.

I am appreciate every answer.

Thank you.

Annyou can do this whole thing with SQLMail.|||Thrasymachus,
please explain me how can I use SQLMail. Please do not get angry with me as I am not sql person, I just create some queries and know how to use some other things from SQL Enterprise Management.
Thank you.|||I do not get angry but I do not repeat readily available information. So, if you go to Start-->Programs-->Microsoft SQL Server-->SQL Server books Online-->Contents-->Admnistering SQL Server-->Managing Servers-->SQL Mail you can read all about this.

If you want to see examples type xp_sendmail in http://www.google.com/codesearch/advanced_code_search.

Monday, March 12, 2012

How to set SQL Server 2000 send an alert message if any of jobs fails or completes success

Hi!
I have several jobs scheduled to run every evening. Is there a way to
set SQL Server 2000 send an alert message if any of jobs fails or
completes successfully?"Zaur Bahramov" <zaur.bahramov@.mondialgroup.it> wrote in message
news:eGKQs4sqIHA.552@.TK2MSFTNGP06.phx.gbl...
> Hi!
> I have several jobs scheduled to run every evening. Is there a way to set
> SQL Server 2000 send an alert message if any of jobs fails or completes
> successfully?
>
For each job, you can send a notification. It must be configured in the
job.
The notification can be sent for On Success, On Failure or On Completion.
You would have to set this up for each job individually.
If you are looking for a more centralized management scenario, you would
probably have to code it.
Without thinking about it too much, I would probably create a new job that
is scheduled to run AFTER the other jobs should have completed.
I would use TSQL code to read the msdb database's jobs tables (sysjobhistory
IIRC) to determine the status of the jobs in question, put together the
email
and then send the email out.
Rick Sawtell|||Zaur
Create a job with three steps. First one is doing what you have defined
and goes to the second step if it failed. (Second step sends you email that
Job failed)
, if it succeded gooes to the third step (Second step sends you email that
Job succeded)
"Zaur Bahramov" <zaur.bahramov@.mondialgroup.it> wrote in message
news:eGKQs4sqIHA.552@.TK2MSFTNGP06.phx.gbl...
> Hi!
> I have several jobs scheduled to run every evening. Is there a way to set
> SQL Server 2000 send an alert message if any of jobs fails or completes
> successfully?
>

How to set SQL Job continuously run

Hello,
I want to set up one SQL job to continuously run with
minimum break. In another word, the second run of the SQL
Job will start as soon as the first run is completed. Is
there any way to do it?
Thanks a lot,
LixinChange the job step properties, so that when the step completes, it runs it
self again, instead of completing successfully.
--
Denny Cherry
DBA
GameSpy Industries
"Lixin Fan" <lixinf@.mailcode.com> wrote in message
news:299801c386ce$22c337f0$a001280a@.phx.gbl...
> Hello,
> I want to set up one SQL job to continuously run with
> minimum break. In another word, the second run of the SQL
> Job will start as soon as the first run is completed. Is
> there any way to do it?
> Thanks a lot,
> Lixin|||Denny,
Thank you very much.
Since the Job becomes an endless process, do you think
this will cause some potential issues?
Lixin
>--Original Message--
>Change the job step properties, so that when the step
completes, it runs it
>self again, instead of completing successfully.
>--
>Denny Cherry
>DBA
>GameSpy Industries
>"Lixin Fan" <lixinf@.mailcode.com> wrote in message
>news:299801c386ce$22c337f0$a001280a@.phx.gbl...
>> Hello,
>> I want to set up one SQL job to continuously run with
>> minimum break. In another word, the second run of the
SQL
>> Job will start as soon as the first run is completed. Is
>> there any way to do it?
>> Thanks a lot,
>> Lixin
>
>.
>|||It "shouldn't". I've run a job in an endless loop before. I would be an
escape clause in there every day, or every hour so that it exits, and writes
the job history to disk. You can use sp_stop_job to stop the job in it's
tracks. Something like
if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
exec sp_Stop_Job 'JobName'
If you wanted to escape every hour then remove the "datepart(hh, getdate())
= 0 and " from the if statement. Besure to schedule the job to start every
minute of every day, so that when it stops it will automatically restart.
--
Denny Cherry
DBA
GameSpy Industries
"Lixin Fan" <lixinf@.mailcode.com> wrote in message
news:18e9901c386db$09351760$a601280a@.phx.gbl...
> Denny,
> Thank you very much.
> Since the Job becomes an endless process, do you think
> this will cause some potential issues?
> Lixin
> >--Original Message--
> >Change the job step properties, so that when the step
> completes, it runs it
> >self again, instead of completing successfully.
> >
> >--
> >Denny Cherry
> >DBA
> >GameSpy Industries
> >"Lixin Fan" <lixinf@.mailcode.com> wrote in message
> >news:299801c386ce$22c337f0$a001280a@.phx.gbl...
> >> Hello,
> >>
> >> I want to set up one SQL job to continuously run with
> >> minimum break. In another word, the second run of the
> SQL
> >> Job will start as soon as the first run is completed. Is
> >> there any way to do it?
> >>
> >> Thanks a lot,
> >> Lixin
> >
> >
> >.
> >|||> if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> exec sp_Stop_Job 'JobName'
This may not guarantee that sp_stop_job will always run because the
currently running job may not stop before 00:00. It's safer to do a time
range check.
Another mehtod to run a job repeatly, especially if you don't need the loop
to be very tight, is to schedule the job to start every minute (or any other
time unit). In the job, using an apllication lock to detect whether the job
is still running. Exit immediately if it is.
--
Linchi Shea
linchi_shea@.NOSPAMml.com
"Denny" <mrdenny@.gamespy.com> wrote in message
news:eKtYe4uhDHA.2448@.TK2MSFTNGP12.phx.gbl...
> It "shouldn't". I've run a job in an endless loop before. I would be an
> escape clause in there every day, or every hour so that it exits, and
writes
> the job history to disk. You can use sp_stop_job to stop the job in it's
> tracks. Something like
> if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> exec sp_Stop_Job 'JobName'
> If you wanted to escape every hour then remove the "datepart(hh,
getdate())
> = 0 and " from the if statement. Besure to schedule the job to start
every
> minute of every day, so that when it stops it will automatically restart.
> --
> Denny Cherry
> DBA
> GameSpy Industries
> "Lixin Fan" <lixinf@.mailcode.com> wrote in message
> news:18e9901c386db$09351760$a601280a@.phx.gbl...
> > Denny,
> >
> > Thank you very much.
> >
> > Since the Job becomes an endless process, do you think
> > this will cause some potential issues?
> >
> > Lixin
> >
> > >--Original Message--
> > >Change the job step properties, so that when the step
> > completes, it runs it
> > >self again, instead of completing successfully.
> > >
> > >--
> > >Denny Cherry
> > >DBA
> > >GameSpy Industries
> > >"Lixin Fan" <lixinf@.mailcode.com> wrote in message
> > >news:299801c386ce$22c337f0$a001280a@.phx.gbl...
> > >> Hello,
> > >>
> > >> I want to set up one SQL job to continuously run with
> > >> minimum break. In another word, the second run of the
> > SQL
> > >> Job will start as soon as the first run is completed. Is
> > >> there any way to do it?
> > >>
> > >> Thanks a lot,
> > >> Lixin
> > >
> > >
> > >.
> > >
>|||> Another mehtod to run a job repeatly, especially if you don't need the loop
> to be very tight, is to schedule the job to start every minute (or any other
> time unit). In the job, using an apllication lock to detect whether the job
> is still running. Exit immediately if it is.
Is that necessary? As far as I understand, Agent will not start a job if it is already running.
Yet another option is to start the job at agent startup and use a loop with in the job (assuming one
TSQL jobstep). The loop is using a simple WAITFOR construct.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"Linchi Shea" <linchi_shea@.NOSPAMml.com> wrote in message
news:u1ENtQwhDHA.3276@.tk2msftngp13.phx.gbl...
> > if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> > exec sp_Stop_Job 'JobName'
> This may not guarantee that sp_stop_job will always run because the
> currently running job may not stop before 00:00. It's safer to do a time
> range check.
> Another mehtod to run a job repeatly, especially if you don't need the loop
> to be very tight, is to schedule the job to start every minute (or any other
> time unit). In the job, using an apllication lock to detect whether the job
> is still running. Exit immediately if it is.
> --
> Linchi Shea
> linchi_shea@.NOSPAMml.com
>
> "Denny" <mrdenny@.gamespy.com> wrote in message
> news:eKtYe4uhDHA.2448@.TK2MSFTNGP12.phx.gbl...
> > It "shouldn't". I've run a job in an endless loop before. I would be an
> > escape clause in there every day, or every hour so that it exits, and
> writes
> > the job history to disk. You can use sp_stop_job to stop the job in it's
> > tracks. Something like
> > if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> > exec sp_Stop_Job 'JobName'
> >
> > If you wanted to escape every hour then remove the "datepart(hh,
> getdate())
> > = 0 and " from the if statement. Besure to schedule the job to start
> every
> > minute of every day, so that when it stops it will automatically restart.
> >
> > --
> > Denny Cherry
> > DBA
> > GameSpy Industries
> > "Lixin Fan" <lixinf@.mailcode.com> wrote in message
> > news:18e9901c386db$09351760$a601280a@.phx.gbl...
> > > Denny,
> > >
> > > Thank you very much.
> > >
> > > Since the Job becomes an endless process, do you think
> > > this will cause some potential issues?
> > >
> > > Lixin
> > >
> > > >--Original Message--
> > > >Change the job step properties, so that when the step
> > > completes, it runs it
> > > >self again, instead of completing successfully.
> > > >
> > > >--
> > > >Denny Cherry
> > > >DBA
> > > >GameSpy Industries
> > > >"Lixin Fan" <lixinf@.mailcode.com> wrote in message
> > > >news:299801c386ce$22c337f0$a001280a@.phx.gbl...
> > > >> Hello,
> > > >>
> > > >> I want to set up one SQL job to continuously run with
> > > >> minimum break. In another word, the second run of the
> > > SQL
> > > >> Job will start as soon as the first run is completed. Is
> > > >> there any way to do it?
> > > >>
> > > >> Thanks a lot,
> > > >> Lixin
> > > >
> > > >
> > > >.
> > > >
> >
> >
>|||You're right, Tibor, it's not necessary if you use SQL Server Agent to
schedule the job, which what we are talking about here. Just a habit of
wanting to take the concurrency matter into my own hands -:)
Linchi Shea
linchi_shea@.NOSPAMml.com
"Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
wrote in message news:ubSCczxhDHA.2496@.tk2msftngp13.phx.gbl...
> > Another mehtod to run a job repeatly, especially if you don't need the
loop
> > to be very tight, is to schedule the job to start every minute (or any
other
> > time unit). In the job, using an apllication lock to detect whether the
job
> > is still running. Exit immediately if it is.
> Is that necessary? As far as I understand, Agent will not start a job if
it is already running.
> Yet another option is to start the job at agent startup and use a loop
with in the job (assuming one
> TSQL jobstep). The loop is using a simple WAITFOR construct.
> --
> Tibor Karaszi, SQL Server MVP
> Archive at: http://groups.google.com/groups?oi=djq&as
ugroup=microsoft.public.sqlserver
>
> "Linchi Shea" <linchi_shea@.NOSPAMml.com> wrote in message
> news:u1ENtQwhDHA.3276@.tk2msftngp13.phx.gbl...
> > > if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> > > exec sp_Stop_Job 'JobName'
> >
> > This may not guarantee that sp_stop_job will always run because the
> > currently running job may not stop before 00:00. It's safer to do a time
> > range check.
> >
> > Another mehtod to run a job repeatly, especially if you don't need the
loop
> > to be very tight, is to schedule the job to start every minute (or any
other
> > time unit). In the job, using an apllication lock to detect whether the
job
> > is still running. Exit immediately if it is.
> >
> > --
> > Linchi Shea
> > linchi_shea@.NOSPAMml.com
> >
> >
> > "Denny" <mrdenny@.gamespy.com> wrote in message
> > news:eKtYe4uhDHA.2448@.TK2MSFTNGP12.phx.gbl...
> > > It "shouldn't". I've run a job in an endless loop before. I would be
an
> > > escape clause in there every day, or every hour so that it exits, and
> > writes
> > > the job history to disk. You can use sp_stop_job to stop the job in
it's
> > > tracks. Something like
> > > if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> > > exec sp_Stop_Job 'JobName'
> > >
> > > If you wanted to escape every hour then remove the "datepart(hh,
> > getdate())
> > > = 0 and " from the if statement. Besure to schedule the job to start
> > every
> > > minute of every day, so that when it stops it will automatically
restart.
> > >
> > > --
> > > Denny Cherry
> > > DBA
> > > GameSpy Industries
> > > "Lixin Fan" <lixinf@.mailcode.com> wrote in message
> > > news:18e9901c386db$09351760$a601280a@.phx.gbl...
> > > > Denny,
> > > >
> > > > Thank you very much.
> > > >
> > > > Since the Job becomes an endless process, do you think
> > > > this will cause some potential issues?
> > > >
> > > > Lixin
> > > >
> > > > >--Original Message--
> > > > >Change the job step properties, so that when the step
> > > > completes, it runs it
> > > > >self again, instead of completing successfully.
> > > > >
> > > > >--
> > > > >Denny Cherry
> > > > >DBA
> > > > >GameSpy Industries
> > > > >"Lixin Fan" <lixinf@.mailcode.com> wrote in message
> > > > >news:299801c386ce$22c337f0$a001280a@.phx.gbl...
> > > > >> Hello,
> > > > >>
> > > > >> I want to set up one SQL job to continuously run with
> > > > >> minimum break. In another word, the second run of the
> > > > SQL
> > > > >> Job will start as soon as the first run is completed. Is
> > > > >> there any way to do it?
> > > > >>
> > > > >> Thanks a lot,
> > > > >> Lixin
> > > > >
> > > > >
> > > > >.
> > > > >
> > >
> > >
> >
> >
>|||> Just a habit of
> wanting to take the concurrency matter into my own hands -:)
And a good habit it is. I wonder whether I should say that I found out the behavior by... chance...?
:-)
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"Linchi Shea" <linchi_shea@.NOSPAMml.com> wrote in message
news:el$YUr0hDHA.3204@.TK2MSFTNGP11.phx.gbl...
> You're right, Tibor, it's not necessary if you use SQL Server Agent to
> schedule the job, which what we are talking about here. Just a habit of
> wanting to take the concurrency matter into my own hands -:)
> Linchi Shea
> linchi_shea@.NOSPAMml.com
>
> "Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
> wrote in message news:ubSCczxhDHA.2496@.tk2msftngp13.phx.gbl...
> > > Another mehtod to run a job repeatly, especially if you don't need the
> loop
> > > to be very tight, is to schedule the job to start every minute (or any
> other
> > > time unit). In the job, using an apllication lock to detect whether the
> job
> > > is still running. Exit immediately if it is.
> >
> > Is that necessary? As far as I understand, Agent will not start a job if
> it is already running.
> > Yet another option is to start the job at agent startup and use a loop
> with in the job (assuming one
> > TSQL jobstep). The loop is using a simple WAITFOR construct.
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > Archive at: http://groups.google.com/groups?oi=djq&as
> ugroup=microsoft.public.sqlserver
> >
> >
> > "Linchi Shea" <linchi_shea@.NOSPAMml.com> wrote in message
> > news:u1ENtQwhDHA.3276@.tk2msftngp13.phx.gbl...
> > > > if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> > > > exec sp_Stop_Job 'JobName'
> > >
> > > This may not guarantee that sp_stop_job will always run because the
> > > currently running job may not stop before 00:00. It's safer to do a time
> > > range check.
> > >
> > > Another mehtod to run a job repeatly, especially if you don't need the
> loop
> > > to be very tight, is to schedule the job to start every minute (or any
> other
> > > time unit). In the job, using an apllication lock to detect whether the
> job
> > > is still running. Exit immediately if it is.
> > >
> > > --
> > > Linchi Shea
> > > linchi_shea@.NOSPAMml.com
> > >
> > >
> > > "Denny" <mrdenny@.gamespy.com> wrote in message
> > > news:eKtYe4uhDHA.2448@.TK2MSFTNGP12.phx.gbl...
> > > > It "shouldn't". I've run a job in an endless loop before. I would be
> an
> > > > escape clause in there every day, or every hour so that it exits, and
> > > writes
> > > > the job history to disk. You can use sp_stop_job to stop the job in
> it's
> > > > tracks. Something like
> > > > if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> > > > exec sp_Stop_Job 'JobName'
> > > >
> > > > If you wanted to escape every hour then remove the "datepart(hh,
> > > getdate())
> > > > = 0 and " from the if statement. Besure to schedule the job to start
> > > every
> > > > minute of every day, so that when it stops it will automatically
> restart.
> > > >
> > > > --
> > > > Denny Cherry
> > > > DBA
> > > > GameSpy Industries
> > > > "Lixin Fan" <lixinf@.mailcode.com> wrote in message
> > > > news:18e9901c386db$09351760$a601280a@.phx.gbl...
> > > > > Denny,
> > > > >
> > > > > Thank you very much.
> > > > >
> > > > > Since the Job becomes an endless process, do you think
> > > > > this will cause some potential issues?
> > > > >
> > > > > Lixin
> > > > >
> > > > > >--Original Message--
> > > > > >Change the job step properties, so that when the step
> > > > > completes, it runs it
> > > > > >self again, instead of completing successfully.
> > > > > >
> > > > > >--
> > > > > >Denny Cherry
> > > > > >DBA
> > > > > >GameSpy Industries
> > > > > >"Lixin Fan" <lixinf@.mailcode.com> wrote in message
> > > > > >news:299801c386ce$22c337f0$a001280a@.phx.gbl...
> > > > > >> Hello,
> > > > > >>
> > > > > >> I want to set up one SQL job to continuously run with
> > > > > >> minimum break. In another word, the second run of the
> > > > > SQL
> > > > > >> Job will start as soon as the first run is completed. Is
> > > > > >> there any way to do it?
> > > > > >>
> > > > > >> Thanks a lot,
> > > > > >> Lixin
> > > > > >
> > > > > >
> > > > > >.
> > > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>|||>--Original Message--
>It "shouldn't". I've run a job in an endless loop
before. I would be an
>escape clause in there every day, or every hour so that
it exits, and writes
>the job history to disk.
Can you explain why the Job must exit to write history
into disk?
The Job I use has 16 steps. I set up the last step goes
back to the first step when the last step succeeds. I can
view the Job history for each step in EM and
msdb..syshistory table while the Job is endlessly running.
Do you mean that the job history is still only in the
memory instead of disk until I stop the Job?
Thanks,
Lixin|||Yes, you can view each step as that step completes. I've just notices that
if you keep a job running non-stop for a few days, the server can start to
get annoyed with you. Stopping the job every once and a while seams to keep
it from getting to upset.
--
Denny Cherry
DBA
GameSpy Industries
"Lixin Fan" <lixinf@.mailcode.com> wrote in message
news:00a101c3875f$829d5de0$a101280a@.phx.gbl...
> >--Original Message--
> >It "shouldn't". I've run a job in an endless loop
> before. I would be an
> >escape clause in there every day, or every hour so that
> it exits, and writes
> >the job history to disk.
> Can you explain why the Job must exit to write history
> into disk?
> The Job I use has 16 steps. I set up the last step goes
> back to the first step when the last step succeeds. I can
> view the Job history for each step in EM and
> msdb..syshistory table while the Job is endlessly running.
> Do you mean that the job history is still only in the
> memory instead of disk until I stop the Job?
> Thanks,
> Lixin
>
>

Wednesday, March 7, 2012

How to set default SQL Timeout

I have an app that uses ADO connections, and when I run a particular
operation I get a SQL Timeout, but when I run the same operation with the
same executable on another client I don't get a timeout. A Profiler trace
confirms that the first query times out after 30 seconds (the default), and
the second client succeeds after about 40 seconds. Both clients are running
the same MDAC version.
I thought that the query timeout is set in the ADO command object, but this
behavior leads me to think otherwise. Is there a way to set the default
timeout value on a client?
Thanks,
Tom
Well, I've partially explained my own problem. The client that isn't timing
out is running on the server using the shared memory protocol LPC. When I
disable that and force the connection to use TCP/IP or named pipes, then I
get the SQL Timeout. So now my question is why is there a different timeout
value for TCP/IP and named pipe connections than there is for shared memory
connections?
Tom
"Tom" wrote:

> I have an app that uses ADO connections, and when I run a particular
> operation I get a SQL Timeout, but when I run the same operation with the
> same executable on another client I don't get a timeout. A Profiler trace
> confirms that the first query times out after 30 seconds (the default), and
> the second client succeeds after about 40 seconds. Both clients are running
> the same MDAC version.
> I thought that the query timeout is set in the ADO command object, but this
> behavior leads me to think otherwise. Is there a way to set the default
> timeout value on a client?
> Thanks,
> Tom

How to set default SQL Timeout

I have an app that uses ADO connections, and when I run a particular
operation I get a SQL Timeout, but when I run the same operation with the
same executable on another client I don't get a timeout. A Profiler trace
confirms that the first query times out after 30 seconds (the default), and
the second client succeeds after about 40 seconds. Both clients are running
the same MDAC version.
I thought that the query timeout is set in the ADO command object, but this
behavior leads me to think otherwise. Is there a way to set the default
timeout value on a client?
Thanks,
TomWell, I've partially explained my own problem. The client that isn't timing
out is running on the server using the shared memory protocol LPC. When I
disable that and force the connection to use TCP/IP or named pipes, then I
get the SQL Timeout. So now my question is why is there a different timeout
value for TCP/IP and named pipe connections than there is for shared memory
connections?
Tom
"Tom" wrote:

> I have an app that uses ADO connections, and when I run a particular
> operation I get a SQL Timeout, but when I run the same operation with the
> same executable on another client I don't get a timeout. A Profiler trace
> confirms that the first query times out after 30 seconds (the default), an
d
> the second client succeeds after about 40 seconds. Both clients are runni
ng
> the same MDAC version.
> I thought that the query timeout is set in the ADO command object, but thi
s
> behavior leads me to think otherwise. Is there a way to set the default
> timeout value on a client?
> Thanks,
> Tom

How to set default SQL Timeout

I have an app that uses ADO connections, and when I run a particular
operation I get a SQL Timeout, but when I run the same operation with the
same executable on another client I don't get a timeout. A Profiler trace
confirms that the first query times out after 30 seconds (the default), and
the second client succeeds after about 40 seconds. Both clients are running
the same MDAC version.
I thought that the query timeout is set in the ADO command object, but this
behavior leads me to think otherwise. Is there a way to set the default
timeout value on a client?
Thanks,
TomWell, I've partially explained my own problem. The client that isn't timing
out is running on the server using the shared memory protocol LPC. When I
disable that and force the connection to use TCP/IP or named pipes, then I
get the SQL Timeout. So now my question is why is there a different timeout
value for TCP/IP and named pipe connections than there is for shared memory
connections?
Tom
"Tom" wrote:
> I have an app that uses ADO connections, and when I run a particular
> operation I get a SQL Timeout, but when I run the same operation with the
> same executable on another client I don't get a timeout. A Profiler trace
> confirms that the first query times out after 30 seconds (the default), and
> the second client succeeds after about 40 seconds. Both clients are running
> the same MDAC version.
> I thought that the query timeout is set in the ADO command object, but this
> behavior leads me to think otherwise. Is there a way to set the default
> timeout value on a client?
> Thanks,
> Tom

Friday, February 24, 2012

How to set a SP run at mid-night ?

(1)I need to insert the data from vfp into sql every mid-night .
I think I can use SP to process the inset statment .
However, How can I set it run at mid-night automically 'Take a look at sql job:
http://msdn.microsoft.com/library/e...tomate_7awj.asp
-oj
"Agnes" <agnes@.dynamictech.com.hk> wrote in message
news:%23evjgqtSFHA.3312@.TK2MSFTNGP12.phx.gbl...
> (1)I need to insert the data from vfp into sql every mid-night .
> I think I can use SP to process the inset statment .
> However, How can I set it run at mid-night automically '
>
>|||SQLAgent ?
Gopi
"Agnes" <agnes@.dynamictech.com.hk> wrote in message
news:%23evjgqtSFHA.3312@.TK2MSFTNGP12.phx.gbl...
> (1)I need to insert the data from vfp into sql every mid-night .
> I think I can use SP to process the inset statment .
> However, How can I set it run at mid-night automically '
>
>

how to set a schedule to run codes like

backup log <dbname> with truncate_only
thanks
benExpand SQL Server Agent, create a new job, add a job step with that code. However, the question is
why you want to execute that command regularly? If you don't do log backup, set the database to
simple recovery model.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<libin918@.gmail.com> wrote in message news:1149613568.316745.80160@.g10g2000cwb.googlegroups.com...
> backup log <dbname> with truncate_only
> thanks
> ben
>|||Thanks Tibor.
Yes. we can setup to simple model. But the thing is we want a full
model and meanwhile we dont want them to grow up too big. it doesnt
make a sense? :)
Thanks again
Tibor Karaszi wrote:
> Expand SQL Server Agent, create a new job, add a job step with that code. However, the question is
> why you want to execute that command regularly? If you don't do log backup, set the database to
> simple recovery model.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> <libin918@.gmail.com> wrote in message news:1149613568.316745.80160@.g10g2000cwb.googlegroups.com...
> > backup log <dbname> with truncate_only
> >
> > thanks
> >
> > ben
> >|||If you are in full model, then the log is emptied every time you backup the transaction log. So
adding backup log with truncate_only will not add anything to that backup strategy, it will only
break the log backup sequence. Are you doing regular log backups? How often?
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<libin918@.gmail.com> wrote in message news:1149686820.193242.3960@.y43g2000cwc.googlegroups.com...
> Thanks Tibor.
> Yes. we can setup to simple model. But the thing is we want a full
> model and meanwhile we dont want them to grow up too big. it doesnt
> make a sense? :)
> Thanks again
> Tibor Karaszi wrote:
>> Expand SQL Server Agent, create a new job, add a job step with that code. However, the question
>> is
>> why you want to execute that command regularly? If you don't do log backup, set the database to
>> simple recovery model.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> <libin918@.gmail.com> wrote in message
>> news:1149613568.316745.80160@.g10g2000cwb.googlegroups.com...
>> > backup log <dbname> with truncate_only
>> >
>> > thanks
>> >
>> > ben
>> >
>

how to set a schedule to run codes like

backup log <dbname> with truncate_only
thanks
benExpand SQL Server Agent, create a new job, add a job step with that code. Ho
wever, the question is
why you want to execute that command regularly? If you don't do log backup,
set the database to
simple recovery model.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<libin918@.gmail.com> wrote in message news:1149613568.316745.80160@.g10g2000cwb.googlegroups.
com...
> backup log <dbname> with truncate_only
> thanks
> ben
>

Sunday, February 19, 2012

how to send sql mail using condition statement

I try to run the following code in DTS, but i not work. What i want is
if do not have duplicate data, then the table will be dropped. While
if have duplicate data, the table will not be dropped but an email
notification will be sent. Why when there is no duplicate data, the
email still will be sent out?
if not exists(select catalog_code, count(catalog_code) from rd_awards
group
by catalog_code having
count(catalog_code) > 1)
begin
drop table [dbo].[Rewards_CatalogProducts_CS]
end
else
if exists(select catalog_code, count(catalog_code) from rd_awards
group
by catalog_code having
count(catalog_code) > 1)
use master
go
declare @.FROM NVARCHAR(4000),
@.FROM_NAME NVARCHAR(4000),
@.TO NVARCHAR(4000),
@.CC NVARCHAR(4000),
@.BCC NVARCHAR(4000),
@.priority NVARCHAR(10),
@.subject NVARCHAR(4000),
@.message NVARCHAR(4000),
@.type NVARCHAR(100),
@.attachments NVARCHAR(4000),
@.codepage INT,
@.rc INT
select @.FROM = N'sqlmail@.cyber-village.net',
@.FROM_NAME = N'ChangMian',
@.TO = N'tchangmian@.yahoo.com.sg',
@.CC = N'changmian@.cyber-village.net',
@.priority = N'High',
@.subject = N'Ei,can wor',
@.message = N'&
Hello SQL Server SMTP SQL
Mail
',
@.type = N'text/html',
@.attachments = N'',
@.codepage = 0
exec @.rc = master.dbo.xp_smtp_sendmail
@.FROM = @.FROM,
@.TO = @.TO,
@.CC = @.CC,
@.priority = @.priority,
@.subject = @.subject,
@.message = @.message,
@.type = @.type,
@.attachments = @.attachments,
@.codepage = @.codepage,
@.server = N'mail.cyber-village.net'
select RC = @.rc
goYour send mail script is in a different batch because of the 'GO' batch
terminator. Consider revising your script like the example below:
declare @.FROM NVARCHAR(4000),
@.FROM_NAME NVARCHAR(4000),
@.TO NVARCHAR(4000),
@.CC NVARCHAR(4000),
@.BCC NVARCHAR(4000),
@.priority NVARCHAR(10),
@.subject NVARCHAR(4000),
@.message NVARCHAR(4000),
@.type NVARCHAR(100),
@.attachments NVARCHAR(4000),
@.codepage INT,
@.rc INT
if not exists(select catalog_code, count(catalog_code) from rd_awards
group
by catalog_code having
count(catalog_code) > 1)
begin
drop table [dbo].[Rewards_CatalogProducts_CS]
end
else
begin
select @.FROM = N'sqlmail@.cyber-village.net',
@.FROM_NAME = N'ChangMian',
@.TO = N'tchangmian@.yahoo.com.sg',
@.CC = N'changmian@.cyber-village.net',
@.priority = N'High',
@.subject = N'Ei,can wor',
@.message = N'&
Hello SQL Server SMTP SQL
Mail
',
@.type = N'text/html',
@.attachments = N'',
@.codepage = 0
exec @.rc = master.dbo.xp_smtp_sendmail
@.FROM = @.FROM,
@.TO = @.TO,
@.CC = @.CC,
@.priority = @.priority,
@.subject = @.subject,
@.message = @.message,
@.type = @.type,
@.attachments = @.attachments,
@.codepage = @.codepage,
@.server = N'mail.cyber-village.net'
select RC = @.rc
end
go
--
Hope this helps.
Dan Guzman
SQL Server MVP
"tchangmian" <tchangmian@.yahoo.com.sg> wrote in message
news:6447ee25.0410042022.52f52ac5@.posting.google.com...
>I try to run the following code in DTS, but i not work. What i want is
> if do not have duplicate data, then the table will be dropped. While
> if have duplicate data, the table will not be dropped but an email
> notification will be sent. Why when there is no duplicate data, the
> email still will be sent out?
>
> if not exists(select catalog_code, count(catalog_code) from rd_awards
> group
> by catalog_code having
> count(catalog_code) > 1)
> begin
> drop table [dbo].[Rewards_CatalogProducts_CS]
> end
>
> else
> if exists(select catalog_code, count(catalog_code) from rd_awards
> group
> by catalog_code having
> count(catalog_code) > 1)
>
> use master
> go
> declare @.FROM NVARCHAR(4000),
> @.FROM_NAME NVARCHAR(4000),
> @.TO NVARCHAR(4000),
> @.CC NVARCHAR(4000),
> @.BCC NVARCHAR(4000),
> @.priority NVARCHAR(10),
> @.subject NVARCHAR(4000),
> @.message NVARCHAR(4000),
> @.type NVARCHAR(100),
> @.attachments NVARCHAR(4000),
> @.codepage INT,
> @.rc INT
> select @.FROM = N'sqlmail@.cyber-village.net',
> @.FROM_NAME = N'ChangMian',
> @.TO = N'tchangmian@.yahoo.com.sg',
> @.CC = N'changmian@.cyber-village.net',
> @.priority = N'High',
> @.subject = N'Ei,can wor',
> @.message = N'<HTML><H1>Hello SQL Server SMTP SQL
> Mail</H1></HTML>',
> @.type = N'text/html',
> @.attachments = N'',
> @.codepage = 0
> exec @.rc = master.dbo.xp_smtp_sendmail
> @.FROM = @.FROM,
> @.TO = @.TO,
> @.CC = @.CC,
> @.priority = @.priority,
> @.subject = @.subject,
> @.message = @.message,
> @.type = @.type,
> @.attachments = @.attachments,
> @.codepage = @.codepage,
> @.server = N'mail.cyber-village.net'
> select RC = @.rc
> go

how to send sql mail using condition statement

I try to run the following code in DTS, but i not work. What i want is
if do not have duplicate data, then the table will be dropped. While
if have duplicate data, the table will not be dropped but an email
notification will be sent. Why when there is no duplicate data, the
email still will be sent out?
if not exists(select catalog_code, count(catalog_code) from rd_awards
group
by catalog_code having
count(catalog_code) > 1)
begin
drop table [dbo].[Rewards_CatalogProducts_CS]
end
else
if exists(select catalog_code, count(catalog_code) from rd_awards
group
by catalog_code having
count(catalog_code) > 1)
use master
go
declare @.FROM NVARCHAR(4000),
@.FROM_NAME NVARCHAR(4000),
@.TO NVARCHAR(4000),
@.CC NVARCHAR(4000),
@.BCC NVARCHAR(4000),
@.priority NVARCHAR(10),
@.subject NVARCHAR(4000),
@.message NVARCHAR(4000),
@.type NVARCHAR(100),
@.attachments NVARCHAR(4000),
@.codepage INT,
@.rc INT
select @.FROM = N'sqlmail@.cyber-village.net',
@.FROM_NAME = N'ChangMian',
@.TO = N'tchangmian@.yahoo.com.sg',
@.CC = N'changmian@.cyber-village.net',
@.priority = N'High',
@.subject = N'Ei,can wor',
@.message = N'<HTML><H1>Hello SQL Server SMTP SQL
Mail</H1></HTML>',
@.type = N'text/html',
@.attachments = N'',
@.codepage = 0
exec @.rc = master.dbo.xp_smtp_sendmail
@.FROM = @.FROM,
@.TO = @.TO,
@.CC = @.CC,
@.priority = @.priority,
@.subject = @.subject,
@.message = @.message,
@.type = @.type,
@.attachments = @.attachments,
@.codepage = @.codepage,
@.server = N'mail.cyber-village.net'
select RC = @.rc
go
Your send mail script is in a different batch because of the 'GO' batch
terminator. Consider revising your script like the example below:
declare @.FROM NVARCHAR(4000),
@.FROM_NAME NVARCHAR(4000),
@.TO NVARCHAR(4000),
@.CC NVARCHAR(4000),
@.BCC NVARCHAR(4000),
@.priority NVARCHAR(10),
@.subject NVARCHAR(4000),
@.message NVARCHAR(4000),
@.type NVARCHAR(100),
@.attachments NVARCHAR(4000),
@.codepage INT,
@.rc INT
if not exists(select catalog_code, count(catalog_code) from rd_awards
group
by catalog_code having
count(catalog_code) > 1)
begin
drop table [dbo].[Rewards_CatalogProducts_CS]
end
else
begin
select @.FROM = N'sqlmail@.cyber-village.net',
@.FROM_NAME = N'ChangMian',
@.TO = N'tchangmian@.yahoo.com.sg',
@.CC = N'changmian@.cyber-village.net',
@.priority = N'High',
@.subject = N'Ei,can wor',
@.message = N'<HTML><H1>Hello SQL Server SMTP SQL
Mail</H1></HTML>',
@.type = N'text/html',
@.attachments = N'',
@.codepage = 0
exec @.rc = master.dbo.xp_smtp_sendmail
@.FROM = @.FROM,
@.TO = @.TO,
@.CC = @.CC,
@.priority = @.priority,
@.subject = @.subject,
@.message = @.message,
@.type = @.type,
@.attachments = @.attachments,
@.codepage = @.codepage,
@.server = N'mail.cyber-village.net'
select RC = @.rc
end
go
Hope this helps.
Dan Guzman
SQL Server MVP
"tchangmian" <tchangmian@.yahoo.com.sg> wrote in message
news:6447ee25.0410042022.52f52ac5@.posting.google.c om...
>I try to run the following code in DTS, but i not work. What i want is
> if do not have duplicate data, then the table will be dropped. While
> if have duplicate data, the table will not be dropped but an email
> notification will be sent. Why when there is no duplicate data, the
> email still will be sent out?
>
> if not exists(select catalog_code, count(catalog_code) from rd_awards
> group
> by catalog_code having
> count(catalog_code) > 1)
> begin
> drop table [dbo].[Rewards_CatalogProducts_CS]
> end
>
> else
> if exists(select catalog_code, count(catalog_code) from rd_awards
> group
> by catalog_code having
> count(catalog_code) > 1)
>
> use master
> go
> declare @.FROM NVARCHAR(4000),
> @.FROM_NAME NVARCHAR(4000),
> @.TO NVARCHAR(4000),
> @.CC NVARCHAR(4000),
> @.BCC NVARCHAR(4000),
> @.priority NVARCHAR(10),
> @.subject NVARCHAR(4000),
> @.message NVARCHAR(4000),
> @.type NVARCHAR(100),
> @.attachments NVARCHAR(4000),
> @.codepage INT,
> @.rc INT
> select @.FROM = N'sqlmail@.cyber-village.net',
> @.FROM_NAME = N'ChangMian',
> @.TO = N'tchangmian@.yahoo.com.sg',
> @.CC = N'changmian@.cyber-village.net',
> @.priority = N'High',
> @.subject = N'Ei,can wor',
> @.message = N'<HTML><H1>Hello SQL Server SMTP SQL
> Mail</H1></HTML>',
> @.type = N'text/html',
> @.attachments = N'',
> @.codepage = 0
> exec @.rc = master.dbo.xp_smtp_sendmail
> @.FROM = @.FROM,
> @.TO = @.TO,
> @.CC = @.CC,
> @.priority = @.priority,
> @.subject = @.subject,
> @.message = @.message,
> @.type = @.type,
> @.attachments = @.attachments,
> @.codepage = @.codepage,
> @.server = N'mail.cyber-village.net'
> select RC = @.rc
> go