Showing posts with label dynamically. Show all posts
Showing posts with label dynamically. Show all posts

Friday, March 23, 2012

Problem in Charting

I am dynamically generating the RDL for a chart,but i am not able to show markers on the X-Axis when the report is generated.

FYI ,I am creating a orthographic column chart.

Any ideas?

Markers can be turned on using the Chart properties dialog in VS.NET.

In the Data tab, Select the Values you want to display makers. Cick "Edit". Then on the Appearance tab, click the Show markers checkbox.

-Chris

|||

Hi,

I suppose u didnt read my question fully..I am dynamically generating the RDL wherein I need to show the labels (Markers) on the X-Axis.

|||

You can always lookup the RDL specification available here: http://www.microsoft.com/sql/technologies/reporting/rdlspec.mspx

Here is an example of what you would need to generate to get tickmarks on the x-axis (depending on major and minor interval settings or automatic intervals if omitted):

<CategoryAxis>
<Axis>
<Title />
<Visible>true</Visible>
<MajorTickMarks>Outside</MajorTickMarks>
<MinorTickMarks>Outside</MinorTickMarks>
<MajorInterval>5</MajorInterval>
<MinorInterval>1</MinorInterval>
<MajorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<Margin>true</Margin>
<Scalar>true</Scalar>
</Axis>
</CategoryAxis>

-- Robert

Wednesday, March 21, 2012

Problem getting execution status of a SQL Agent Job

I’m having trouble retrieving the execution status of a job – perhaps someone can help me.

I have a stored proc (on SQL 2005) that dynamically creates and executes a SQL Agent Job. The stored proc first has to check whether the job exists. If it already exists and is not active then I simply reuse the existing job. However if the job exists but is currently executing then I need to create a new job because there can be multiple instances of the program that the job runs. My problem is how to check whether the job is currently executing. I tried using sp_help_job as shown below but the rowcount seems to return 1 even when there are no jobs executing!

Exec msdb.dbo.sp_help_job

@.job_aspect = 'JOB',

@.execution_status = 0,

@.job_name = @.JobName

If @.@.rowcount > 0 Begin

End

I then tried this code…

If (select count(*) from msdb.dbo.sysjobs j

left outer join msdb.dbo.sysjobhistory h on j.job_id = h.job_id where name = @.JobName and

h.step_id = 1 and

run_status = 4) > 0

Begin

End

… but it doesn’t seem to pick up records even when the job is currently executing.

How can I, in T-SQL, get the execution status of the job?

I have the same issue. When I began to dig into sp_help_job, I noticed a call within the procedure to build a temp table:

exec master.dbo.xp_sqlagent_enum_jobs 1, {insert job owner here}

This procedure outputs a 'Running' field that will return a 1 if it the job is running, or otherwise a 0. This is not complete code for you, but should get you pointed in the right direction. I am going to build a temp table with this XP and filter on the job ID to return the status.

|||sp_help_jobactivity is the sp that should give status of jobs in SQL2005. See BOL for more info on this SP.sql

Wednesday, March 7, 2012

Problem creating database dynamically

Hi everybody,

I have a problem. When I try to create a database with this code:

strConnection = "server=(local);Integrated Security=SSPI"
objConnection = New SqlConnection(strConnection)
objConnection.Open()
Dim strSQL = "CREATE DATABASE xxxxxx ON PRIMARY"
strSQL += "(Name=test_data, filename = 'xxxxx.mdf', size=3,"
strSQL += "maxsize=5, filegrowth=10%)log on"
strSQL += "(name=mydbb_log, filename='xxxxx.ldf',size=3,"
strSQL += "maxsize=20,filegrowth=1)"
objCommand = New SqlCommand(strSQL, objConnection)
objCommand.ExecuteNonQuery()

it usually works, except when the name of the database (xxxxxx) contains a number in the beginning of the name or if it is all made up completely by numbers. I also converted the database name into a string, but it doesn't work either.

What is the problem?
How can I solve it?

Thanks in advanceEither don't allow all digits or the first character to be a digit or you might try using [] around then database name. Works for fields, may work for the database name.