Sweetie
Sweetie

Reputation: 1368

Creating scalar functions in SQL Server

I have come across a situation where functions are very helpful. I can create it using its syntax and then I would use them in select or procedures.

But recently I have found that a function is called automatically when a row is inserted or updated. Also it is accepting two parameters. This user-defined scalar function is neither called in C# through ORM and moreover there is no stored procedure using this function, yet it is being called and as per my assumption, this setting must be in a table itself. It is triggered automatically when a row is updated or inserted.

Can somebody please throw some light on this as I have never encountered it before. An example of it would really be helpful that how it is created and how we can call this function.

Upvotes: 1

Views: 220

Answers (1)

Reboon
Reboon

Reputation: 578

You can install SQL RedGate Search (it's free) which allows you to search all SQL objects to find where your functions has been used:

http://www.red-gate.com/products/sql-development/sql-search/

enter image description here

Also possible is that you make a trace on that function to see where it has been called from (or at least by who):

How to trace T-SQL function calls

Upvotes: 2

Related Questions