title: Moving table from one database to another with primary key and other keys
body: <p>I want to move all the table from one database to another with primary key and all other keys
  using SQL queries. I am using SQL Server 2005 and I got a SQL queries to move the table but the keys are not moved.</p>
  
  <p>And my queries is as follows</p>
  
  <pre><code>set @cSQL='Select Name from SRCDB.sys.tables where Type=''U''' 
  
  Insert into #TempTable
  exec (@cSQL)
  
  while((select count(tName) from #t1Table)&gt;0)
  begin
      select top 1 @cName=tName from #t1Table
      set @cSQL='Select * into NEWDB.dbo.'+@cName+' from   SRCDB.dbo.'+@cName +' where 1=2'
      exec(@cSQL)
      delete from #t1Table where tName=@cName
  end
  </code></pre>
  
  <p>where SRCDB is the name of source database and NEWDB is the name of destination database</p>
  
  <p>How can I achieve this..?</p>
  
  <p>Can anyone help me in this...</p>
  
  <p>Thank you...</p>