我需要使用源表中的数据加载维度表。我必须将一些列转换为不同的数据类型。我不确定如何正确设置我的代码或处理一些语法错误。
我需要将纬度和经度转换为地理类型。我还需要将时区从文本转换为整数。继承人正在进行的代码。
USE DBM298_DataMart;
GO
CREATE PROC Load_Dim_Aiports
AS
SET IDENTITY_INSERT Dim_Airports ON
BEGIN
INSERT INTO Dim_Airports
(AirportId, AirportName, City, Country, LatLong , Altitude, Timezone)
SELECT AirportId, AirportName,City,Country, Latitude, Longitude, Altitude, Timezone
FROM src_flights;
SET LatLong = geography::Point(Latitude,Longitude,4326)
DECLARE @NegativeNumeric INT
DECLARE @NegativeCharString VARCHAR(50)
SELECT @NegativeNumeric = -1 * CAST ( REPLACE(@NegativeCharString ,'-','') AS DECIMAL (10,2)
END
答案 0 :(得分:1)
这样的事情怎么样:
USE DBM298_DataMart;
GO
CREATE PROC Load_Dim_Aiports
AS
SET IDENTITY_INSERT Dim_Airports ON
BEGIN
INSERT INTO Dim_Airports
(AirportId, AirportName, City, Country, LatLong , Altitude, Timezone)
SELECT AirportId, AirportName, City, Country, geography::Point(Latitude,Longitude,4326) as LatLong , Altitude, cast(Timezone as int) as Timezone
FROM src_flights;
END