Search code examples
sql-servertemp-tables

Updating SQL Table for a temptable


I have a SQL table that gets all the data from a temptable. I would like to add a column into the temp table. How can i update my sql table? Thanks.

ps: #Sonuc is my temp table and ANALIZ.dbo.HizliSatanOptionRaporu2_v1 is permanent.

select hr.STORECODE,
        s.StoreDescription,
        s.StoreAtt04 AVMCadde,
        s.StoreAtt05 SezonOutlet,
        s.StoreAtt06 SesGrup,
        s.StoreAtt07 Brands,
        s.StoreAtt25 MeteorYaz,
        s.StoreAtt26 MeteorKis,
        s.StoreAtt27 StoreGrade,
        s.StoreAtt28 MusteriProfili,
        s.CityDescription Sehir,
        s.StateDescription Bolge,
       Division,
       Department,
       SubDepartment,
       Category,
       Class,
       ItemCode,
       ColorCode,
       LEFT(ItemCode,2) Sezon,
       ItemCode+ColorCode [Option],
       ToplamStok,
       ToplamSatis,
       case when ToplamSatis=0 then 0 else 1 end SatisVarMi,
       SDH,
       Att_Basic,
       BasicOlmaDurumu,
       Sorun,
       hr.ProductHierarchyID,
       GETDATE() as SonGuncellemeTarihi 
       into #Sonuc
      from #HiyerarsiID hr 
      join ANALIZ.dbo.tb_ProductHierarchy ph on hr.ProductHierarchyID = ph.ProductHierarchyID
      inner join ANALIZ.dbo.gg_StoreInfo s on s.StoreCode=hr.StoreCode


select * 
into ANALIZ.dbo.HizliSatanOptionRaporu2_v1
from #Sonuc

Solution

  • Just do it like a normal table.

    alter table #tempTable add column int