tags:

views:

29

answers:

1

Let's say I have the following two tables:

Fields

FieldID INT
FieldName NVARCHAR(50)

Values

FieldID INT
Value NVARCHAR(1000)

From the following stored procedure, how can I select only the values that are linked to a field which has the same FieldName than the one received as a parameter?

CREATE PROCEDURE [dbo].[GetValues]
@FieldName NVARCHAR(50)

AS SELECT * FROM [dbo].[Values]
WHERE ... ?
+4  A: 
Select ...
From Fields As F
    Join Values As V
        On V.FieldID = F.FieldID
Where F.FieldName = @FieldName
Thomas
Well that turned out to be simpler than I thought. Thanks.
asmo