title: t-sql create user and grant execute on permission for stored procedures
body: <p>I have a script which creates a database, stored procs, views, tables, udf. I want to include a script to create a user 'user_1' and give execute permission on the database. </p>
  
  <p>I tried following to create grant exec command for all stored procs</p>
  
  <pre><code>declare @permission varchar(max)
  
  select @permission = COALESCE(
      @permission + '; ' + 'Grant Execute on ' + name +  ' user_1', 
     'Grant Execute on ' + name +  ' user_1')
  from sysobjects where xtype in ('P')
  
  exec (@permission)
  </code></pre>
  
  <p>But <code>exec (@permission)</code> does not work. It gives </p>
  
  <blockquote>
    <p>incorrect syntax near ';'. </p>
  </blockquote>
  
  <p>How can I solve this?</p>