我的查询未按预期运行

时间:2015-04-22 13:11:06

标签: sql sql-server-2008

我的查询无效,如下所示:

CREATE TABLE #tempCal (
    CategoryId BIGINT
    ,CategoryName NVARCHAR(max)
    ,ElementWeight MONEY
    ,MakingCharges MONEY
    ,GemstoneAttribute NVARCHAR(max)
    ,AlloyAttribute NVARCHAR(max)
    ,Rates MONEY
    )

--insert into #tempCal(CategoryId,CategoryName,ElementWeight,MakingCharges,GemstoneAttribute,AlloyAttribute,Rates)
--values
DECLARE @iterator BIGINT = (
        SELECT max(MstJewelleryProduct.ID)
        FROM MstJewelleryProduct
        )

INSERT INTO #tempCal (
    CategoryId
    ,CategoryName
    ,ElementWeight
    ,MakingCharges
    ,GemstoneAttribute
    ,AlloyAttribute
    ,Rates
    )
VALUES (
    (
        SELECT MstJewelleryProduct.ElementWeight
            ,MstJewelleryProduct.Element_Price
            ,MstJewelleryProduct.MakingCharges
            ,MstJewelleryProduct.GemstoneAttribute
            ,MstJewelleryProduct.AlloyAttribute
            ,MstJewelleryCategory.ID
            ,MstJewelleryCategory.CategoryName
            ,MstRates.Rates
            ,MstJewelleryOffers.OfferAmount
        FROM MstJewelleryProduct
        INNER JOIN MstJewelleryCategory ON MstJewelleryProduct.CategoryID = MstJewelleryCategory.ID
        LEFT JOIN MstRates ON MstJewelleryProduct.CategoryID = MstRates.CategoryId
        LEFT JOIN MstJewelleryOffers ON MstJewelleryProduct.CategoryID = MstJewelleryOffers.ProductCategory
            AND MstJewelleryOffers.IsActive = 1
        WHERE MstJewelleryProduct.IsActive = 1
        )
    )

SELECT *
FROM #tempCal

DROP TABLE #tempCal

1 个答案:

答案 0 :(得分:0)

插入 进入)的语法不正确。使用时(选择),您无需使用()。请参阅此link以检查正确的语法。

相关问题