troubleshooting Question

Could you point a way to save a select result in a new table by using MSSQLServer?

Avatar of Eduardo Fuerte
Eduardo FuerteFlag for Brazil asked on
Microsoft SQL Server
4 Comments1 Solution18 ViewsLast Modified:
Hi Experts

Could you point a way to save a select result in a new table by using MSSQLServer?

Accordingly to:

My attempts (no success)
Select * Into MC1_CityZipCodeExt_LAB_NOVO  -- new table to receive the results
FROM
SELECT
  y.lIdState  as lIdState, --  lIdState
  LOC_NU,  --  cIdCity
  LOC_NO,  --  cNameCity
  UFE_SG,  --  cCodeState
  CEP,      -- cZiCode
  1 as mc1Enabled,        -- mc1Enabled
  CURRENT_TIMESTAMP as mc1LastUpdate, --mc1LastUpdate
  'novo' as condicao
FROM LOG_LOCALIDADE_OK t
LEFT JOIN MC1_StateZipCodeExt y ON  t.UFE_SG = y.cState
WHERE NOT EXISTS (SELECT NULL
                  FROM MC1_CityZipCodeExt x
              WHERE x.cIdCity = t.LOC_NU
              AND   x.cCodeState = t.UFE_SG
              AND   x.cZiCode = t.CEP
                  )
AND t.CEP IS NOT NULL
and
SELECT
  y.lIdState  as lIdState, --  lIdState
  LOC_NU,  --  cIdCity
  LOC_NO,  --  cNameCity
  UFE_SG,  --  cCodeState
  CEP,      -- cZiCode
  1 as mc1Enabled,        -- mc1Enabled
  CURRENT_TIMESTAMP as mc1LastUpdate, --mc1LastUpdate
  'novo' as condicao
FROM LOG_LOCALIDADE_OK t
LEFT JOIN MC1_StateZipCodeExt y ON  t.UFE_SG = y.cState
WHERE NOT EXISTS (SELECT NULL
                  FROM MC1_CityZipCodeExt x
              WHERE x.cIdCity = t.LOC_NU
              AND   x.cCodeState = t.UFE_SG
              AND   x.cZiCode = t.CEP
                  )
AND t.CEP IS NOT NULL
Into MC1_CityZipCodeExt_LAB_NOVO 

Thanks in advance
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros