Does anyone know of a way to get the name of the job that is running. Is
there a variable that this is stored in similar to @.@.servername or a stored
procedure that can return this information. I am wanting to capture the
jobname while the job is running
Thanks,
Randy Bunton
One method is to specify a '[JOBID]' token in your job step T-SQL script.
You can then use this value to retrieve the job name from sysjobs. For
example.
SELECT name
FROM msdb..sysjobs
WHERE job_id = CAST([JOBID] AS uniqueidentifier)
Note that SQL Server Agent job tokens can only be specified in the directly
executed script. If you need the value in stored procedures, etc, you can
pass the value as a parameter.
Hope this helps.
Dan Guzman
SQL Server MVP
"Randy Bunton" <buntonrl@.charlestoncpw.com> wrote in message
news:uVYnPsiSEHA.3988@.tk2msftngp13.phx.gbl...
> Does anyone know of a way to get the name of the job that is running. Is
> there a variable that this is stored in similar to @.@.servername or a
stored
> procedure that can return this information. I am wanting to capture the
> jobname while the job is running
> Thanks,
> Randy Bunton
>
Showing posts with label similar. Show all posts
Showing posts with label similar. Show all posts
Friday, March 23, 2012
Retrieving the name of a job while it is executing
Labels:
database,
executing,
isthere,
job,
microsoft,
mysql,
oracle,
retrieving,
running,
server,
servername,
similar,
sql,
stored,
variable
Retrieving the name of a job while it is executing
Does anyone know of a way to get the name of the job that is running. Is
there a variable that this is stored in similar to @.@.servername or a stored
procedure that can return this information. I am wanting to capture the
jobname while the job is running
Thanks,
Randy BuntonOne method is to specify a '[JOBID]' token in your job step T-SQL script
.
You can then use this value to retrieve the job name from sysjobs. For
example.
SELECT name
FROM msdb..sysjobs
WHERE job_id = CAST([JOBID] AS uniqueidentifier)
Note that SQL Server Agent job tokens can only be specified in the directly
executed script. If you need the value in stored procedures, etc, you can
pass the value as a parameter.
Hope this helps.
Dan Guzman
SQL Server MVP
"Randy Bunton" <buntonrl@.charlestoncpw.com> wrote in message
news:uVYnPsiSEHA.3988@.tk2msftngp13.phx.gbl...
> Does anyone know of a way to get the name of the job that is running. Is
> there a variable that this is stored in similar to @.@.servername or a
stored
> procedure that can return this information. I am wanting to capture the
> jobname while the job is running
> Thanks,
> Randy Bunton
>
there a variable that this is stored in similar to @.@.servername or a stored
procedure that can return this information. I am wanting to capture the
jobname while the job is running
Thanks,
Randy BuntonOne method is to specify a '[JOBID]' token in your job step T-SQL script
.
You can then use this value to retrieve the job name from sysjobs. For
example.
SELECT name
FROM msdb..sysjobs
WHERE job_id = CAST([JOBID] AS uniqueidentifier)
Note that SQL Server Agent job tokens can only be specified in the directly
executed script. If you need the value in stored procedures, etc, you can
pass the value as a parameter.
Hope this helps.
Dan Guzman
SQL Server MVP
"Randy Bunton" <buntonrl@.charlestoncpw.com> wrote in message
news:uVYnPsiSEHA.3988@.tk2msftngp13.phx.gbl...
> Does anyone know of a way to get the name of the job that is running. Is
> there a variable that this is stored in similar to @.@.servername or a
stored
> procedure that can return this information. I am wanting to capture the
> jobname while the job is running
> Thanks,
> Randy Bunton
>
Labels:
database,
executing,
isthere,
job,
microsoft,
mysql,
oracle,
retrieving,
running,
server,
servername,
similar,
sql,
stored,
variable
Retrieving the name of a job while it is executing
Does anyone know of a way to get the name of the job that is running. Is
there a variable that this is stored in similar to @.@.servername or a stored
procedure that can return this information. I am wanting to capture the
jobname while the job is running
Thanks,
Randy BuntonOne method is to specify a '[JOBID]' token in your job step T-SQL script.
You can then use this value to retrieve the job name from sysjobs. For
example.
SELECT name
FROM msdb..sysjobs
WHERE job_id = CAST([JOBID] AS uniqueidentifier)
Note that SQL Server Agent job tokens can only be specified in the directly
executed script. If you need the value in stored procedures, etc, you can
pass the value as a parameter.
Hope this helps.
Dan Guzman
SQL Server MVP
"Randy Bunton" <buntonrl@.charlestoncpw.com> wrote in message
news:uVYnPsiSEHA.3988@.tk2msftngp13.phx.gbl...
> Does anyone know of a way to get the name of the job that is running. Is
> there a variable that this is stored in similar to @.@.servername or a
stored
> procedure that can return this information. I am wanting to capture the
> jobname while the job is running
> Thanks,
> Randy Bunton
>
there a variable that this is stored in similar to @.@.servername or a stored
procedure that can return this information. I am wanting to capture the
jobname while the job is running
Thanks,
Randy BuntonOne method is to specify a '[JOBID]' token in your job step T-SQL script.
You can then use this value to retrieve the job name from sysjobs. For
example.
SELECT name
FROM msdb..sysjobs
WHERE job_id = CAST([JOBID] AS uniqueidentifier)
Note that SQL Server Agent job tokens can only be specified in the directly
executed script. If you need the value in stored procedures, etc, you can
pass the value as a parameter.
Hope this helps.
Dan Guzman
SQL Server MVP
"Randy Bunton" <buntonrl@.charlestoncpw.com> wrote in message
news:uVYnPsiSEHA.3988@.tk2msftngp13.phx.gbl...
> Does anyone know of a way to get the name of the job that is running. Is
> there a variable that this is stored in similar to @.@.servername or a
stored
> procedure that can return this information. I am wanting to capture the
> jobname while the job is running
> Thanks,
> Randy Bunton
>
Labels:
database,
executing,
job,
microsoft,
mysql,
oracle,
retrieving,
running,
server,
servername,
similar,
sql,
stored,
variable
Tuesday, February 21, 2012
Retrieve Domain Name
Is there a way to pull back the domain name that a server is in from within
SQL?
ie @.@.servername returns the server/instance, something similar for the
domain is what I am looking for.
to capture the start time, end time, application name, client host name, NT
user name and the domain name.
DECLARE @.TraceID int, @.DB_ID int
EXEC CreateTrace
'C:\My SQL Traces\ProceduresCalledInMSDB',
@.OutputTraceID = @.TraceID OUT
EXEC AddEvent
@.TraceID,
'SP:Completed',
'TextData, StartTime, EndTime, ApplicationName, ClientHostName, NTUserName,
NTDomainName, DatabaseID'
SET @.DB_ID = DB_ID('msdb')
EXEC AddFilter
@.TraceID,
'DatabaseID',
@.DB_ID
EXEC StartTrace 1
GO
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from within
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.
|||Sorry all, this is not within a trace but just at a sql analyzer window or
within a stored proc?
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from within
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.
|||I don't think there is any direct statement in SQL to get the domain name.
I think these statement will give the domain information for a login or
associated to the server:
xp_loginconfig
xp_enumgroups
xp_logininfo
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from within
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.
SQL?
ie @.@.servername returns the server/instance, something similar for the
domain is what I am looking for.
to capture the start time, end time, application name, client host name, NT
user name and the domain name.
DECLARE @.TraceID int, @.DB_ID int
EXEC CreateTrace
'C:\My SQL Traces\ProceduresCalledInMSDB',
@.OutputTraceID = @.TraceID OUT
EXEC AddEvent
@.TraceID,
'SP:Completed',
'TextData, StartTime, EndTime, ApplicationName, ClientHostName, NTUserName,
NTDomainName, DatabaseID'
SET @.DB_ID = DB_ID('msdb')
EXEC AddFilter
@.TraceID,
'DatabaseID',
@.DB_ID
EXEC StartTrace 1
GO
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from within
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.
|||Sorry all, this is not within a trace but just at a sql analyzer window or
within a stored proc?
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from within
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.
|||I don't think there is any direct statement in SQL to get the domain name.
I think these statement will give the domain information for a login or
associated to the server:
xp_loginconfig
xp_enumgroups
xp_logininfo
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from within
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.
Labels:
back,
database,
domain,
instance,
microsoft,
mysql,
oracle,
pull,
retrieve,
returns,
server,
servername,
similar,
sql,
withinsqlie
Retrieve Domain Name
Is there a way to pull back the domain name that a server is in from within
SQL?
ie @.@.servername returns the server/instance, something similar for the
domain is what I am looking for.to capture the start time, end time, application name, client host name, NT
user name and the domain name.
DECLARE @.TraceID int, @.DB_ID int
EXEC CreateTrace
'C:\My SQL Traces\ProceduresCalledInMSDB',
@.OutputTraceID = @.TraceID OUT
EXEC AddEvent
@.TraceID,
'SP:Completed',
'TextData, StartTime, EndTime, ApplicationName, ClientHostName, NTUserName,
NTDomainName, DatabaseID'
SET @.DB_ID = DB_ID('msdb')
EXEC AddFilter
@.TraceID,
'DatabaseID',
@.DB_ID
EXEC StartTrace 1
GO
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from within
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.|||Sorry all, this is not within a trace but just at a sql analyzer window or
within a stored proc?
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from within
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.|||I don't think there is any direct statement in SQL to get the domain name.
I think these statement will give the domain information for a login or
associated to the server:
xp_loginconfig
xp_enumgroups
xp_logininfo
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from within
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.
SQL?
ie @.@.servername returns the server/instance, something similar for the
domain is what I am looking for.to capture the start time, end time, application name, client host name, NT
user name and the domain name.
DECLARE @.TraceID int, @.DB_ID int
EXEC CreateTrace
'C:\My SQL Traces\ProceduresCalledInMSDB',
@.OutputTraceID = @.TraceID OUT
EXEC AddEvent
@.TraceID,
'SP:Completed',
'TextData, StartTime, EndTime, ApplicationName, ClientHostName, NTUserName,
NTDomainName, DatabaseID'
SET @.DB_ID = DB_ID('msdb')
EXEC AddFilter
@.TraceID,
'DatabaseID',
@.DB_ID
EXEC StartTrace 1
GO
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from within
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.|||Sorry all, this is not within a trace but just at a sql analyzer window or
within a stored proc?
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from within
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.|||I don't think there is any direct statement in SQL to get the domain name.
I think these statement will give the domain information for a login or
associated to the server:
xp_loginconfig
xp_enumgroups
xp_logininfo
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from within
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.
Retrieve Domain Name
Is there a way to pull back the domain name that a server is in from within
SQL?
ie @.@.servername returns the server/instance, something similar for the
domain is what I am looking for.to capture the start time, end time, application name, client host name, NT
user name and the domain name.
DECLARE @.TraceID int, @.DB_ID int
EXEC CreateTrace
'C:\My SQL Traces\ProceduresCalledInMSDB',
@.OutputTraceID = @.TraceID OUT
EXEC AddEvent
@.TraceID,
'SP:Completed',
'TextData, StartTime, EndTime, ApplicationName, ClientHostName, NTUserName,
NTDomainName, DatabaseID'
SET @.DB_ID = DB_ID('msdb')
EXEC AddFilter
@.TraceID,
'DatabaseID',
@.DB_ID
EXEC StartTrace 1
GO
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from withi
n
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.|||Sorry all, this is not within a trace but just at a sql analyzer window or
within a stored proc?
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from withi
n
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.|||I don't think there is any direct statement in SQL to get the domain name.
I think these statement will give the domain information for a login or
associated to the server:
xp_loginconfig
xp_enumgroups
xp_logininfo
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from withi
n
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.
SQL?
ie @.@.servername returns the server/instance, something similar for the
domain is what I am looking for.to capture the start time, end time, application name, client host name, NT
user name and the domain name.
DECLARE @.TraceID int, @.DB_ID int
EXEC CreateTrace
'C:\My SQL Traces\ProceduresCalledInMSDB',
@.OutputTraceID = @.TraceID OUT
EXEC AddEvent
@.TraceID,
'SP:Completed',
'TextData, StartTime, EndTime, ApplicationName, ClientHostName, NTUserName,
NTDomainName, DatabaseID'
SET @.DB_ID = DB_ID('msdb')
EXEC AddFilter
@.TraceID,
'DatabaseID',
@.DB_ID
EXEC StartTrace 1
GO
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from withi
n
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.|||Sorry all, this is not within a trace but just at a sql analyzer window or
within a stored proc?
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from withi
n
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.|||I don't think there is any direct statement in SQL to get the domain name.
I think these statement will give the domain information for a login or
associated to the server:
xp_loginconfig
xp_enumgroups
xp_logininfo
"Thom" wrote:
> Is there a way to pull back the domain name that a server is in from withi
n
> SQL?
> ie @.@.servername returns the server/instance, something similar for the
> domain is what I am looking for.
Labels:
back,
database,
domain,
instance,
microsoft,
mysql,
oracle,
pull,
retrieve,
returns,
server,
servername,
similar,
sql,
withinsqlie
Subscribe to:
Posts (Atom)