ssis - 使用表达式生成器评估表达式
问题描述
我是 ssis 的新手,我想使用表达式生成器对此进行评估,以获取 bigin 中的当前日期。任何想法?
DATEPART(second, getdate()) +
DATEPART(minute, getdate()) * 100 +
DATEPART(hour, getdate()) * 10000 +
DATEPART(day, getdate()) * 1000000 +
DATEPART(month, getdate()) * 100000000 +
DATEPART(year, getdate()) * 10000000000
错误是
无法评估表达式。
------------------------------
ADDITIONAL INFORMATION:
The expression contains unrecognized token "second". If "second" is a variable, it should be expressed as "@second". The specified token is not valid. If the token is intended to be a variable name, it should be prefixed with the @ symbol.
Attempt to parse the expression "DATEPART(second, getdate()) +
DATEPART(minute, getdate()) * 100 +
DATEPART(hour, getdate()) * 10000 +
DATEPART(day, getdate()) * 1000000 +
DATEPART(month, getdate()) * 100000000 +
DATEPART(year, getdate()) * 10000000000" failed and returned error code 0xC00470A4. The expression cannot be parsed. It might contain invalid elements or it might not be well-formed. There may also be an out-of-memory error.
(Microsoft.DataTransformationServices.Controls)
------------------------------
解决方案
DATEPART
SSIS 表达式中的语法与 TSQL 中的语法不同。因为这有助于使我们的生活变得比必要的更加艰难。
第一个参数 ,datepart
必须用双引号括起来。这应该让你更接近你所追求的。
DATEPART("second", getdate()) +
DATEPART("minute", getdate()) * 100 +
DATEPART("hour", getdate()) * 10000 +
DATEPART("day", getdate()) * 1000000 +
DATEPART("month", getdate()) * 100000000 +
DATEPART("year", getdate()) * 10000000000
您将得到的下一个错误是:
文字“10000000000”太大而无法放入类型 DT_I4。字面量的大小会溢出类型。
L
您可以通过在最后一个文字的末尾添加一个来修复该问题:
DATEPART("second", getdate()) +
DATEPART("minute", getdate()) * 100 +
DATEPART("hour", getdate()) * 10000 +
DATEPART("day", getdate()) * 1000000 +
DATEPART("month", getdate()) * 100000000 +
DATEPART("year", getdate()) * 10000000000L
并且正确评估为20200611143622
.
推荐阅读
- php - 无法在我的 JQuery 脚本中从 PHP 访问 json_encode 数据
- c# - 如何获取在 ASP.NET 中单击的按钮的动态设置 ID
- list - Prolog 中的关联列表
- elasticsearch - 如何在 Kibana 中过滤消息?
- asp.net-mvc - .net MVC 链接到区域内视图的正确方法
- oracle - 当使用 Oracle 的 setFirstResults 和 setMaxResults 方法时,休眠返回两列而不是一列
- oracle - 从可能不存在的表中选择
- arrays - vue路由器重载和组件更新的一些问题
- c# - 不支持实体框架连接字符串“连接超时”关键字?
- json - 具有类注释的类型的序列化/反序列化的自定义增强