YouTube2Text

SQL Server Integration Services (SSIS) Part 7 - Conditional split and derived column transforms — Transcript

by WiseOwlTutorials · 2,803 words · 406 segments · language en · Watch on YouTube

Full transcript

  1. 0:01welcome to this wise hour tutorial on
  2. 0:03conditional split transforms and derived
  3. 0:05column transforms in integration
  4. 0:07Services here's what we'll aim to cover
  5. 0:09on the
  6. 0:12tutorial the first thing we'll look at
  7. 0:14is what we're trying to achieve which is
  8. 0:16actually to marry off Cheryl Cole to one
  9. 0:18of our trainers but more on that in a
  10. 0:20second we'll then look at how to create
  11. 0:23a conditional split transform to split a
  12. 0:25table of data into two or more
  13. 0:28parts we then look at how to create a
  14. 0:30derived column transform to create a new
  15. 0:33column or amend an existing one in a
  16. 0:35table of data and finally we'll complete
  17. 0:38the project so to get the finnal output
  18. 0:41and send it to a SQL Server table so
  19. 0:44let's get
  20. 0:46started here at yal some of us are Avid
  21. 0:49followers of The X Factor I'm afraid
  22. 0:51it's a UK version and so we've got an
  23. 0:54Excel workbook of X Factor finalists
  24. 0:56over the last few years what we're going
  25. 0:59to do is import the data paying
  26. 1:01particular attention to the mentor
  27. 1:02column cherd Cole has just got married
  28. 1:04to one of our trainers Dave Wakefield
  29. 1:06and so we need to change all occurrences
  30. 1:08of Cheryl Cole to Cheryl
  31. 1:11wigfield also we can't spell this
  32. 1:13person's name we can't even actually
  33. 1:15pronounce it so what we're going to do
  34. 1:17is redirect all people whose name
  35. 1:19contains the words
  36. 1:21contostavlos down to a path which will
  37. 1:23then be
  38. 1:26rejected the package in ssis would look
  39. 1:29like this we'll begin with an Excel
  40. 1:32workbook of the xfactor finalists and
  41. 1:34we'll import that using a data flow
  42. 1:37task if the mentor is Cheryl will
  43. 1:40redirect the output down this path we'll
  44. 1:43then use a derived column task to re or
  45. 1:46to change Cheryl's name to Cheryl
  46. 1:48Wakefield and then that data will
  47. 1:50reunite with the normal data in a union
  48. 1:53or query to recombine all the finalists
  49. 1:55together the final result will be
  50. 1:58exported to a SQL Server table of fin
  51. 1:59finalists except that Tisa contostavlos
  52. 2:03that sounded more likely didn't it will
  53. 2:05won't appear in the final results her
  54. 2:07Rose would have been
  55. 2:09rejected here's what the final results
  56. 2:11will look like then there will be a
  57. 2:13table containing the mentor name Sher
  58. 2:16wakefields will all appear at the top or
  59. 2:18the bottom depending on how we do
  60. 2:20it uh but there won't in this list be
  61. 2:23any toisa Kosta losses those records
  62. 2:26would have been
  63. 2:28lost so let's have a look at
  64. 2:32the package in ssis we've got a control
  65. 2:35flow containing an execute SQL task what
  66. 2:39that will do is just delete all the
  67. 2:41records from the finless table to begin
  68. 2:43with so that we can reimport them we've
  69. 2:46then got a data flow task which will
  70. 2:48import all the xfactor
  71. 2:50finalists and all I've done so far
  72. 2:52within that is created a source which
  73. 2:55will take data from an Excel worksheet
  74. 2:57of excel Factor finalists and if we
  75. 2:59double click on that and preview it you
  76. 3:02can see there's the columns contained in
  77. 3:04the Excel workbook and it's the mentor
  78. 3:06column we're going to be conly
  79. 3:08particularly concerned
  80. 3:10with so let's get started with the
  81. 3:13conditional split
  82. 3:16task so what we're going to do is split
  83. 3:19the data coming out from this Excel
  84. 3:20workbook into three parts people Mentor
  85. 3:24by Cheryl Cole people Mentor by TSA
  86. 3:26whatever her name is and everybody else
  87. 3:29and the way to do that to split data is
  88. 3:32to create a conditional split task so
  89. 3:35I'm going to add one of those and I'll
  90. 3:38rename it to say split mentors because
  91. 3:43that's what it's going to do and then
  92. 3:45what I'm going to do is run the data
  93. 3:46from the Excel workbook straight into
  94. 3:48that conditional split
  95. 3:49task what I can now do is configure this
  96. 3:52and I can have as many conditions as I
  97. 3:55want the default
  98. 3:57output will be called normal people but
  99. 4:01in addition to that I'll have one or
  100. 4:03more conditions above here in one for
  101. 4:05each line which says specifies another
  102. 4:08data pipe so let's start with the cherl
  103. 4:11coal
  104. 4:14finalists and I'm going to call that
  105. 4:15stream of data sh call finalists for
  106. 4:18obvious reasons what I want to do is
  107. 4:20find out whether the mentor name
  108. 4:23contains the word Cheryl now I can get
  109. 4:26to the mentor Name by clicking on that
  110. 4:28column and dragging it into the
  111. 4:30condition to find out whether one bit of
  112. 4:33text contains another I can use a string
  113. 4:36function and users of other Microsoft
  114. 4:39software will find a lot of these
  115. 4:40familiar the one I want on this occasion
  116. 4:43is find string if I click on that you
  117. 4:45can see that it says it Returns the
  118. 4:47location of the specified occurrence of
  119. 4:48one string within another so I'm going
  120. 4:51to drag that down into the condition and
  121. 4:53it has three arguments the string within
  122. 4:56the bit of text within which I'm
  123. 4:57searching the string I'm looking for
  124. 4:59four and the occurrence I want to return
  125. 5:03so whether it's the first or the second
  126. 5:04or subsequent
  127. 5:05equasion the character expression is
  128. 5:08just going to be the column called
  129. 5:09Mentor so I can click on that and drag
  130. 5:11it onto the character expression
  131. 5:13argument and it will automatically
  132. 5:14replace it you can see that my whole
  133. 5:17expression is still red because it still
  134. 5:19doesn't make sense to integration
  135. 5:21Services the next thing I need to
  136. 5:23specify is the string I'm looking for
  137. 5:25and I'm going to look for the word
  138. 5:27Cheryl but I can't actually remember how
  139. 5:29I typed it in so I'm going to use a
  140. 5:31fairly standard trick throughout
  141. 5:32Microsoft software which is instead of
  142. 5:35just looking for it in the Co in the
  143. 5:38case I typed it in I'm going to convert
  144. 5:41it using either the upper or the lower
  145. 5:44function and all these functions do is
  146. 5:47to convert text to Upper or lower case
  147. 5:49and because I've typed in cherl in
  148. 5:51uppercase I'm going to have to type in
  149. 5:53the word upper in
  150. 5:55there and close the brackets there so
  151. 5:58what this is doing is taking the
  152. 6:00mentor's name converting it to uppercase
  153. 6:03and then searching within that for the
  154. 6:04word Cheryl in uppercase so now it
  155. 6:07doesn't matter in which case I typed in
  156. 6:08Cheryl it will still
  157. 6:10work the occurrence I'm looking for is
  158. 6:13the first one and I'm hoping that when I
  159. 6:15click off that row it will turn black it
  160. 6:19hasn't it still doesn't understand it
  161. 6:21and if I let my mouse linger over it it
  162. 6:23will tell me why it tells me the answer
  163. 6:26is a Boolean I don't know if you read
  164. 6:27that briefly and that's because I
  165. 6:29haven't actually specified a condition
  166. 6:32the F string function will return the
  167. 6:35character number where it found the word
  168. 6:37Cheryl in the mentor's name and what I
  169. 6:40want to do is say that that should be
  170. 6:41greater than zero so what I'm saying is
  171. 6:44try to look for the word Cheryl within
  172. 6:45the mentor's name and if it finds it at
  173. 6:47a character position all well and
  174. 6:51good so that completes my Cheryl Co
  175. 6:53finalist condition I'm going to add one
  176. 6:56more output which is going to be to Lisa
  177. 7:00finalists and this is going to do pretty
  178. 7:02much the same thing but instead of
  179. 7:04looking for the word toisa anywhere
  180. 7:06within the mentor name I'm going to just
  181. 7:08by way of variety see if the first six
  182. 7:11characters of the mentor's name equal to
  183. 7:13Lisa so I can do that rather than using
  184. 7:16find string I can use the left function
  185. 7:20which takes a string of text and picks
  186. 7:22out a given number of letters from it
  187. 7:24beginning at the left hand
  188. 7:27side I'm looking within the mentor name
  189. 7:30but again I'm nervous whether I typed in
  190. 7:32me toisa in lower or upper case so I'm
  191. 7:36going to do exactly what I did last time
  192. 7:38and convert it to
  193. 7:42lowercase and I'm going to pick out six
  194. 7:44characters and I want to say whether
  195. 7:46that equals toisa except I need to make
  196. 7:50sure I type toisa in in lowercase and
  197. 7:52when I click off that it still gives me
  198. 7:53an error and the reason for that is
  199. 7:56because I haven't actually specified the
  200. 7:59right equal sign this is a condition and
  201. 8:02in ssis just like in C you have to put
  202. 8:06two equal sign to specify
  203. 8:09equality so let's just sum up where I've
  204. 8:11got to then the stream of all the
  205. 8:14contestants are going to come from an
  206. 8:15Exel workbook the ones where the
  207. 8:18mentor's name contains the word Cheryl
  208. 8:20in any case are going to go down one
  209. 8:22pipe the one where the mentor's name
  210. 8:24begins with the word TSA are going to go
  211. 8:26down a second pipe and all of the others
  212. 8:29are going to go to the default output
  213. 8:30called normal people so I'm going to
  214. 8:33choose okay to confirm that and just do
  215. 8:35a quick test to see how well it's
  216. 8:38working the quick test is going to
  217. 8:40involve the TSA
  218. 8:42contestants I'm going to put a union all
  219. 8:44query there to mop up all the data and
  220. 8:46I'm going
  221. 8:47to configure the output from the split
  222. 8:50mentor's conditional split task to run
  223. 8:53straight into that and I'm just going to
  224. 8:56take the TSA finalists for the moment
  225. 8:58they're the only ones I'm interested in
  226. 9:00and choose okay and then I'm going to
  227. 9:02right click on that pipe and enable the
  228. 9:04data viewer just to see what's flowing
  229. 9:06down
  230. 9:07it okay if I now run this package what
  231. 9:10I'm hoping to see is the data viewer
  232. 9:13containing the list of all the
  233. 9:15contestant whose names began with
  234. 9:18TSA so that looks like it's
  235. 9:21working what I can now do is get rid of
  236. 9:23my union all query because I'm actually
  237. 9:25going to lose my Telsa finalist now and
  238. 9:28what we're now going to do is show how
  239. 9:29to configure uh integration services so
  240. 9:33the shell Cole contestants automatically
  241. 9:35get renamed so instead of being mentored
  242. 9:38by Cheryl Cole they're being mentored by
  243. 9:40Cheryl Wakefield
  244. 9:43instead so what we now have is a
  245. 9:46conditional split transform which is
  246. 9:48splitting the data into three paths and
  247. 9:51what I want to do is for the contestants
  248. 9:54who are mentored by Cheryl Cole I want
  249. 9:56to rename every occurrence of Cheryl
  250. 9:58Cole toer
  251. 10:00Wakefield to do that I'm going to use a
  252. 10:02derived column transform which will
  253. 10:05either create a new column or replace an
  254. 10:07existing one and what I'm going to do is
  255. 10:10feed the output from the conditional
  256. 10:12split transform into that choosing to
  257. 10:14take the shell Co finalists
  258. 10:18only what I can then do I'll just rename
  259. 10:22the derive column transform to say that
  260. 10:24Cheryl has married a
  261. 10:27wise owl which I I think definitely
  262. 10:30deserves an exclamation mark what I'm
  263. 10:33going to do now is reconfigure this
  264. 10:35derived column
  265. 10:36transform and create a new column within
  266. 10:39it which I'll call new
  267. 10:42Mentor now I can do one of two things
  268. 10:44with this either either create a new
  269. 10:46column alongside the existing ones or I
  270. 10:48can replace an existing column I'm
  271. 10:51actually going to create a new column
  272. 10:52alongside the existing one and I need to
  273. 10:54say what the expression for that column
  274. 10:56will be I want to replace every
  275. 10:58occurrence of with Wakefield and that
  276. 11:01sounds like a string function to me
  277. 11:03specifically it's going to be the
  278. 11:05replace function so I can drag that in
  279. 11:08and what I'm going to do is replace all
  280. 11:10the characters in The MENTOR
  281. 11:12name so I can drag the mentor name and
  282. 11:14use that as my character
  283. 11:16expression and the other two arguments
  284. 11:19are going to be the thing I'm looking
  285. 11:20for which is the word Cole and the thing
  286. 11:23I'm replacing it which is Dave's
  287. 11:28surname it's G black so must have
  288. 11:30accepted the syntax at any
  289. 11:32rate bizarrely it's created a length of
  290. 11:35570 characters if I choose okay to
  291. 11:38confirm that just for the moment and go
  292. 11:40back to the path feeding into it and
  293. 11:42edit it by right clicking you can see
  294. 11:44for the metad DAT for that path the
  295. 11:46mentor name actually only had 255
  296. 11:51characters what I think is going on here
  297. 11:53is that integration Services doesn't
  298. 11:55actually know how many times the word
  299. 11:57Cole is going to appear in each name and
  300. 11:59so it's ering on the safe side and
  301. 12:01creating a very long arbitrary long
  302. 12:03length of 570 characters unfortunately
  303. 12:07this will cause problems further down
  304. 12:08the line because the SQL Server table
  305. 12:11only has 255 characters set aside for
  306. 12:13that column so what I'm going to do is
  307. 12:16cast the expression to be shorter than
  308. 12:18it currently is I want to keep the same
  309. 12:20data type dtor wstr which is a Unicode
  310. 12:24text character
  311. 12:26string but I want to change the length
  312. 12:28of it to
  313. 12:30255 and that will truncate it at 255
  314. 12:35characters so I can choose okay to
  315. 12:37confirm that and that completes my
  316. 12:39derived column
  317. 12:41transform what I now want to do is to
  318. 12:43reunite the original normal people and
  319. 12:46the normal people with Cheryl Cole
  320. 12:48renamed so what I can do is add in a
  321. 12:51union all transform to recombine the
  322. 12:54data and I'll call that reunite
  323. 13:00normal
  324. 13:02people and Cheryl
  325. 13:06mentored I seem to have lost the ability
  326. 13:08to type one more go and what I'm going
  327. 13:11to do is run firstly the normal people
  328. 13:14down into
  329. 13:16that and because I've still got the TSA
  330. 13:19finalist which I want to discard I have
  331. 13:21to choose the output which is normal
  332. 13:24people what I can then do is take the
  333. 13:27finalist mentored by sh Cole and feed
  334. 13:30those into the unol query or the union
  335. 13:32all
  336. 13:33transform if I then double click on the
  337. 13:35union all transform to reconfigure it
  338. 13:38I've got one change I need to make for
  339. 13:40five of the six columns everything will
  340. 13:41stay as it is but for the mentor column
  341. 13:45yes I want to take the mentor from the
  342. 13:46normal people as it stood but from the
  343. 13:49other derived column transform I want to
  344. 13:52take my newly derived new Mentor column
  345. 13:55which is exactly like the mentor one but
  346. 13:57containing the word cod Wakefield
  347. 14:00instead of coal so I can then choose
  348. 14:02okay to confirm that and all I have to
  349. 14:05do now is to send my data to a SQL
  350. 14:08Server data source and test out my
  351. 14:12package so just to complete the picture
  352. 14:15I need to send the output from my union
  353. 14:17all query and feed it into my SQL Server
  354. 14:19table and this should be a revision of
  355. 14:22things we've done in previous
  356. 14:23tutorials I'm going to I've already got
  357. 14:26a SQL Server Connection Manager set up
  358. 14:29so I'm going to add
  359. 14:30a destination I'm going to say that I'm
  360. 14:34using my SQL Server Connection
  361. 14:36Manager and I'm going to feed the output
  362. 14:39from the union all transform directly
  363. 14:41into that and I'll call it Final Table
  364. 14:46in SQL
  365. 14:48Server what I can then do is reconfigure
  366. 14:51this Final Destination the first thing I
  367. 14:54need to do is say which table is feeding
  368. 14:55into it's the one called TBL finalist
  369. 14:58and then what I need to do is set the
  370. 15:01mappings it's only been able
  371. 15:03successfully to map one column the
  372. 15:04series column and that's cuz I've done
  373. 15:06some renaming as it happens the name
  374. 15:10will go onto the finalist name the
  375. 15:13category I'm going to ignore the mentor
  376. 15:15Will Go On The MENTOR name and the
  377. 15:18finished will go onto the position which
  378. 15:20holds the position of the
  379. 15:21finalist if I then choose okay to
  380. 15:23confirm that I should now be in a
  381. 15:25position to run my package so let's see
  382. 15:28if it works
  383. 15:29if I click on the play Tool I'm hoping
  384. 15:31to see a lot of green ticks excellent
  385. 15:33I'll just stop running that for the
  386. 15:35moment and if I now look at SQL server
  387. 15:38and if I just execute my package you can
  388. 15:43see that I've got all I've got 104 rows
  389. 15:49there were originally 109 take it from
  390. 15:51me I've lost the five um finalists who
  391. 15:54were mentored by
  392. 15:56TSA the only difference this has made is
  393. 15:59the sort order has changed the first
  394. 16:01thing it did was add the normal people
  395. 16:04and then it added the ones mentored by
  396. 16:06Sheryl Cole and that's why they all
  397. 16:08appear together at the end if I didn't
  398. 16:10want that to happen I would have to
  399. 16:12implement some sorting
  400. 16:14algorithm I hope you've enjoyed this
  401. 16:16tutorial on SQL Server integration
  402. 16:18Services conditional splits and derive
  403. 16:20column
  404. 16:21transforms you can find lots more
  405. 16:23training resources on SQL server.net and
  406. 16:26Microsoft Office at ww w. w.c.

About this transcript

This page contains the full transcript of SQL Server Integration Services (SSIS) Part 7 - Conditional split and derived column transforms by WiseOwlTutorials, generated from the public captions YouTube serves with the video. The transcript has 2,803 words across 406 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.