• this is the normal query

    through this we will come to know whiether the records exists or not in the table

    if EXISTS(SELECT Sr_No FROM #Temp_Table_Col WHERE Sr_No = @iIndexCol)

    BEGIN

    SELECT Sr_No FROM #Temp_Table_Col WHERE Sr_No = @iIndexCol

    END

    my questions

    i want to check the record exists or not in the table then execute the query

    through following syntax but it gives an error

    SET @sqlquery = N'SELECT ' + CHAR(39) +@TableName + CHAR(39) + ' AS TableName,* FROM [' + @TableName + '] WITH (NOLOCK) WHERE [' + @ColumnName + ']= ' + CHAR(39) + @Value + CHAR(39)

    if EXISTS(SP_EXECUTESQL @sqlquery)

    BEGIN EXEC SP_EXECUTESQL @sqlquery

    END

    i am assign the query into one variable and then executing it through EXEC SP_EXECUTESQL but before executing the query i want to check the record exists for the build up query

    hope you got it.....

    Patel Mohamad