Sql server 我不知道如何在SQL中加载源系统

Sql server 我不知道如何在SQL中加载源系统,sql-server,database,Sql Server,Database,这是我的任务列表: 为数据仓库设计星型或雪花型模式,帮助回答有关销售的各种业务问题 基于您设计的星形/雪花模式,在SQL Server(这是数据仓库服务器)中创建数据库 从源系统(即前面显示的OLTP数据库)将数据加载到星形/雪花模式数据库 OLTP数据库中大多数表中的数据都是以SQL语句的形式准备的。不幸的是,根据公司的政策,不允许“直接”从产品和客户表加载数据 客户数据以CSV格式编制 产品数据只能以JSON格式从云数据库中检索 您需要找到最有效的方法(可能包括编码)将数据从源加载到SQL

这是我的任务列表:

  • 为数据仓库设计星型或雪花型模式,帮助回答有关销售的各种业务问题
  • 基于您设计的星形/雪花模式,在SQL Server(这是数据仓库服务器)中创建数据库
  • 从源系统(即前面显示的OLTP数据库)将数据加载到星形/雪花模式数据库
  • OLTP数据库中大多数表中的数据都是以SQL语句的形式准备的。不幸的是,根据公司的政策,不允许“直接”从产品和客户表加载数据
  • 客户数据以CSV格式编制
  • 产品数据只能以JSON格式从云数据库中检索
  • 您需要找到最有效的方法(可能包括编码)将数据从源加载到SQL Server 到目前为止,我已经做到了:

    CREATE TABLE Customers (
    customerNumber          Int             NOT NULL,
    customerName            Varchar(50)     NOT NULL,
    contactLastName         Varchar(50)     NOT NULL,
    contactFirstName        Varchar(50)     NOT NULL,
    phone                   Varchar (50)    NOT NULL,
    addressLine1            Varchar (50)    NOT NULL,
    addressLine2            Varchar (50)    NOT NULL,
    city                    Varchar (50)    NOT NULL,
    state                   Varchar (50)    NULL,
    postalCode              Varchar (15)    NOT NULL,
    country                 Varchar(50)     NOT NULL,
    salesRepEmployeeNumber  Int             NOT NULL,
    creditLimit             Double          NOT NULL,
    PRIMARY KEY (customerNumber));
    
    
    CREATE TABLE Offices (
    officeCode              Varchar(10)     NOT NULL,
    city                    Varchar(50)     NOT NULL,
    phone                   Varchar(50)     NOT NULL,
    addressLine1            Varchar(50)     NOT NULL,
    addressLine2            Varchar(50)     NOT NULL,
    state                   Varchar(50)     NULL,
    country                 Varchar(50)     NOT NULL,
    postalCode              Varchar(15)     NOT NULL,
    territory               Varchar(10)     NOT NULL,
    PRIMARY KEY (officeCode));
    
    CREATE TABLE payments (
    customerNumber          Int             NOT NULL,
    checkNumber             Varchar(50)     NOT NULL,
    paymentDate             Datetime        NOT NULL,
    amount                  DOUBLE          NOT NULL,
    PRIMARY KEY (customerNumber, checkNumber));
    
    CREATE TABLE OrderDetails (
    orderNumber             Int             NOT NULL,
    productCode             Varchar(15)     NOT NULL,
    quantityOrdered         Int             NOT NULL,
    priceEach               DOUBLE          NOT NULL,
    orderLineNumber         SMALLINT        NOT NULL,
    PRIMARY KEY (orderNumber, productCode));
    
    CREATE TABLE ProductLines (
    productLine             Varchar (50)    NOT NULL,
    textDescription         TEXT            NOT NULL,
    htmlDescription         TEXT            NOT NULL,
    image                   BLOB            NOT NULL,
    PRIMARY KEY (productLine));
    
    CREATE TABLE Orders (
    orderNumber      Int            NOT NULL,
    orderDate        DateTime       NOT NULL,
    requiredDate     DateTime       NOT NULL,
    shippedDate      DateTime       NOT NULL,
    status           Varchar(15)    Not null,
    comments         TEXT           NOT NULL,
    customerNumber   INT            NOT NULL,
    Primary key(orderNumber));
    ALTER TABLE Orders  ADD FOREIGN KEY(customerNumber) REFERENCES Customer(customerNumber);   
    
    CREATE TABLE Employees (
    employeeNumber Int Not null,
    lastName Varchar(50) Not null,
    firstName Varchar(50) Not null,
    extension Varchar(10) NOt null,
    email Varchar(100) Not null,
    officeCode Varchar(10) Not Null,
    reportsTo Int Not null,
    jobTitle Varchar(50) Not null,
    Primary key(employeeNumber));
    
    CREATE TABLE Products ( 
    productCode         Varchar(15)      Not Null,
    productName         Varchar(70)      Not Null,
    productLine         Varchar(50)      Not null,
    productScale        Varchar(10)      Not null,
    productVendor       Varchar(50)      Not null,
    productDescription  TEXT             Not null,
    quantityinStock     Int              Not null,
    Buy Price           Double           Not null,
    MSRP                Double           Not null,
    Primary key (productCode))
    9:28PM
    
    CREATE TABLE payments (
    customerNumber          Int             NOT NULL,
    checkNumber             Varchar(50)     NOT NULL,
    paymentDate             Datetime        NOT NULL,
    amount                  Float           NOT NULL,
    PRIMARY KEY (customerNumber, checkNumber));
    
    
    
    CREATE TABLE Customers (
    customerNumber          Int             NOT NULL,
    customerName            Varchar(50)     NOT NULL,
    contactLastName         Varchar(50)     NOT NULL,
    contactFirstName        Varchar(50)     NOT NULL,
    phone                   Varchar (50)    NOT NULL,
    addressLine1            Varchar (50)    NOT NULL,
    addressLine2            Varchar (50)    NOT NULL,
    city                    Varchar (50)    NOT NULL,
    state                   Varchar (50)    NULL,
    postalCode              Varchar (15)    NOT NULL,
    country                 Varchar(50)     NOT NULL,
    salesRepEmployeeNumber  Int             NOT NULL,
    creditLimit             Float           NOT NULL,
    PRIMARY KEY (customerNumber));
    
    ALTER TABLE Payments  ADD FOREIGN KEY(customerNumber) REFERENCES Customers(customerNumber);  -- here
    
    
    CREATE TABLE Offices (
    officeCode              Varchar(10)     NOT NULL,
    city                    Varchar(50)     NOT NULL,
    phone                   Varchar(50)     NOT NULL,
    addressLine1            Varchar(50)     NOT NULL,
    addressLine2            Varchar(50)     NOT NULL,
    state                   Varchar(50)     NULL,
    country                 Varchar(50)     NOT NULL,
    postalCode              Varchar(15)     NOT NULL,
    territory               Varchar(10)     NOT NULL,
    PRIMARY KEY (officeCode));
    
    
    CREATE TABLE OrderDetails (
    orderNumber             Int             NOT NULL,
    productCode             Varchar(15)     NOT NULL,
    quantityOrdered         Int             NOT NULL,
    priceEach               Float           NOT NULL,
    orderLineNumber         SMALLINT        NOT NULL,
    PRIMARY KEY (orderNumber, productCode));
    
    
    CREATE TABLE ProductLines (
    productLine             Varchar (50)    NOT NULL,
    textDescription         TEXT            NOT NULL,
    htmlDescription         TEXT            NOT NULL,
    image                   Float           NOT NULL,
    PRIMARY KEY (productLine));
    
    
    CREATE TABLE Orders (
    orderNumber      Int            NOT NULL,
    orderDate        DateTime       NOT NULL,
    requiredDate     DateTime       NOT NULL,
    shippedDate      DateTime       NOT NULL,
    status           Varchar(15)    Not null,
    comments         TEXT           NOT NULL,
    customerNumber   INT            NOT NULL,
    Primary key(orderNumber));
    ALTER TABLE OrderDetails  ADD FOREIGN KEY(orderNumber) REFERENCES Orders(orderNumber);   -- here
    
    
    CREATE TABLE Employees (
    employeeNumber Int Not null,
    lastName Varchar(50) Not null,
    firstName Varchar(50) Not null,
    extension Varchar(10) NOt null,
    email Varchar(100) Not null,
    officeCode Varchar(10) Not Null,
    reportsTo Int Not null,
    jobTitle Varchar(50) Not null,
    Primary key(employeeNumber));
    
    
    CREATE TABLE Products ( 
    productCode         Varchar(15)      Not Null,
    productName         Varchar(70)      Not Null,
    productLine         Varchar(50)      Not null,
    productScale        Varchar(10)      Not null,
    productVendor       Varchar(50)      Not null,
    productDescription  TEXT             Not null,
    quantityinStock     Int              Not null,
    BuyPrice            Float            Not null,
    MSRP                Float            Not null,
    Primary key (productCode))
    
    ALTER TABLE OrderDetails  ADD FOREIGN KEY(productCode) REFERENCES Products(productCode);
    

    我不知道如何从源系统加载?

    在SQL Server Management Studio中,exp[和服务器名称,并在
    数据库下找到您的数据库

    右键单击它,选择任务,然后导入数据


    使用导入/导出向导帮助您从源数据导入数据。

    您对stackoverflow的目标有很大的误解。我们是来帮助您解决问题的,而不是为您解决问题的。好的,您应该从尝试将整个任务划分为更小的可管理块开始。其中一个可能是PARe给定的JSON结构,并将其转换为SQL server的可消化的SQL
    INSERT
    命令。
    ntext
    text
    image
    数据类型将在SQL server的未来版本中删除。避免在新的开发工作中使用这些数据类型,并计划修改当前使用它们的应用程序。使用
    nvarchar(max)
    varchar(max)
    、和
    varbinary(max)
    。您需要将其缩小为一个具体的、可回答的问题,并说明您尝试了什么以及如何出错。我们通常不会为您创建大量软件。我尝试过,但不知道从哪里开始,但我在这里寻求一些帮助:(