Reputation: 1571
I have a set of stored procedures that are stored in one database and all refer to tables in another database to snapshot data. They have a structure broadly like this (the actual queries are more complicated, but this reflects the database usage):
USE [Database_A]
GO
INSERT [Database_A].[dbo].[MyTable]
SELECT *
FROM [Database_B].[dbo].[YourTable]
When applying a column filter to the SQL server profiler, in order to see everything these queries are doing, should I filter on Database_A or Database_B or both?
It says "Name of the database in which the statement of the user is running", but are there parts of the above style of query running in each?
Upvotes: 1
Views: 453
Reputation: 46193
A statement runs in the context of a single database even if the referenced objects are in other databases. The database name will be Database_A for events such as SQL:BatchCompleted and SQL:StmtCompleted in your example. However, more granular events like SP:StmtCompleted will show the database name of the stored procedure containing the statement.
Upvotes: 2