June 27, 2011 at 5:20 am
Hi
I wanna to execute following code :
SELECT COUNT(*) FROM
STR.GoodsPlace INNER JOIN STR.GoodsPlace.StoreDivisionID=STR.StoreDivision.StoreDivisionID
WHERE (STR.GoodsPlace.GoodsID = @GoodID)
AND @DBName.dbo.TypesSec_GetPermission(@UserId,StoreId)=1
i want to use the result of a function of another database in where clause that i will pass the database's name from my C# program as parameter
how can i do it?
plz help me as soos as possible
thank you veru much
June 27, 2011 at 5:34 am
You need sp_executesql.
June 27, 2011 at 2:36 pm
Why would you have the same function in multiple databases that do different things?
Or, do you have a single database that contains these functions but you do not know the actual name of that database until run-time?
Since this is just a function, wouldn't it be better to create the function in the database where it is going to be run?
Anyways, if this is a single database that contains generic utility functions - and it can be named differently on different host systems I would recommend you take a look at synonyms. With a synonym, you can code your procedure to use the synonym and just update the synonym in each database to point to your utility database.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply