title: insert stored procedure, check if row exists
body: <p>I am using sql server 2005 and want to insert a row into a database table, however i am getting an incorrect syntax at values. and also i want to make sure what i am adding already doesnt exist i think this is right but i have that one syntax error.</p>
  
  <pre><code> create PROCEDURE [dbo].[directway]
             @tour as varchar(50),
             @tourname as varchar(50),
             @taskname as varchar(50) ,
             @deptdate as varchar(50),
             @tasktype as varchar(50)  ,
             @desc as varchar(50) ,
             @duedate as varchar(50) ,
             @agent as varchar(50),
             @graceperiod as varchar(50)
  AS
  BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;
  
  
  INSERT INTO dashboardtasks
             ([tour]
             ,[tourname]
             ,[taskname]
             ,[deptdate]
             ,[tasktype]
             ,[desc]
             ,[duedate]
             ,[agent]
             ,[graceperiod]
  
       VALUES (@tour,
             @tourname,
             @taskname ,
             @deptdate,
             @tasktype  ,
             @desc ,
             @duedate ,
             @agent ,
             @graceperiod
                    )
  WHERE  NOT EXISTS(SELECT *
                    FROM   dashboardtasks
                    WHERE  ( @tour = dashboardtasks.tour
                             and @taskname = dashboardtasks.taskname
                             and @deptdate = dashboardtasks.deptdate
                             and @duedate = dashboardtasks.duedate
                             and  @tourname = dashboardtasks.tourname
                           and @agent = dashboardtasks.agent
                           )
  )  
  
  END
  </code></pre>