0

I'm working on an SQL-Server database.

Regularly, entries from one table get moved to another one (from entries to Log_Entries) in order not to flood the database. (The Log_Entries get cleaned afterwards too)

I would like to know how this works, but I don't find any corresponding entry in the "Stored Procedures" or "Functions" and there seem not to be any "Database Triggers". Also the "Rules" part of the database seems to be empty.

Which entry in the database can be responsible for such a task?

Edit after first comment
I have "Database Diagrams", "Tables", "Views, "External Resources", "Programmability", "Service Broker", "Storage" and "Security".
Within "Programmability" there are "Stored Procedures", "Functions", "Database Triggers", "Assemblies", "Types", "Rules", "Defaults" and "Sequences".

Where is that SQL Agent?

Thanks in advance

asked Mar 17, 2022 at 9:04
5
  • 2
    SQL Agent Job maybe? Commented Mar 17, 2022 at 9:16
  • @DenisRubashkin: where can I find those? (I've edited my question accordingly) Commented Mar 17, 2022 at 9:23
  • 2
    View a Job Commented Mar 17, 2022 at 9:39
  • The SQL Agent is at the end of the list of "folders" in SSMS. If you don't see it, that means your account doesn't have permissions to SQL Agent, and you'll need further access granted by someone who has SysAdmin access. At a minimum you need the SQLAgentUserRole granted. Commented Mar 17, 2022 at 11:58
  • 1
    Previously you were using SQL Server Express - which does not support the Agent. Have you simply tried ASKING people who are familiar with this database and the system in which it is a part? This logic might be containined within a program - so you can't "find" it within the server instance at all. Commented Mar 17, 2022 at 12:21

1 Answer 1

1

You can find if there's a job that refers to a specific table using this query:

SELECT j.name,
 s.database_name,
 s.command
FROM msdb.dbo.sysjobsteps s
 INNER JOIN msdb.dbo.sysjobs j
 ON s.job_id = j.job_id
WHERE s.command LIKE '%TableName%' 
 AND s.database_name LIKE '%DatabaseName%';

It's not 100% safe method though as your job might refer to a stored procedure which refers to the table. Yet, I recommend using it since you could be lucky enough to find the job you're looking for and save time going through each job manually.

answered Mar 17, 2022 at 11:31
2
  • It's a good attempt, but I didn't find what I was looking for (there were only some "purge" related jobs). Commented Mar 17, 2022 at 12:56
  • @Dominique, you could use one approach like these to find what's causing the changes. But you're gonna have to adapt them to capture the delete/truncate on the table Log_Entries, for example. Commented Mar 17, 2022 at 13:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.