Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server date1的语法错误_Sql Server - Fatal编程技术网

Sql server date1的语法错误

Sql server date1的语法错误,sql-server,Sql Server,我试过了,检查一下 SELECT FactOrders.TerritoryKey , FactOrders.DistributorKey , FactOrders.ItemKey , SUM(FactOrders.UnitQty)as Quantity , SUM(FactOrders.GrossValue) as Gross_Value FROM FactOrders WHERE FactOrders.TerritoryKey = @

我试过了,检查一下

SELECT FactOrders.TerritoryKey ,
       FactOrders.DistributorKey ,
       FactOrders.ItemKey ,
       SUM(FactOrders.UnitQty)as Quantity ,
       SUM(FactOrders.GrossValue) as Gross_Value 
FROM FactOrders 
WHERE FactOrders.TerritoryKey = @TerritoryKey and 
      FactOrders.DistributorKey = @DistributorKey and 
      FactOrders.DateKey >=CInt(Format(Paramters!@Date1.Value,"yyyyMMdd")) and 
      FactOrders.DateKey <= @Date2 AND 
      FactOrders.LineType = 'ORDER' 
GROUP BY FactOrders.TerritoryKey , FactOrders.DistributorKey ,FactOrders.ItemKey 
ORDER BY FactOrders.TerritoryKey , FactOrders.DistributorKey ,FactOrders.ItemKey

@Date1看起来像一个变量,但您是否在任何地方定义了它?为什么要访问属性?@Date1是我的ms sql报表编写器中的参数。它是日期类型参数。我想将其转换为intiger。@Dumindaaturaliyapathegama Date1=2017-01-31表示您需要转换为的基础int@Chanukya我想将2016年5月21日转换为20160521。因为在数据库中,日期用作整数。但在参数部分,我想将其用作日期类型。@Chanukya现在在将varchar值5/21/2016转换为数据类型int时给出转换失败,错误245
SELECT FactOrders.TerritoryKey ,
       FactOrders.DistributorKey ,
       FactOrders.ItemKey ,
       SUM(FactOrders.UnitQty)as Quantity ,
       SUM(FactOrders.GrossValue) as Gross_Value 
FROM FactOrders 
WHERE FactOrders.TerritoryKey = @TerritoryKey and 
      FactOrders.DistributorKey = @DistributorKey and 
     ---- FactOrders.DateKey >=CInt(Format(Paramters!@Date1.Value,"yyyyMMdd")) and
     CONVERT(varchar(8),CAST(@date1 AS DATE),112)
      FactOrders.DateKey <= @Date2 AND 
      FactOrders.LineType = 'ORDER' 
GROUP BY FactOrders.TerritoryKey , FactOrders.DistributorKey ,FactOrders.ItemKey 
ORDER BY FactOrders.TerritoryKey , FactOrders.DistributorKey ,FactOrders.ItemKey