小编Ech*_*cho的帖子

SSIS如何通过分隔符获取字符串的一部分

我需要一个SSIS表达式来获取分隔符之前的字符串的左侧部分,然后将新字符串放在一个新列中.我检查了派生列,似乎没有这样的表达式."Substring"只能返回固定长度的字符串部分.

例如,使用分隔符字符串' - ':

Art-Reading                Should return Art
Art-Writing                Should return Art
Science-chemistry          Should return Science
Run Code Online (Sandbox Code Playgroud)

PS我知道这可以在MySQL中使用SUBSTRING_INDEX()完成,但我在SSIS中寻找一个等价物,或者至少在SQL Server中

sql-server expression ssis etl

15
推荐指数
3
解决办法
6万
查看次数

SQL:Last_Value()返回错误的结果(但First_Value()工作正常)

我在SQL Server 2012中有一个表,如快照所示:

在此输入图像描述

然后我使用Last_Value()和First Value来获取不同YearMonth的每个EmpID的AverageAmount.脚本如下:

SELECT A.EmpID,  
       First_Value(A.AverageAmount) OVER (PARTITION BY A.EmpID Order by A.DimYearMonthKey asc) AS  '200901AvgAmount', 
       Last_Value(A.AverageAmount) OVER (PARTITION BY A.EmpID Order by A.DimYearMonthKey asc) AS '201112AvgAmount'

FROM  Emp_Amt  AS A
Run Code Online (Sandbox Code Playgroud)

但是,此查询的结果是:

结果

在"201112AvgAmount"列中,它显示每个EmpID的不同值,而"200901AvgAmount"具有正确的值.

我的SQL脚本有什么问题吗?我在网上做了很多研究,但仍然找不到答案....

sql sql-server sql-function sql-server-2012

11
推荐指数
2
解决办法
8294
查看次数

如何在SSIS中将数据库名称设置为变量?

在我当前的项目中,数据库名称不断变化,我不想每次都修改我的OLE DB源.因此,我想将其设置为变量.也就是说,在每个OLE DB源中,我可以将它用作参数.但是,似乎SSIS不允许将数据库名称作为参数传输.那么我该怎么做才能最大限度地减少我的变化

我希望在OLE DB源中执行类似这样的SQL语句:

Select OrderID
  From ?.Order
Run Code Online (Sandbox Code Playgroud)

我只需要在更改数据库名称时修改我的变量.谢谢你的解决方案!

variables ssis oledbconnection

6
推荐指数
1
解决办法
7538
查看次数

SQL:如何获得本周的周日

我想在任何时间戳给出当周的最后一天(星期日).我尝试了下面的脚本,但它按照我的预期将星期六作为最后一天而不是星期日.

Select DATEADD(DAY , 7-DATEPART(WEEKDAY,GETDATE()),GETDATE()) AS 'Last Day Of Week' 
Run Code Online (Sandbox Code Playgroud)

欢迎任何答案!!

sql date sql-server-2008

6
推荐指数
1
解决办法
3万
查看次数

每个循环中的"所有表中的行"是什么?

当为每个循环设置a以从"objProduct"对象变量读取产品时,我在"枚举器模式"窗格中有三个选项,如快照所示:

在此输入图像描述

我知道"第一张表中的行"是当前案例的正确选项.但是,我很好奇第二和第三个选项会在哪些场景中使用?

似乎"ADO对象源变量"将包含多个表,如果应用了第2个/第3个.那令人困惑......不应该将一个变量视为一个表,因此只需要第一个选项吗?

PS我做过研究,只有MSDN如下所示,但是当它们被应用以及用于何种目的时,并不十分清楚.

**Rows in all tables (ADO.NET dataset only)**
Select to enumerate rows in all tables. This option is available only if the objects to enumerate are all members of the same ADO.NET dataset.
**All tables (ADO.NET dataset only)**
Select to enumerate tables only.
Run Code Online (Sandbox Code Playgroud)

foreach ssis enumerator foreach-loop-container

6
推荐指数
1
解决办法
2986
查看次数

SSIS条件拆分布尔结果

在条件拆分组件中,我需要知道Age是否等于-1并使用以下语句. 在此输入图像描述

但是,运行时会出现错误.我该如何修改我的陈述?这是一个loooooooot!

Error: The expression "Age == -1" on "output "Unknown" (12743)" evaluated to NULL, but the "component "Age Conditional Split 1" (12740)" requires a Boolean results. Modify the error row disposition on the output to treat this result as False (Ignore Failure) or to redirect this row to the error output (Redirect Row).  The expression results must be Boolean for a Conditional Split.  A NULL expression result is an error.
Run Code Online (Sandbox Code Playgroud)

conditional ssis split boolean-expression

4
推荐指数
1
解决办法
1万
查看次数

SSRS 2008:如何动态更改图表轴单位?

我在SSRS报告中有一张图表,其Y轴显示销售员的总收入.Y轴的单位是"百万",它适用于总量.

然而,大约有数千名销售员,并且当在参数面板中选择一个特定的销售员时,他/她的销售额可能仅为"百"级.因此,图表上的条形图太小而无法识别.

有没有办法在运行时动态更改Y轴单位?

scale reporting-services ssrs-2008 axis-labels

3
推荐指数
1
解决办法
8331
查看次数

SSIS左合并加入部分匹配

在SSIS中,当我尝试在"CourseName"上对表1和表2进行合并连接时,结果显示只映射了部分列.也就是说,即使这两个表中的值具有相同的数据类型并且具有相同的"Coursename",它们在SSIS中的左合并连接中也被视为"不匹配".有人可以帮帮我吗?

PS

  1. 两列的数据类型都是nvarchar(30)
  2. 查找也不起作用......

merge ssis left-join string-matching

2
推荐指数
1
解决办法
3022
查看次数

无法在 python 中加载 json 文件

我得到了一个 json 格式的 Twitter 流数据文件。现在我尝试在 python 中加载它:

import json

tweets_data=[]
tweets_file=open('test1.txt',"r")
for line in tweets_file:
    try:
        tweet=json.load(line)
        tweets_data.append(tweet)
    except:
        continue 

print(len(tweets_data))
Run Code Online (Sandbox Code Playgroud)

结果始终为 0。如果删除“try”和“ except”,则错误为“ValueError:期望值:第 2 行第 1 列(字符 1)”。但是,根据在线验证器,文件的每一行都是有效的 JSON。

这是 test1.txt 的一段:

{"created_at":"Fri Jul 24 16:35:22 +0000 2015","id":624618886277640192,"id_str":"624618886277640192","text":"RT @nodenow: Essential Steps: Long Term Support for Node.js\nhttp:\/\/t.co\/MzPfvenwtT\n+1 micshasan #javascript","source":"\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":3290861609,"id_str":"3290861609","name":"Rajiin","screen_name":"Rajiin_07","location":"Pokhara city","url":"http:\/\/www.pokharacity.com","description":null,"protected":false,"verified":false,"followers_count":1101,"friends_count":1119,"listed_count":155,"favourites_count":2048,"statuses_count":5498,"created_at":"Wed May 20 04:58:23 +0000 2015","utc_offset":-25200,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"000000","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_link_color":"4A913C","profile_sidebar_border_color":"000000","profile_sidebar_fill_color":"000000","profile_text_color":"000000","profile_use_background_image":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/617620457336893440\/3HTEKnMx_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/617620457336893440\/3HTEKnMx_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/3290861609\/1435854327","default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweeted_status":{"created_at":"Fri Jul 24 16:33:04 +0000 2015","id":624618308050915328,"id_str":"624618308050915328","text":"Essential Steps: Long Term Support for Node.js\nhttp:\/\/t.co\/MzPfvenwtT\n+1 micshasan #javascript","source":"\u003ca href=\"http:\/\/ifttt.com\" rel=\"nofollow\"\u003eIFTTT\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":3243544179,"id_str":"3243544179","name":"Javascript Digest","screen_name":"nodenow","location":"","url":null,"description":null,"protected":false,"verified":false,"followers_count":1238,"friends_count":1,"listed_count":1148,"favourites_count":2,"statuses_count":130923,"created_at":"Sat May …
Run Code Online (Sandbox Code Playgroud)

python json

2
推荐指数
1
解决办法
9234
查看次数