Showing posts with label checking. Show all posts
Showing posts with label checking. Show all posts

Saturday, February 25, 2012

Checking which tables were modified by a program?

Is it possible to know what tables were modified when running an application
?
I'm working on a program that has several different components, but I'm only
testing one. I would like to see what tables were affected by this one
component (either by updating or inserting data to a table or several tables
).
Thanks.You can use SQL Server Profiler to show all the commands sent to the
database. I would filter the commands at least down to a specific user if
you are running profiler on a multi user system.
"VMI" wrote:

> Is it possible to know what tables were modified when running an applicati
on?
> I'm working on a program that has several different components, but I'm on
ly
> testing one. I would like to see what tables were affected by this one
> component (either by updating or inserting data to a table or several tabl
es).
> Thanks.|||You can also filter by applicationname in profiler. Its part of the selecte4
d
data in the default trace template.
--
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/
"VMI" wrote:

> Is it possible to know what tables were modified when running an applicati
on?
> I'm working on a program that has several different components, but I'm on
ly
> testing one. I would like to see what tables were affected by this one
> component (either by updating or inserting data to a table or several tabl
es).
> Thanks.

Checking whether the table has a column with the specified name

Hi,

I have a table as follows

Table

{

Category1,

Category2,

Category3

}

I wanted to write a query to check whether the column with the name 'Category3' exists in the table.

Can anyone please let me know how to do this

Best Regards and Thanks

~Mohan Babu

2005?

Check out the sys.columns table

|||

Code Snippet

if Exists(

select * from sys.columns where Name = N'Category3'

and Object_ID = Object_ID(N'<TableName>')

)

begin

--some code for column exists condition

end

else

begin

--some code for column does not exist condition

end

|||Hi,

If you are using sql2005 then u can make use of rusag2's querry else if you are using sql2000 the u can make use of the following querry:

Code Snippet

SELECT CASE WHEN ISNULL(COLUMN_NAME ,'')='' THEN 'NO' ELSE 'YES' END
FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME='VoucherSerial' AND TABLE_NAME='Vouchers'


Checking whether an external image exists

Hello,
I have a table containing an image with dynamic content. My dataset gives
me a path to the image, now I can't be sure that the image actually exists
in the file system so I check using File.Exists. This works fine on my development
box but when I deploy it to my production environment, File.Exists returns
false no matter what.
Thinking it might be a security issue I moved the files from the original
fileshare and placed them on the Reporting Services server locally. No effect.
Along those lines I created a small test application which uses the same
File.Exists method. The app is able to verify the files which exist correctly.
I'm at a loss as to what to try out next, so any help is greatly appreciated.
--
Med venlig hilsen,
Søren Lund
www.publicvoid.dkAs is often the case I found a solution shortly after posting this and I
thought I'd share in case some of you comes across something similar.
http://www.publicvoid.dk/NETMethodsRequiringSpecialPermissionsWithinReportingServices.aspx
Med venlig hilsen,
Søren Lund
www.publicvoid.d

checking versions

you can check versions in query analyzer by
select @.@.version
Yes you can.
www.aspfaq.com/2160
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
SQLRebel wrote:
> you can check versions in query analyzer by
> select @.@.version
>

checking versions

you can check versions in query analyzer by
select @.@.versionYes you can.
www.aspfaq.com/2160
--
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
SQLRebel wrote:
> you can check versions in query analyzer by
> select @.@.version
>

Checking values with range parameters

How can i match a value in my query with a parameter that has range e.g:
i want to check where order_date between {?Datapara}
where date parameter is a single field that has range.I have CR XI, can not swear this is supported in earlier releases.
Go to the sample reports and open the Record selection on date range.
look at the select statement and check out the report custom formulas.
You may be able to do this same thing in earlier versions, but I do not know that for certain. Only have CR XI

checking value in 2 tables.

i want to check a value in 2 tables. the 1st table i want to check if the value exists and from the 2ed table i samething.

i came up with this but when it's doing the second if i get error on the page.

Dim ReturnValAsInteger

Dim ReturnVal2AsInteger

Dim connAs SqlConnection =New SqlConnection(ConfigurationManager.ConnectionStrings("imacstestConnectionString").ConnectionString)

Dim cmdAs SqlCommand =New SqlCommand("SELECT [ReportNumber] FROM [AppraisalSummaryBlue] WHERE ([ReportNumber] = @.ReportNumber)", conn)

'To check if the # is registered.

Dim cmd2As SqlCommand =New SqlCommand("SELECT [ReportNumber] FROM [t_RegisterInfoTemp] WHERE ([ReportNumber] = @.ReportNumber)", conn)

cmd.Parameters.AddWithValue("@.ReportNumber", txtReport.Text)

cmd2.Parameters.AddWithValue("@.ReportNumber", txtReport.Text)

conn.Open()

ReturnVal = Convert.ToInt32(cmd.ExecuteScalar())

conn.Close()

'This checks if the # is correct.

If ReturnVal > 0Then

'This checks if its registered with someone else.

conn.Open()

ReturnVal2 = Convert.ToInt32(cmd2.ExecuteScalar())

conn.Close()

If ReturnVal2 <> 0Then

Server.Transfer("regccinfo.aspx")

Else

lblError.Text ="the # is registered with someone else."

EndIf

Else

lblError.Text ="the # does not exists."

txtReport.Focus()

EndIf

Sure would help if you would post the error that you're gettingSmile

|||

this is the error i get

Value was either too large or too small for an Int32.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.OverflowException: Value was either too large or too small for an Int32.

|||

Well, looks like you're sending in too big a value (absolute value speaking).

|||

you mean the value in the textbox to the query ?

the value would be numbers 10 digits.

If ReturnVal > 0Then

'This checks if the certificate is registered with someone else.

Server.Transfer("regccinfo.aspx")

Else

lblError.Text ="The # is incorrect."

txtReport.Focus()

EndIf

if i have my if else statment like this then it works fine.( Now this doesnt work either.)

|||

"TheInt32 value type represents signed integers with values ranging from negative 2,147,483,648 through positive 2,147,483,647."

fromhttp://msdn2.microsoft.com/en-us/library/system.int32(vs.80).aspx

|||

i got it to work. i chanded my ReturnVal as String running it like that. So far looking good.

Thanks for all your help guys

checking validity

Hello there
I've build store proecdure that create dinamic sql sentences for updating
data.
Is there a way to check if the sencence is valid before running it?Roy,shalom
Yes it is
CREATE TABLE #Test (col INT)
INSERT INTO #Test VALUES (1)
DECLARE @.str VARCHAR(50),@.col INT
SET @.col=5
SET @.str='UPDATE #Test SET col='+CAST(@.col AS VARCHAR(10))
--EXEC (@.str)
PRINT (@.str)
SELECT * FROM #Test
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:OVHrU1LUGHA.5500@.TK2MSFTNGP12.phx.gbl...
> Hello there
> I've build store proecdure that create dinamic sql sentences for updating
> data.
> Is there a way to check if the sencence is valid before running it?
>|||[Reposted, as posts from outside msnews.microsoft.com does not seem to make
it in.]
Roy Goldhammer (roy@.hotmail.com) writes:
> I've build store proecdure that create dinamic sql sentences for updating
> data.
> Is there a way to check if the sencence is valid before running it?
In SQL 2005 you could embed the query in SET PARSEONLY ON and put it in
a TRY/CATCH handler. But that will not catch all errors, like misspelled
column names or misspelled table names. I guess you can catch these if
you use SET FMTONLY ON instead, but that will produce a result set with
metadata to the client, which is likely confuse it.
Working with dynamic SQL means that you have to test carefully, and by
other means ensure that you do not generate syntax errors at run-time.
A very important tool to achieve this is that you build parameterised
queries that you run with sp_executesql. If you interpolate all values
into the SQL string and run with EXEC(), there are more risk for problems.
Also, make sure that you use quotename for all object names you interpolate
into the string.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.seBooks Online for SQL
Server 2005
athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000
athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx|||Consider SET FMTONLY ON and SET PARSEONLY ON. However, if the programming to
create the T-SQL statements is correct, then this should not be a recuring
problem.
If you are talking about dynamic SQL as in the entire structure of statement
(not just parameters) is created on the fly, then perhaps this programming
would be easier to implment on the application side. A class can be written
that exposes properties for table names, joins, column names, filter
expressions, etc. and then a few hundred lines of C# coding could assemble a
properly formatted select statement.
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:OVHrU1LUGHA.5500@.TK2MSFTNGP12.phx.gbl...
> Hello there
> I've build store proecdure that create dinamic sql sentences for updating
> data.
> Is there a way to check if the sencence is valid before running it?
>

Checking User & Expire of Update Possibility (by Trigger), How to?

Hi,

I have Table (RatesTable) every user can insert records to this table, and all users can see this records, this table contain the following columns:

RateID, Service, Rate, DateTime, User

Want I want is a code (trigger) in the database can do the following:

If user perform an Update request the code will check:

- if this recored inserted by the same user update command will be execute.

- if this recored inserted by other user: update command will not execute and return message.

- if more than 5 minutes passed the update command will not be execute and return message.

Yes, this can be done with a trigger but it really would be better for the update statement itself to decide whether or not the update is allowed by adding either a WHERE condition or an AND condition to the update statement to decide whether or not to allow the update.

Change the update statement from something like:

update rate
set service = @.serviceChange,
rate = @.rateChange
where rateId = @.rateRecordId

to something like

update rate
set service = @.serviceChange,
rate = @.rateChange
where rateId = @.rateRecordId
and user = @.currentUser
and dateTime >= dateadd (mi, -5, getdate())

|||

Thanks Kent Waldrop Ap07, but the problem is my all program use Datasets created by Data Source Configration Wizzard, is it possible to to add your code to the Dataset Designer?

and what if I want to put this code in Trigger?

thnx again,,,

|||Any help?|||

Here is a TRIGGER idea. While I agree with Kent that changing the UPDATE statement is a better option, I know from expereince that it is not always the solution that works.

The code idea below relies upon [User] being captured with the system_user system function (domain/username).

Code Snippet


CREATE TRIGGER tr_RatesTable_U_UserOnly
ON RatesTable
FOR UPDATE
AS
IF @.@.ROWCOUNT = 0
RETURN

DECLARE @.User varchar(50)


IF EXISTS
( SELECT *
FROM inserted
WHERE User <> system_user
)
BEGIN
ROLLBACK
RAISERROR('Cannot UpDate This Record', 16, 1)
RETURN
END

GO



|||

Hi,

I am not familiar with the Wizard stuff, but I would expect that it does not cover holding the logic for that. But should have a look on the resulting queries the wizard produces, maybe you are able to tweak the Update statement to cover your logic. Anyway, using a trigger could be another option:

CREATE TRIGGER TRG_UPD_SomeTable
ON SomeTable
FOR UPDATE
AS
BEGIN

IF NOT EXISTS(SELECT * From INSERTED WHERE User = SUSER_NAME AND DateTime <= DATEADD(s,-5,GETDATE()))
RAISERROR('Update not allowed',16,1)

END


HTH, jens K. Suessmeyer.


http://www.sqlserver2005.de

Checking User & Expire of Update Possibility (by Trigger), How to?

Hi,

I have Table (RatesTable) every user can insert records to this table, and all users can see this records, this table contain the following columns:

RateID, Service, Rate, DateTime, User

Want I want is a code (trigger) in the database can do the following:

If user perform an Update request the code will check:

- if this recored inserted by the same user update command will be execute.

- if this recored inserted by other user: update command will not execute and return message.

- if more than 5 minutes passed the update command will not be execute and return message.

Yes, this can be done with a trigger but it really would be better for the update statement itself to decide whether or not the update is allowed by adding either a WHERE condition or an AND condition to the update statement to decide whether or not to allow the update.

Change the update statement from something like:

update rate
set service = @.serviceChange,
rate = @.rateChange
where rateId = @.rateRecordId

to something like

update rate
set service = @.serviceChange,
rate = @.rateChange
where rateId = @.rateRecordId
and user = @.currentUser
and dateTime >= dateadd (mi, -5, getdate())

|||

Thanks Kent Waldrop Ap07, but the problem is my all program use Datasets created by Data Source Configration Wizzard, is it possible to to add your code to the Dataset Designer?

and what if I want to put this code in Trigger?

thnx again,,,

|||Any help?|||

Here is a TRIGGER idea. While I agree with Kent that changing the UPDATE statement is a better option, I know from expereince that it is not always the solution that works.

The code idea below relies upon [User] being captured with the system_user system function (domain/username).

Code Snippet


CREATE TRIGGER tr_RatesTable_U_UserOnly
ON RatesTable
FOR UPDATE
AS
IF @.@.ROWCOUNT = 0
RETURN

DECLARE @.User varchar(50)


IF EXISTS
( SELECT *
FROM inserted
WHERE User <> system_user
)
BEGIN
ROLLBACK
RAISERROR('Cannot UpDate This Record', 16, 1)
RETURN
END

GO



|||

Hi,

I am not familiar with the Wizard stuff, but I would expect that it does not cover holding the logic for that. But should have a look on the resulting queries the wizard produces, maybe you are able to tweak the Update statement to cover your logic. Anyway, using a trigger could be another option:

CREATE TRIGGER TRG_UPD_SomeTable
ON SomeTable
FOR UPDATE
AS
BEGIN

IF NOT EXISTS(SELECT * From INSERTED WHERE User = SUSER_NAME AND DateTime <= DATEADD(s,-5,GETDATE()))
RAISERROR('Update not allowed',16,1)

END


HTH, jens K. Suessmeyer.


http://www.sqlserver2005.de

Checking Triggers....

Is there a way to check if triggers have been enabled or disabled?
Already found it
select objectproperty (object_id('triggernamegoeshere'),
'ExecIsTriggerDisabled')
A result of 0 = enabled.
"nivek" <eckart_612@.hotmail.com> wrote in message
news:UemdnQD7XMXDlCLcRVn-sQ@.centurytel.net...
> Is there a way to check if triggers have been enabled or disabled?
>
|||SELECT OBJECTPROPERTY(OBJECT_ID('TriggerName'), 'ExecIsTriggerDisabled')
Will return 1 if the trigger is disabled, 0 if it's enabled, NULL if you
enter an invalid name.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
"nivek" <eckart_612@.hotmail.com> wrote in message
news:UemdnQD7XMXDlCLcRVn-sQ@.centurytel.net...
> Is there a way to check if triggers have been enabled or disabled?
>
|||SELECT name, CASE OBJECTPROPERTY(id, 'ExecIsTriggerDisabled') WHEN 1 THEN
'Disabled' ELSE 'Enabled' END AS status
FROM sysobjects
WHERE xtype = 'TR'
Jacco Schalkwijk
SQL Server MVP
"nivek" <eckart_612@.hotmail.com> wrote in message
news:UemdnQD7XMXDlCLcRVn-sQ@.centurytel.net...
> Is there a way to check if triggers have been enabled or disabled?
>

Checking Triggers....

Is there a way to check if triggers have been enabled or disabled?Already found it
select objectproperty (object_id('triggernamegoeshere'),
'ExecIsTriggerDisabled')
A result of 0 = enabled.
"nivek" <eckart_612@.hotmail.com> wrote in message
news:UemdnQD7XMXDlCLcRVn-sQ@.centurytel.net...
> Is there a way to check if triggers have been enabled or disabled?
>|||SELECT OBJECTPROPERTY(OBJECT_ID('TriggerName'), 'ExecIsTriggerDisabled')
Will return 1 if the trigger is disabled, 0 if it's enabled, NULL if you
enter an invalid name.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"nivek" <eckart_612@.hotmail.com> wrote in message
news:UemdnQD7XMXDlCLcRVn-sQ@.centurytel.net...
> Is there a way to check if triggers have been enabled or disabled?
>|||SELECT name, CASE OBJECTPROPERTY(id, 'ExecIsTriggerDisabled') WHEN 1 THEN
'Disabled' ELSE 'Enabled' END AS status
FROM sysobjects
WHERE xtype = 'TR'
--
Jacco Schalkwijk
SQL Server MVP
"nivek" <eckart_612@.hotmail.com> wrote in message
news:UemdnQD7XMXDlCLcRVn-sQ@.centurytel.net...
> Is there a way to check if triggers have been enabled or disabled?
>

Checking to see if values are in a table or not -- if not then inserting the values.

I'm trying to checking my production table table_a against a working table table_b (which i'm downlading data to)
Here are the collumns i have in table_a and table_b
Description | FundID (this is not my PK) | Money
I'm running an update if there is already vaule in the money collumn. I check to see if table_a matches table_b...if not i update table a with table b's value where FundID match up.
What i'm having trouble on is if there is no record in table_a but there is a record in table_b. How can I insert that record into table_a? I would like to do all of this (the update and insert statement in one stored proc. if possible. )
If anyone has this answer please let me know.
Thanks,
RB

You'll have to check this before you use it, but this should give you all rows in b that are not in a:
select b.FundID, a.FundID
from b
left join a on a.FundID = b.FundID
where a.FundID is null
Then if this is right, you can write a simple insert statement before it, like this:
INSERT INTO a
select b.Description, b.FundID, b.Money
from b
left join a on a.FundID = b.FundID
where a.FundID is null

|||The select statement looks good however I'm trying to insert into table b so wouldn't it be
INSERT INTO b
...
Just clarify for me if you could.
Thanks for the help
RB|||Oh, if you are inserting INTO b, then you'll just have to reverseeverything I wrote. I thought you were inserting into A what wasin B but not in A.

Checking to see if SQL Server on machine is up and running

Hi All,
i have a doos script that downloads from an ftp site and extracts data from
zip files before running a DTS Package.
my question is; is there a way to check to see if SQL is running and if not
start it?
any help woudl be appreciated
Simon Whale
Hi,
Take a look into this script. I have not tested this.
http://www.softtreetech.com/24x7/archive/35.htm
Thanks
Hari
SQL Server MVP
"simon whale" <hell@.nospam.com> wrote in message
news:%23M8$s1J5GHA.1012@.TK2MSFTNGP05.phx.gbl...
> Hi All,
> i have a doos script that downloads from an ftp site and extracts data
> from zip files before running a DTS Package.
> my question is; is there a way to check to see if SQL is running and if
> not start it?
> any help woudl be appreciated
>
> Simon Whale
>

Checking to see if SQL Server on machine is up and running

Hi All,
i have a doos script that downloads from an ftp site and extracts data from
zip files before running a DTS Package.
my question is; is there a way to check to see if SQL is running and if not
start it?
any help woudl be appreciated
Simon WhaleHi,
Take a look into this script. I have not tested this.
http://www.softtreetech.com/24x7/archive/35.htm
Thanks
Hari
SQL Server MVP
"simon whale" <hell@.nospam.com> wrote in message
news:%23M8$s1J5GHA.1012@.TK2MSFTNGP05.phx.gbl...
> Hi All,
> i have a doos script that downloads from an ftp site and extracts data
> from zip files before running a DTS Package.
> my question is; is there a way to check to see if SQL is running and if
> not start it?
> any help woudl be appreciated
>
> Simon Whale
>

Friday, February 24, 2012

Checking to see if SQL Server on machine is up and running

Hi All,
i have a doos script that downloads from an ftp site and extracts data from
zip files before running a DTS Package.
my question is; is there a way to check to see if SQL is running and if not
start it?
any help woudl be appreciated
Simon WhaleHi,
Take a look into this script. I have not tested this.
http://www.softtreetech.com/24x7/archive/35.htm
Thanks
Hari
SQL Server MVP
"simon whale" <hell@.nospam.com> wrote in message
news:%23M8$s1J5GHA.1012@.TK2MSFTNGP05.phx.gbl...
> Hi All,
> i have a doos script that downloads from an ftp site and extracts data
> from zip files before running a DTS Package.
> my question is; is there a way to check to see if SQL is running and if
> not start it?
> any help woudl be appreciated
>
> Simon Whale
>

checking to see if field value is unique

When entering a value into a SQL database is there a way to find out if that value has already been used in that field?

eg. If I were entering a last name into a field called "user_name" could I add some validation whereby the record couldn't be entered if someone else had already inserted that last name?You could:

1) use unique index in the user_name column to prevent duplicate values (i.e first name and last name into separate columns as well and target the index to the last name column). In this case DB throws an error if duplicate insert is tried.

2) you could also check the existence before inserting into table, something like:

IF (SELECT count(*) FROM MyTable WHERE Last_name='thename') > 0
BEGIN /*There is such last name already*/

END

ELSE /*There isn't such in the table*/

BEGIN

END|||Definitely create the unique contraint on the columns you don't want duplicated, as suggested. This will ensure that duplicate values cannot physically be entered.

You should also check for the existence before inserting into the table, so that you can gracefully capture the error and return user-friendly information back to the user. But, instead of the method suggested, you should try using EXISTS, which will stop processing as soon as the condition is met


IF EXISTS(SELECT NULL FROM MyTable WHERE Last_name='thename')
BEGIN /*There is such last name already*/
END

ELSE /*There isn't such in the table*/

BEGIN
END


Terri

Checking to see if a sqlagent job is running?

Hi all,
I am starting with the very basics to check to see if a job is running
before I kick off another job. I go to my dev server, see that a job is
running through EM, open query analyzer and run:
Use msdb
go
select run_status from sysjobhistory
where run_status = 4
and it returns 0 rows. I go back to EM and refresh the job and it is still
running. It's history says it runs for 10 minutes or so each run. According
to BOL I should see at least one row for this job that is running. Can
someone show me the error of my ways? Thanks. BTW, I have tried searching on
this topic, but have not come up with anything very helpful.
Jackie
Jackie,
Try:
EXECUTE MSDB.DBO.SP_HELP_JOB @.EXECUTION_STATUS = 1
HTH
Jerry
"Jackie Brophy" <jbrophy@.mathworks.com> wrote in message
news:u3ekuDnzFHA.3720@.TK2MSFTNGP14.phx.gbl...
> Hi all,
> I am starting with the very basics to check to see if a job is running
> before I kick off another job. I go to my dev server, see that a job is
> running through EM, open query analyzer and run:
> Use msdb
> go
> select run_status from sysjobhistory
> where run_status = 4
> and it returns 0 rows. I go back to EM and refresh the job and it is still
> running. It's history says it runs for 10 minutes or so each run.
> According to BOL I should see at least one row for this job that is
> running. Can someone show me the error of my ways? Thanks. BTW, I have
> tried searching on this topic, but have not come up with anything very
> helpful.
> Jackie
>

Checking to see if a sqlagent job is running?

Hi all,
I am starting with the very basics to check to see if a job is running
before I kick off another job. I go to my dev server, see that a job is
running through EM, open query analyzer and run:
Use msdb
go
select run_status from sysjobhistory
where run_status = 4
and it returns 0 rows. I go back to EM and refresh the job and it is still
running. It's history says it runs for 10 minutes or so each run. According
to BOL I should see at least one row for this job that is running. Can
someone show me the error of my ways? Thanks. BTW, I have tried searching on
this topic, but have not come up with anything very helpful.
JackieJackie,
Try:
EXECUTE MSDB.DBO.SP_HELP_JOB @.EXECUTION_STATUS = 1
HTH
Jerry
"Jackie Brophy" <jbrophy@.mathworks.com> wrote in message
news:u3ekuDnzFHA.3720@.TK2MSFTNGP14.phx.gbl...
> Hi all,
> I am starting with the very basics to check to see if a job is running
> before I kick off another job. I go to my dev server, see that a job is
> running through EM, open query analyzer and run:
> Use msdb
> go
> select run_status from sysjobhistory
> where run_status = 4
> and it returns 0 rows. I go back to EM and refresh the job and it is still
> running. It's history says it runs for 10 minutes or so each run.
> According to BOL I should see at least one row for this job that is
> running. Can someone show me the error of my ways? Thanks. BTW, I have
> tried searching on this topic, but have not come up with anything very
> helpful.
> Jackie
>

Checking to see if a sqlagent job is running?

Hi all,
I am starting with the very basics to check to see if a job is running
before I kick off another job. I go to my dev server, see that a job is
running through EM, open query analyzer and run:
Use msdb
go
select run_status from sysjobhistory
where run_status = 4
and it returns 0 rows. I go back to EM and refresh the job and it is still
running. It's history says it runs for 10 minutes or so each run. According
to BOL I should see at least one row for this job that is running. Can
someone show me the error of my ways? Thanks. BTW, I have tried searching on
this topic, but have not come up with anything very helpful.
JackieJackie,
Try:
EXECUTE MSDB.DBO.SP_HELP_JOB @.EXECUTION_STATUS = 1
HTH
Jerry
"Jackie Brophy" <jbrophy@.mathworks.com> wrote in message
news:u3ekuDnzFHA.3720@.TK2MSFTNGP14.phx.gbl...
> Hi all,
> I am starting with the very basics to check to see if a job is running
> before I kick off another job. I go to my dev server, see that a job is
> running through EM, open query analyzer and run:
> Use msdb
> go
> select run_status from sysjobhistory
> where run_status = 4
> and it returns 0 rows. I go back to EM and refresh the job and it is still
> running. It's history says it runs for 10 minutes or so each run.
> According to BOL I should see at least one row for this job that is
> running. Can someone show me the error of my ways? Thanks. BTW, I have
> tried searching on this topic, but have not come up with anything very
> helpful.
> Jackie
>