Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. sql temp table

sql temp table

Scheduled Pinned Locked Moved Database
databasetutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jashimu
    wrote on last edited by
    #1

    Hi all, How to create temp table with new column name from a existing table that has different column name. thanks

    modified on Wednesday, February 3, 2010 8:19 AM

    A L 2 Replies Last reply
    0
    • J jashimu

      Hi all, How to create temp table with new column name from a existing table that has different column name. thanks

      modified on Wednesday, February 3, 2010 8:19 AM

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      Easy

      select column1 as newname
      into #temp
      from oldtable
      where 1 = 2

      insert into #temp(newname)
      select column1
      from oldtable

      By creating an empty table you avoid locking a lot of the system tables in tempdb - ALL the time a select into is running the system tables in tempdb are locked, which prevents other users from creating temp tables.

      Bob Ashfield Consultants Ltd

      J 1 Reply Last reply
      0
      • A Ashfield

        Easy

        select column1 as newname
        into #temp
        from oldtable
        where 1 = 2

        insert into #temp(newname)
        select column1
        from oldtable

        By creating an empty table you avoid locking a lot of the system tables in tempdb - ALL the time a select into is running the system tables in tempdb are locked, which prevents other users from creating temp tables.

        Bob Ashfield Consultants Ltd

        J Offline
        J Offline
        jashimu
        wrote on last edited by
        #3

        I will have to try it then I will let you know. thanks for your help

        1 Reply Last reply
        0
        • J jashimu

          Hi all, How to create temp table with new column name from a existing table that has different column name. thanks

          modified on Wednesday, February 3, 2010 8:19 AM

          L Offline
          L Offline
          leckey 0
          wrote on last edited by
          #4

          Jashimu--you have been a member long enough to know not to use such a general message title. Please refresh yourself with the forum guidelines if needed!

          Back in the blog beatch! http://CraptasticNation.blogspot.com/[^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups