Mistři v programování na #hovnokod

SQL #374

ALTER PROCEDURE [dbo].[SomeProc]       
      
(      
 @TableName Varchar(500),      
 @Condition Varchar(1000)      
)      
--================================================================      
-- Stored procedure:  SomeProc      
-- Description: Returns rows depending on a dynamic condition      
--      
-- Inputs:        
--      
-- Returns:      
--      Recordset 1: UserID, Name      
--      
--================================================================      
      
AS      
BEGIN      
DECLARE @StrQuery varchar(1000)      
  
If charindex('[Tablename]',@tablename) > 0  
begin
 print 'new'
 SET @StrQuery = 'Select * From ' + @TableName + ' Where ' + @Condition   
 print @tablename
 print @condition
 print @strquery
end
else      
 SET @StrQuery = 'Select * From ' + @TableName + ' Where ' + @Condition + ' And [Tablename] = 1'      
      
Exec(@StrQuery)      
END

HovnoKod,