I have a value in a table that was changed unexpectedly. The column in question is CreatedDate
: this is set when my item is created, but it's being changed by a stored procedure.
Could I write some type of SELECT
statement to get all the procedure names that reference this column from my table?
You need to query Mysql. proc table, here's the documentation: The mysql. proc table contains information about stored procedures and stored functions.
IF EXISTS(SELECT 1 FROM sys. columns WHERE Name = N'Name' AND Object_ID = Object_ID(N'dbo. SampleTable')) SELECT 'Column exists in table' AS [Status] ; ELSE SELECT 'Column does not exist in table' AS [Status]; You can see in below result, column Name exists in table.
One option is to create a script file.
Right click on the database -> Tasks -> Generate Scripts
Then you can select all the stored procedures and generate the script with all the sps. So you can find the reference from there.
Or
-- Search in All Objects SELECT OBJECT_NAME(OBJECT_ID), definition FROM sys.sql_modules WHERE definition LIKE '%' + 'CreatedDate' + '%' GO -- Search in Stored Procedure Only SELECT DISTINCT OBJECT_NAME(OBJECT_ID), object_definition(OBJECT_ID) FROM sys.Procedures WHERE object_definition(OBJECT_ID) LIKE '%' + 'CreatedDate' + '%' GO
Source SQL SERVER – Find Column Used in Stored Procedure – Search Stored Procedure for Column Name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With