CREATE PROCEDURE Ewdataviewlink
(@sTable VARCHAR(100),
@sLnkFld VARCHAR(100),
@sDispFld VARCHAR(100),
@sDispFld2 VARCHAR(100),
@sFilterFld VARCHAR(100),
@sOrderBy VARCHAR(100),
@sOrderType VARCHAR(100),
@bDistinct AS BIT,
@sFilter VARCHAR(100))
AS
DECLARE @sSql VARCHAR(500)
-- Construct@sQL@statement
SET @sSql = 'SELECT'
IF bdistinct
BEGIN
SET @sSql = @sSql + ' DISTINCT'
END
SET @sSql = @sSql + ' [' + @sLnkFld + '], [' + @sDispFld + ']'
IF @sDispFld2 <> ''
BEGIN
SET @sSql = @sSql + ', [' + @sDispFld2 + ']'
END
IF @sFilterFld <> ''
BEGIN
SET @sSql = @sSql + ', [' + @sFilterFld + ']'
END
SET @sSql = @sSql + ' FROM [' + @sTable + ']'
IF @sFilter <> ''
BEGIN
SET @sSql = @sSql + ' WHERE ' + @sFilter
END
IF @sOrderBy <> ''
BEGIN
SET @sSql = @sSql + ' ORDER BY [' + @sOrderBy + '] ' + @sOrderType
END
EXEC(@sSql)
|