This tip is really simple but usefull if we're concatenating strings to write a Where clause. For example: DECLARE NVARCHAR @SQL = 'SELECT ... FROM ...' IF(@IDAluno IS NOT NULL) SET @SQL = @SQL + '' WHERE [IDAluno] = ' + CAST(@IDAluno AS NVARCHAR) A better solution would be something like this: SELECT ... FROM ... WHERE ([IDAluno] = @IDAluno OR @IDAluno IS NULL) A special thanks to Paulo Moreira for the advice ;) ......