No insert happens on linked server Express version when Agent Job activates stored procedure from linked Enterprise version server - sql

Using SSMS with linked servers. Have stored procedure in Express version that performs a table insert. When the stored procedure is run locally, the table insert works.
When I run an Agent Job executing the stored procedure from the linked Enterprise version, the table insert does not happen. Linked servers are set up properly - I have all permissions turned on for both target table and stored procedures.

Related

Can I execute a stored procedure every month automatically without creating a job?

I do not have access to SQL Server Agent and would like to execute a stored procedure monthly from SQL Server Management Studio 14. I am trying to insert the syntax for a stored procedure that will ensure it will be executed anytime I log into the client.
How would I do this?

Running Stored Procedure in SSIS Child package, SQL Server 2012

I can run the child package on its own just fine. Package runs, stored procedure fires and updates a table as expected (stored procedure is aggregating some data and updating a second table with the results).
When I run it from its parent package the stored procedure appears to execute (I can see it in SQL Server profiler) however the table is not updated by the procedure. Other tasks within the child package run fine, both when the child package is run on its own and when run by parent.
This is running by SQL Server Agent job, deployed on SQL Server 2012. If I run the parent-child in Visual Studios, the stored procedure fires and the table is updated.
Seems that the stored procedure is not running when deployed. Any suggestions on how to troubleshoot this?

SQL Server stored procedure, exec from another query

I'm learning SQL and I've got some problems calling a stored procedure from a new/different query.
I has build a installDB.sql file where there are created some tables and additionally filled these with data.
Furthermore I use a stored procedure as well, to add some functions.
Example:
CREATE PROCEDURE Add_Book
#User CHAR(50),
#Book CHAR(50)
AS
INSERT INTO Relationtable(book_id, user_id, current_dato)
VALUES(
(SELECT book_id FROM Books WHERE book_title = #Book),
(SELECT user_id FROM Users WHERE user_name = #User),
GETDATE()
)
In this query (tab) I can exec that procedure (without problems):
exec Add_Book myUser, myBook
But if I try this command in a new query (tab), it doesn't work.
I want the installDB to build all my functions and be able to call them later from another queries.
Is this possible?
We use this method to setup and maintain databases in our product. We have many separate SQL scripts that install all the required tables, tempdb tables, views, functions, stored procedures, etc. Later, when people run code that executes those stored procedures, the procs can be executed like normal.
If this install script is running in a transaction and ends in a ROLLBACK or encounters an error, everything installed to that point will fail. Similarly, if the install script began with a BEGIN TRAN, and there was no COMMIT, then the procs don't exist yet.
Another possibility is that the install script ran against a different database or different server than you expected. After running the script, you should be able to execute it in a Microsoft SQL Management Studio query window.

SQL Server runs SP on startup - where's the magic?

We have several SQL Server 2008 R2 environments (dev, QA, Production) with databases for an ASP.NET application.
This applicaton uses ASP.NET membership and SQL Server session providers, thus we have an ASPState database.
The functionality of these providers were extended to restrict one active session per login. Our implementation added tables to TempDB, a stored proc ASPState.dbo.CreateTempTables to create these tables, and another stored proc Master.dbo.ASPState_Startup which calls the SP in ASPState.
On my dev machine and in production, when SQL Server is started Master.dbo.ASPState_Startup is executed and the tables are created.
I am setting up a new QA environment and cannot figure out how that happens (so in QA, the tables are not added to TempDB on startup). I have compared schema and permissions manually and via Red Gate's compare tool and find no differences there.
I checked the jobs and none call either of these stored procs.
Any ideas of where the magic is hiding?
Thanks,
Scott
sp_procoption is the "magic":
Sets or clears a stored procedure for automatic execution. A stored procedure that is set to automatic execution runs every time an instance of SQL Server is started.
EXEC sp_procoption #ProcName = 'ASPState_Startup'
, #OptionName = 'startup'
, #OptionValue = 'on';

Stored Procedure stopped working

I have a stored procedure that I'm positive of has no errors but I recently deleted the table it references but imported a backup with the same name exactly and same column settings (including identity) that the previous one had but now it doesn't work.
Is there any reason that having deleted the table but importing a new would break the stored procedure?
BTW: Running Microsoft SQL Server Express Edition w/ IIS.
you can try to recompile the stored procedure with:
exec sp_recompile YourProblemTableNameHere
this will recompile all procedures that use the YourProblemTableNameHere table. But that is just a guess based on the very limited info given.