November 2, 2015 at 9:21 am
I'm trying to create a new table while referencing other columns from another table in another database. Could please tell me what I'm doing wrong I'm SQL.
CREATE TABLE HCMBMaps
AS (SELECT mecase.CASETYPE AS "Case#", mecase.mannerappears AS "Appearstobe", mecase.injurystreet + mecase.injurycity + mecase.injurycounty + mecase.injuryzip AS "Placeofinjury", mecase.deathstreet + mecase.deathcity + mecase.deathcnty + mecase.deathzip AS "Placeofdeath", mecase.cause_a AS "Primarycauseofdeath", mecase.manner AS "Mannerofdeath"
FROM dbo.mecase WHERE 1 = 0);
November 2, 2015 at 9:27 am
SQL Server doesn't use the syntax CREATE TABLE...AS... Instead, it uses SELECT...INTO...
This should be what you're looking for.
SELECT mecase.CASETYPE AS [Case#],
mecase.mannerappears AS [Appearstobe],
mecase.injurystreet + mecase.injurycity + mecase.injurycounty + mecase.injuryzip AS [Placeofinjury],
mecase.deathstreet + mecase.deathcity + mecase.deathcnty + mecase.deathzip AS [Placeofdeath],
mecase.cause_a AS [Primarycauseofdeath],
mecase.manner AS [Mannerofdeath]
INTO HCMBMaps
FROM dbo.mecase
WHERE 1 = 0;
This is part of why there's no real code portability from one RDBMS to another.
November 2, 2015 at 9:46 am
Thanks Luis that worked perfectly.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply