Rupesh
Rupesh

Reputation: 1043

SQL stored function call from vb.net

I had a stored function created in SQL Server. When I try to call that from vb.net with command text like...

---- Returning error
lobjCommand.CommandText="Select function_name(value1)"

----- Executing properly without errors    
lobjCommand.CommandText="Select dbo.function_name(value1)" 

Can someone suggest what exactly the dbo playing the magic...

Thanks in advance Rupesh

Upvotes: 0

Views: 1300

Answers (2)

Rashmi Kant Shrivastwa
Rashmi Kant Shrivastwa

Reputation: 1157

The SQL Server engine always parse the query into pieces, if you don't use the prefix definitely it going search for object in similar name with different users before it uses [dbo]. I would suggest you follow the prefix mechanism not only to satisfy the best practices, also to avoid performance glitches and make the code scalable.

old question asked refer this link

Upvotes: 0

Curtis
Curtis

Reputation: 103348

dbo is most likely your default schema. It stands for Database Owner.

When running functions in your SQL queries you need to specify the schema that the function belongs to.

If you don't then there could be two different functions with the name function_name belong to two different schemas. Without mentioning the schema, the server won't know which function you are calling.

Upvotes: 1

Related Questions