I need to pass 2 parameters to a function, one with be a guid I use to query a table to get the database I need to look in, then other will be another guid value I need to find the description of.
I am trying to do something like this:
Create Function [dbo].[get_Description] (@DB_GUID varchar(36), @Value_GUID varchar(36))
RETURNS VarChar(50)
AS
Begin
declare @db_path varchar(36)
declare @Value_Description varchar(36)
SELECT @db_path = DB_Path 'FROM Databases where db_guid = @DB_GUID
SELECT @Value_Description = description from @db_path.dbo.table_of_descriptions WHERE (Value_GUID = @Value_GUID )
return @Value_Description
End
It is obviously failing on the 2nd select where I am trying to pass the DB_path to set the database I require the statement to look at.
Any assistance would be great, and thanks in advance.
I am trying to do something like this:
Create Function [dbo].[get_Description] (@DB_GUID varchar(36), @Value_GUID varchar(36))
RETURNS VarChar(50)
AS
Begin
declare @db_path varchar(36)
declare @Value_Description varchar(36)
SELECT @db_path = DB_Path 'FROM Databases where db_guid = @DB_GUID
SELECT @Value_Description = description from @db_path.dbo.table_of_descriptions WHERE (Value_GUID = @Value_GUID )
return @Value_Description
End
It is obviously failing on the 2nd select where I am trying to pass the DB_path to set the database I require the statement to look at.
Any assistance would be great, and thanks in advance.