title: Add a Column to a Table via Linq or Triggers in SQL
body: <p>The issue is like , I got two tables X &amp; Y. When records are added to table X , columns should be added to the table Y in parallel. </p>
  
  <p><a href="http://prntscr.com/3owqfe" rel="nofollow">http://prntscr.com/3owqfe</a>  &lt;-- Provides a clear Idea. </p>
  
  <p>I tried it with triggers , but seems like the triggers doesnt allow CREATE TABLE or ALTER  TABLE. Anyway as I'm using Linq , Im trying to achieve that via Linq. Any suggestions ?</p>
  
  <p>Edited: For the record the below trigger worked , but with an exception.</p>
  
  <pre><code>create trigger AddItemToCommon ON [SEP].[dbo].[ItemMaster]
  FOR INSERT 
  AS BEGIN 
  
  declare @PAYID varchar(max) 
  
  select @PAYID = payCode from INSERTED 
  
  ALTER TABLE [SEP].[dbo].[CommonPayrollItems] 
  ADD sampleCol varchar(max)
  
  END 
  </code></pre>
  
  <p>Anyway it will only run once because , there cannot be more than 1 column of the same name. But if I can retrieve the row values grom ItemMaster table , it's still possible with triggers. Which I tried to replace sampleCol with @PAYID which results in Syntax error. </p>