title: N''' prefix is added by default while executing Stored Procedure
body: <p>While executing stored procedure, I'm passing 4 arguments. After passing the arguments through GUI mode, I'm seeing that some prefixes has been added by the sql itself.</p>
  <pre><code>USE [du_Attendance]
  GO
  
  DECLARE @return_value Int
  
  EXEC    @return_value = [dbo].[GET_ATTENDANCE_REPORT_FOR_FACULTY]
          @startdate = '1/9/2018',
          @enddate = '1/12/2018',
          @coursecode = N'''BSCCS''',
          @subjectcode = N'''CSHT101'''
  
  SELECT  @return_value as 'Return Value'
  
  GO
  </code></pre>
  <p>So when I am removing the N'', it's giving me an error saying Invalid column name 'BSCCS'. What does it mean ?</p>
  <p>Full Stored Procedure -</p>
  <pre><code>CREATE PROCEDURE GET_ATTENDANCE_REPORT_FOR_FACULTY
  @startdate DATE,  
  @enddate DATE,
  @coursecode varchar(10),
  @subjectcode varchar(10)
  
  
  AS BEGIN
  
  DECLARE @cols as varchar(2000);
  DECLARE @cols_select as varchar(MAX);
  declare @col varchar(20)
  declare @cols_copy varchar(100)
  DECLARE @query as varchar(MAX);
  
  WITH cte (startdate)
  AS 
  (SELECT
          @startdate AS startdate
      UNION ALL
      SELECT
          DATEADD(DD, 1, startdate) AS startdate
      FROM cte
      WHERE startdate &lt; @enddate
  )
  select c.startdate
  into #tempDates
  from cte c
  where datename(weekday, c.startdate) &lt;&gt; 'Sunday';
  
  SELECT
      @cols = STUFF((SELECT DISTINCT ',' + QUOTENAME(CONVERT(CHAR(6),startdate, 106))
          FROM #tempDates
          FOR XML PATH (''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '')
  
  select @cols_copy = replace(@cols, ',', '')
  
  select @cols_select = SUBSTRING(@cols_select, 2, len(@cols_select) - 1)
  
  
  SET @query = 'SELECT RollNo,FirstName,LastName, ' + dbo.fn_convert_cols(@cols) + ' from 
               (
                  select S.RollNo,U.FirstName,U.LastName,
                  D.startdate,
                  convert(CHAR(6), startdate, 106) PivotDate
                  from #tempDates D,Attendance A, Student S, UserDetails U
                  where convert(CHAR(6), D.startdate, 106) = convert(CHAR(6), A.Date, 106) and A.EnrollmentNo=S.EnrollmentNo and A.EnrollmentNo=U.userID and A.CourseCode=' + @coursecode + ' and A.SubjectCode =' + @subjectcode + '
              ) x
             pivot 
             (
                  count(startdate)
                  for PivotDate in (' + @cols + ')
             ) p '
  
  EXECUTE (@query)
  drop table #tempDates
  END
  </code></pre>
  <p>The problem with this is I am passing the parameters from C# code so only 'BSCCS' is passed into the stored procedure resulting in the above mentioned error.</p>
  <p>C# Code -</p>
  <pre><code>SqlConnection con = new SqlConnection(connectionString);
  SqlCommand cmd = new SqlCommand(Constants.getAttendanceForFaculty, con);
  cmd.CommandType = CommandType.StoredProcedure;
  cmd.Parameters.AddWithValue(&quot;@startdate&quot;, startdate);
  cmd.Parameters.AddWithValue(&quot;@enddate&quot;, enddate);
  cmd.Parameters.AddWithValue(&quot;@coursecode&quot;, courseCode);
  cmd.Parameters.AddWithValue(&quot;@subjectcode&quot;, subCode);
  DataTable dt = new DataTable();
  con.Open();
  SqlDataAdapter da = new SqlDataAdapter(cmd);
  da.Fill(dt);
  con.Close();
  </code></pre>