Job run in sql sever agent insert all null data. - sql-server

I have a store procedure which insert data into a table in sql. It work find in SQL however when i create a job in sql server management studio to execute this store procedure by
exec store procedure name
the job does run successfully but all the data insert into the table is null.
i have no idea how this happen, please help. Thanks

Part 1:
We need to know more information than what you are supplying.
Here is a list of things to start.
1 - Generate TSQL for the table.
2 - Send us a couple of records to insert.
3 - Sample TSQL code inside the job step.
4 - What account is SQL Agent running under?
5 - Is the job running in the correct database when executing the TSQL statement?
6 - Are there any errors in the job history.
In short, this task can be easily done.
A screen shot or two would be worth a 1000 words!
Part 2:
Please use the snippet tool in windows to grab a screen shot so that I can see what is wrong.
It is very difficult to diagnose things remotely via just words.
Here are some more things to check.
1 - Are you a local admin of the laptop or server?
2 - Make sure you open the SQL server configuration manager as an admin.
This can be accomplished by right clicking the icon and selecting run as an admin instead of a double click to launch.
Below is a sample image of my configuration manager.
Here is the status of my SQL Server agent and the account it is running under.

Related

We can't update the cube that is located on Microsoft Analysis server from an agent located at SQL Server Agent

Here is some background information. Both the cube and the agent is located on the same server lets call this x.
The database that is used by the Cube is located on a different serverlets call this datasource.
The funny thing is that if we process the cube manually from Microsoft Analysis server it works perfect every time.
Note we run all of this in azure and the datasource is Sql Server
When we start the agentjob it runs quite a while but then we get an error with this message
Executed as user:NT Service\SQLSERVERAGENT.
<return xmlns="urn:schemas-microsoft-com:xml-analysis">
<root xmlns="urn:schemas-microsoft-com:xml-analysis:empty">
<Messages xmlns="urn:schemas-microsoft-com:xml-analysis:exception">
<Warning WarningCode="1092091904" Description="Note. Analysis Server has persisted any security information specified as part of the Connection string portion of the Datsource object definition." Source="Microsoft SQL Server 2017 Analysis Services Managed Code Module"
HelpFile="" />
</Messages>
</root>
</return>
When we klick on "Start Job at Step..." It shows Actions and status
The first action Start Job SsasLoad_Ramundberget_Axess give status Success
The second action execute job SsasLoad_Ramundberget_Axess is first status In progress in 80 sec and then status error
I have been search for a solution to this problem and it all end up with being a permission issue.
A few have had this same problem and all of them point is the permission direction.
We have tried the following.
We have logged in to visual Studio with admin account and deployed it but it was the same error.
I have a theory.
I think the user that is trying to connect to datasource is different when we run the cube manually and when we run the agent.
I am the one that posted the initial question. I have now additional information to share. To be able to see the flow of data that happens on the datasource I use the Azure Data Studio(Sql Server profiler). As I mentioned in my initial question it works all the time with status success when I update the cube(tabular model) manually from Microsoft Analysis Server. Here is the screen shot from logging using Azure Data Studio how it looks like when I process the cube(tabular model) manually with process mode full. https://i.stack.imgur.com/FMcBJ.png To automate this steps to update the cube automatically we created a schedule Job that will run every hour. To make sure that the agent job will work we start the agent job manually that kick start the cube to update itself . But in reality it will run in the background and kickstart the cube to update itself. We used the SQL Server Agent to process the cube(tabular mode). Here is how the json looks like to set up the agent job { "refresh": { "type": "full", "objects": [ { "database": "Axess_Ramundberget" } ] } } I want to point out when we use the agent to trigger the cube to update itself it doesn't work in 95% of the time. Here is a screen shot from zure Data Studio sql server profiler how it looks like when status give error. https://i.stack.imgur.com/Ms075.png One really funny thing is that when we get status error the cube is updated successfully correct despite the error. But the thing is we really don't want to have false information saying error but the cube is successfully updated from the datasource. So in the initial question I thought it had to do with permission but as far as I underrstand it can't be any permission issue. The error we get when starting the agent is always the same as I mentioned in the initial question. I have been looking really thoroughly to find a solution to our problem but there are very few that have had this kind of problem. If I compare the data stream in azure data studio sql profiler between when we run the cube manually and run the agent it very similar. Here is a screen shot for view history of the SQl Server agent https://i.stack.imgur.com/keDVl.jpg One more funny thing is that when we use the Azure Data Studio sql profiler to log it works sometimes but if we doesn't use the sql profiler it will never ever give succes but when we use the sql profiler it give success sometimes as the screen shot shows. So every success that shows is when we have used the sql profiler.

Identify source of a SQL Server job running nightly

I am looking into performance issues with an app that uses SQL Server Express (Microsoft SQL Server 2014 (SP2) (KB3171021) - 12.0.5000.0 (X64)) for the back end database.
I'm logging slow running queries using Extended Events. Looking at these I have identified a job that runs every night a series of queries, some of which take quite an extended period. The longest single query takes 10 minutes or so. It seems to be some sort of reporting, gathering broad information about everything in the tables it is looking at.
This seems to be an automated process that is running nightly at exactly the same time and takes about the same length of time to execute each night (around 20 minutes).
It runs on a Windows account with Administrative privileges that connects to SQL using Windows authentication. There is other legit stuff we do know about also running on this account.
The client doesn't know what it is.
The app name logged is just ".Net SqlClient Data Provider" which I believe is a generic default.
This is different than the client application which identifies itself correctly. I have identified with the client everything else that is running against the database- there are a few other jobs that generate accounting emails for example.
I can't find anything in Windows Scheduled Tasks that corresponds and SQL Express obviously doesn't have SQL Server Agent- everything other SQL job I have identified is scheduled in Windows Scheduled Tasks.
I've tried turning login auditing on and I can see the login occurring but it gives even less information as to what it is, it doesn't even give me the client app name.
I have no reason to believe it is in any way malicious, it is likely something that was set up years ago and simply forgotten.
Any ideas for how I could pinpoint where exactly this is coming from?
You will need to do this while you think the mystery program is running.
Open a Remote Desktop windows session on the actual SQL server since you are pretty sure that is where it is running.
Have TaskMgr.exe ready. Go to the “Details” tab so that you can search by TaskManager PID (not SQL PID) . Sort by this TaskMgr PID.
Right Click on the Columns at the top of this Details tab.. Choose “Select Columns”
Add this column …
Command line
While you think the mystery program is running run the following sql.
select x.host_process_id as USE_ME_TaskMgr_PID_OnClient_PC
, x.host_name as PCNameFromClient
, x.program_name as ProgNmFromClient
, x.client_interface_name
, x.original_login_name
, x.login_name
, x.nt_domain
, x.nt_user_name
, x.*
FROM sys.dm_exec_sessions x
order by x.host_name DESC
, x.program_name DESC
GO
Look at the first column of this sql. Find your mystery program in the list. Take the first value. This is the Program PID that will be the PID on the TaskMgr PID. Then you will see the command line full execution directory path.
By using something like sp_who you can find the hostname for each user connecting. Maybe that can give you a hint on where to look?

SQL Agent job - no results, yet stored proc works

I have a SQL Agent Job which claims to succeed, however doesn't ACTUALLY do what it is supposed to do. If I run the script inside on its own it does generate results.
I am using SQL 2014. The scrip used/inside the agent job is:
IF OBJECT_ID('TEMPDB..##RCCON','U') IS NOT NULL DROP TABLE ##RCCON
SELECT top 10 R.RC_C__ID as ConsentId
,dbo.clr_RC_CON(R.RC_CON__ID,'','') AS RC_CON
INTO ##RCCON FROM RC_CON R
The script works independently, but as a JOB yields no results.
Any suggestions please? Cheers
The ##RCCON evaporates when the SQL Agent Job is done. They only exist for the duration of the session.
Perhaps use [dbo].[RCCON] instead

How to tell when a SSRS Data Driven Subscription has finished running in SQL Server 2014

I have a report running against a Data Driven subscription in SSRS. The subscription runs a report and produces PDFs - about 1000 of them. The process takes about 2 minutes to complete.
I have been kicking this off manually using the following SQL:
EXEC msdb.dbo.sp_start_job #job_name = '<job_name>'
This works, but what I would like to know is when the job has finished. According to what I have read so far, I should be able to run:
exec msdb.dbo.sp_help_job
This lists my job, but it always has a status of 4 (Idle), even while I can see that reports are being produced.
How can I tell when the job has completed and all my reports have been produced?
MSDB shouldn't contain informtaion on the reporting server. The reporting server is seperate from Sql Server Management Server and will only tell you if the job ran or not not what happened in the job. If you have access to the DB I don't know how you have it set up but I have a subscriptions table that I can check with email sent and when it was sent. IF you don't have that you can go onto the reportserver web site and check the subscription and check the status and it should have a date of when it was last sent.
The only way you can access the information in Sql Server Management Studio is by queryng the DB and its tables assuming it is setup correctly.

Executing SQL functions

I'm not a programmer, so I need assistance with executing a SQL function in SQL Server 2000.
We have outsourced some work for an iPhone app which uses a web services located where I am. Everything is set-up correctly, but the outsourcing company has asked me to execute an SQL function on the database. I have no idea where to start with this.
This is the email they sent me, I received a txt file with the function in it:
1) Please execute SQL functions in your database that is written in the attached document i.e UDF.txt.
2) Some parameters are added in query string , these are accessed as a parameter in SQL query.
("ShowWhat") = To switch between two SQL query
("latitude") = Latitude
("longitude") = Longitude
("distance") = Distance of KM in which nearby ATM located.
("page") = For which page records user want to see. (Ex: Page 1)
("strPageSize")= Results will be displayed as per size limit parameter for records.
It sounds like you need to run a script against your SQL Server 2000 database.
Find and execute the shortcut for SQL Query Analyzer whereever the SQL Server tools are installed. Likely they're installed on the server loaded with SQL Server 2000.
Connect to the database instance. It could be an IP address or host name. i.e. "localhost"
Change the database using the dropdown in the toolbar. The screenshot below shows master. Change it to whatever target database you want this function created in.
*Open the script your vendor has supplied you by 'opening' the file/script. Alternatively you could copy/paste in the text into a new Query window.
Press F5 to run the script, or click the green triangle in the toolbar.
whatever SQL statements are in the file will be executed. Perhaps it's 1 or more CREATE or ALTER statements.

Resources