My application cannot execute a stored procedure in SQL Server - sql

I have a new AlwaysOn environment where we've moved an old SQL Server 2008 replication databases. I have replication working between the two environments and when I do a manual failover it works wonderfully.
The problem that I'm having with this is that the application cannot execute the stored procedure. We're tested both the SQL Server 2008 as well as the new SQL Server 2012 edition. The stored procedure works as it has been for years and nothing has changed on it.
I've also did another test while running the application job to create the document and used profiler to find the differences in the two. What I've found is that within the first SQL Server 2008 environment is that I see where the stored procedure is getting executed, as well as the results that getting stored in the tables. With the SQL Server 2012 Profiler results I don't see the same stored procedure execution. More on those line the only thing that I really see is where the statement should be executing. At the end of the profiler I do however see where a statement, that get by mail, executes and stats that "null values are no allowed in a column where nulls are not allow" . This is a true statement. The column does not allow null values. I have double checked the permission and everything matches up.
So my question is why can't the application not execute the stored procedure?
Error is:
Here is the error that we are getting with this process. Error: Error:
PS Auto Changes Process Model. Service Task failed PS Auto
Changes,version 60 : Instance ID 37486 Review Change node :
StoredProcedureServiceTask, SQL Server Exception: Cannot insert the
value NULL into column 'jobID', table
'Docfinity10_Reporting.dbo.TFBAudit_BPMJobInfo'; column does not allow
nulls. INSERT fails.

Related

SSIS SQL Executation Task error: unable to run some sql queries

I'm working to make some fact tables (taking some data from some resources, doing some transformations and putting them in a table). My main dilemma is that I can't run any SQL query other than select, update, and insertion. As soon as i try:
exec someProcedure
or a conditional statement (if #part1 ...) or even (create table ...) I take errors. Opening the task to build my SQL statements and find problems it gives errors ranging from (The Set SQL construct or statement is not supported.) to (The EXEC SQL construct or statement is not supported.).
I looked for numerous topics here on stackoverflow but none were actually addressing me problem.
Thanks,
You can see a view of what I'm facing in this picture :
I expect to run my SQL commands as usual in SSIS.
Try changing the SQL Source Type from Direct Input to Stored Procedure and just specify the stored procedure name instead of Exec stored procedure
Also make sure that you have selected the relevant TargetServerVersion from the project configuration:
How to change TargetServerVersion of my SSIS Project
Based on your comments, you are using SQL Server 2012 with Visual Studio 2010 which are not compatible.
You have to use Visual Studio 2012 or 2015+ (backward compatibility added). You can refer to the SSIS tag wiki for more info:
https://stackoverflow.com/tags/ssis/info

Getting "The parameter is incorrect" when adding more than One table to DB Diagram

Using SQL SERVER 2016, Getting The parameter is incorrect exception when adding more than One table to DB Diagram. Behavior is as if there is a limit of only 1 table allowed. I've tried repairing both SQL SERVER 2016 and SSMS. After multiple reboots, still can not add more than one table to a DB Diagram. My OS is Windows 10.

Copy records from current day between tables on different databases

As the title says, I want to copy all of the current days records from our production database to our development database. I have view access to the production database and db_owner rights to the development database. I'm writing a stored procedure that looks for the current days data, so I need to update the development data with the current days data from our production server. Here is what I've come up with so far:
use DatabaseProd
DECLARE #i_DateCurrent DATETIME;
SET #i_DateCurrent = CONVERT(DATETIME,CONVERT(DATE,GETDATE()));
insert into DatabaseDev..dbo.Table_1
select * from dbo.TableProd
where date_received >= #i_DateCurrent
AND date_received < DATEADD(DAY,1,#i_DateCurrent)
I'm getting the following error:
Msg 7202, Level 11, State 2, Line 4
Could not find server 'ServerDev' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers.
When I check the sys.servers table, there is only one row and it is just the Production server.
I tried using sp_addlinkedserver but it gives me
Msg 15247, Level 16, State 1, Procedure sp_MSaddserver_internal, Line 29
User does not have permission to perform this action.
So, my question is: Is there any other way to do this that doesn't require more permissions on the production server? I'd prefer a T-SQL statement since I will be doing this for awhile but if there is another way, I can do it too. The databases I'm using are both MS SQL server 2008 R2.
This is too long for a comment.
One the development server, create a linked server to the production server. This should give you read access to everything that you need access to.
Then, do the work on the development server. After all, that is a safer place to run scripts than on the production server.
Other than the obvious SSIS, I might suggest using OPENROWSET as you appear to have persmissions to both. MSDN OpenRowset

How to determine which stored procedures are being executed (MSSQL 2008 R2)

I'm having a real problem with my application and SQL Server (2008 R2).
I have a bug whereby a stored procedure is failing because of a misconfigured SQLCMD variable but the call to the stored procedure is in an assembly for which I don't have the source code.
Is there a way to watch which stored procedures are being executed? Or is there a way to determine with an SQL query which stored procedures have been executed and when?
I am really stuck. Please help!
M
You could try running this against your database:
select OBJECT_NAME([object_id], database_id), last_execution_time, execution_count
from sys.dm_exec_procedure_stats
order by last_execution_time desc
Documentation: http://msdn.microsoft.com/en-us/library/cc280701.aspx
That gives you a snapshot at the time of execution what was last run and how many times it's been executed since it was last compiled. The table doesn't unfortunately give a log per-se of the stored procedures getting run, just when they were run last and some other helpful information.
Fore a much more involved approach, you could look at SQL Server Audit, a new feature to SQL Server 2008. I don't have much experience with it, but this should give you a starting point if you're super stuck.

SQL Azure: sp_helptext gives non-runnable source code

When trying to automate reading out constraint information using sp_helpconstraint I got the bright idea of pulling out the source code of the built-in SP directly and run it myself (since it returns multiple result sets so those can't be stored in a temp table). So I ran exec sp_helptext 'sp_helpconstraint' (on SQL Azure) to generate the source code, and copied it into a new query window.
However, when I run the SP (on SQL Azure), I get lot's of error messages -- for example, that object syscomments doesn't exist even though I am using the exact same source that runs perfectly when calling sp_helpconstraint directly. Just to make sure it wasn't an anomaly with the procedure or a mistake in my copy/paste execution, I tested the exact same procedure on SQL Server 2008, and if I directly copy the SP source into a new query window, it runs perfectly (obviously after removing the return statements and manually setting the input parameters).
What gives?? Do built-in SP's run in a special context where more commands are available than normal on SQL Azure version? Is sp_helptext not returning the actual source that is being run on SQL Azure?
If you want me to try anything out, give a suggestion and I can try it on our SQL Azure Development instance. Thanks!