Filter by value or show all if no value I have 2 tables: records and access_rights

Access table has list of permission for certain and should be used to filter records based on rules: 


function field is mandatory
object field is optional. if it`s empty do not apply filter else filter by value
All rules should work in one query. Please see example of expected output and SQL Fiddle data.

| ID |   FUNCTION |   OBJECT | SUM |
|----|------------|----------|-----|
|  1 | Function 1 | Object 1 | 900 |
|  4 | Function 1 | Object 2 | 750 |
|  5 | Function 2 | Object 2 | 200 |



Thanks in advance!

SQL Fiddle

MS SQL Server 2008 Schema Setup:

CREATE TABLE records (
  [id] int NOT NULL PRIMARY KEY,
  [function] varchar(100),
  [object] varchar(100),
  [sum] money
  );

INSERT INTO records VALUES
(1, 'Function 1', 'Object 1', 900),
(2, 'Function 2', 'Object 1', 600),
(3, 'Function 3', 'Object 1', 800),
(4, 'Function 1', 'Object 2', 750),
(5, 'Function 2', 'Object 2', 200),
(6, 'Function 3', 'Object 2', 500);

CREATE TABLE access_rights ( 
  [id] int NOT NULL PRIMARY KEY,
  [user] varchar(50),
  [function] varchar(100),
  [object] varchar(100)
  );

INSERT INTO access_rights VALUES
(1, 'User', 'Function 1', ''),
(2, 'User', 'Function 2', 'Object 2');


Query 1:

SELECT * FROM records WHERE 
[records].[function] in 
(SELECT "function" FROM access_rights where "user"='User'  )


Results:

| ID |   FUNCTION |   OBJECT | SUM |
|----|------------|----------|-----|
|  1 | Function 1 | Object 1 | 900 |
|  2 | Function 2 | Object 1 | 600 |
|  4 | Function 1 | Object 2 | 750 |
|  5 | Function 2 | Object 2 | 200 |
I'd recommend reading Erland Sommarskog's "Dynamic Search Conditions" post here

In your case, here's a fiddle with the pattern:
SQL Fiddle

For posterity, here's the code:

SELECT * 
FROM records r
WHERE 
EXISTS (
  SELECT 1 
  FROM access_rights a
  WHERE r.[function] = a.[function]
  and a.[user] = 'user'
  AND (A.[object] = r.[object] or a.[object] = ''))


Also, please stop using reserved words as column names.