YouTube2Text

SQL Server Integration Services (SSIS) Part 12 - Other Foreach Loops — Transcript

by WiseOwlTutorials · 4,052 words · 573 segments · language en · Watch on YouTube

Full transcript

  1. 0:01welcome to this WIS tutorial on using
  2. 0:04for each loops and containers in SQL
  3. 0:06Server integration Services covering
  4. 0:09everything apart from file Loops which
  5. 0:10were covered in a previous
  6. 0:12tutorial here's what you'll learn in the
  7. 0:15tutorial we'll Begin by looking at the
  8. 0:17most common enumerator AO enumerators
  9. 0:20we'll show what we're trying to do we'll
  10. 0:23create an object variable to temporarily
  11. 0:25hold a set of rows we'll then show how
  12. 0:27to Loop over each row in that set
  13. 0:30running some script for each row in turn
  14. 0:32and then we'll test out the entire
  15. 0:34package to see if it's done what we
  16. 0:35thought it
  17. 0:36should we'll then look at item in
  18. 0:38numerators where you can store a set of
  19. 0:40rows in memory by typing it in rather
  20. 0:43than using a SQL Server
  21. 0:45table then we'll look at ado.net schema
  22. 0:48row set in numerators which is basically
  23. 0:50a fancy word for looping over all the
  24. 0:52rows in a schema in SQL Server we'll
  25. 0:55look at how to create the loop in
  26. 0:56container and then how to process each
  27. 0:58row within the loop within script and
  28. 1:02finally we'll have an overview of
  29. 1:03looping over XML files using a node list
  30. 1:05in numerator and show how to Loop over
  31. 1:07all the nodes in the file so let's get
  32. 1:12started before we begin this tutorial
  33. 1:15let's look at what we're trying to
  34. 1:16actually achieve I've got here a table
  35. 1:19called Mentor
  36. 1:21numbers and what it contains is a list
  37. 1:24of all of the mentors from the first
  38. 1:26nine series of The X Factor Series in
  39. 1:28the UK apologies to am American and
  40. 1:30other viewers around the world for
  41. 1:32anybody who's been watching other
  42. 1:33tutorials in this series this will be
  43. 1:35familiar data now what I want to do is
  44. 1:38find out which of the xfactor contests
  45. 1:40mentors rather has had the most protes
  46. 1:43the answer of course is Lou Walsh
  47. 1:44looking at the data but we're going to
  48. 1:46write a package which will automatically
  49. 1:49Loop over all of the records in turn
  50. 1:52monitoring the number of protes and
  51. 1:54storing which one is the largest
  52. 1:57number if this all sounds like uh
  53. 1:59keeping of a record set in VBA that's
  54. 2:02because it is very similar but in
  55. 2:03integration Services it's called an AO
  56. 2:07enumerator so to get this to work we're
  57. 2:09going to need to obviously create a
  58. 2:10package in integration Services which
  59. 2:12I've already done and within that create
  60. 2:15a connection to our SQL Server
  61. 2:17database and the next thing I'm going to
  62. 2:19do is to use an execute SQL task to read
  63. 2:23in the data from the mentor numbers
  64. 2:25table into something called an object
  65. 2:27variable so that I can then enumerate
  66. 2:30all the records within that
  67. 2:34variable before I can create my execute
  68. 2:38SQL task what I need first is somewhere
  69. 2:40to put the data and the place I'm going
  70. 2:43to put it is a variable which would be a
  71. 2:45temporary holding place for a set of
  72. 2:47records and the difficult thing about
  73. 2:49this variable is not creating it but
  74. 2:50choosing what data type to give it so
  75. 2:53I'm going to call it
  76. 2:56mentors and the data type is actually
  77. 2:59really should be record set but there
  78. 3:02isn't such a data type so I'm going to
  79. 3:04choose the vaguest thing I possibly can
  80. 3:06which is object and what will happen is
  81. 3:09integration services will allow me to
  82. 3:11put a set of rows inside that
  83. 3:13variable so now that I've got that I can
  84. 3:16create my execute SQL task to begin my
  85. 3:19package and what it's going to do is to
  86. 3:21load the
  87. 3:23mentors into a variable so that's
  88. 3:26exactly what I'll call it if I then
  89. 3:28configure that by clicking on it the
  90. 3:31first thing I need to do is to say which
  91. 3:33connection is using and it's using the X
  92. 3:35Factor one I then need to put in a SQL
  93. 3:39statement happily I've got one in my
  94. 3:42clipboard is going to select all of the
  95. 3:44three columns from the mentor numbers
  96. 3:46table and then what I need to do is to
  97. 3:48choose a record set to put that into and
  98. 3:52what I'm going to do is export the
  99. 3:53entire set of data into my
  100. 3:56variable now that's all very well and
  101. 3:58good that will create an entire record
  102. 4:01set but where will it put it to answer
  103. 4:04that question I need to go to my results
  104. 4:06set tab on the left hand side and add in
  105. 4:09a new
  106. 4:10mapping there could be several outputs
  107. 4:13from this execute SQL task I'm going to
  108. 4:17take the first one which as in most
  109. 4:20things in integration Services is
  110. 4:22numbered from zero so that is equivalent
  111. 4:24to the first set of rows returned from
  112. 4:27my execute SQL task in fact it's the
  113. 4:29only one one and the variable I'm going
  114. 4:31to store it in is the only one I've
  115. 4:33created so far which is the one called
  116. 4:36mentors so if I now choose okay to
  117. 4:38confirm that and run my package I think
  118. 4:42I'll probably just need to change it and
  119. 4:44set that to be my star package
  120. 4:46first what will happen when I run it is
  121. 4:49it will load up the data from the
  122. 4:50mentor's table into an object variable
  123. 4:54and for the moment you're going to have
  124. 4:55to believe me that that's what's
  125. 4:56actually
  126. 4:57happening what we now need to to do is
  127. 5:00to Loop over those records doing
  128. 5:02something to each in
  129. 5:04turn before I can create my fre
  130. 5:07container to Loop over the rows of my
  131. 5:10table or rather my variable I need
  132. 5:12somewhere to put the information so what
  133. 5:15I'm going to do is create no less than
  134. 5:17five
  135. 5:18variables the first three variables are
  136. 5:20all going to hold Columns of the current
  137. 5:23record in the AO numerator I'm leaping
  138. 5:26over so I'll call the first one a first
  139. 5:28name and make that into a string
  140. 5:33variable I'll call the second one last
  141. 5:35name and make that also into a string
  142. 5:40variable and the third one I'll call
  143. 5:43protes if I could spell it and that's
  144. 5:46going to be an integer it holds how many
  145. 5:47protes each person
  146. 5:50has the other two variables I'm going to
  147. 5:52create are going to be to keep track of
  148. 5:55which is the highest number of protes at
  149. 5:56any point in time and what's the name of
  150. 5:59the mentor who has that number of
  151. 6:01protes so I'll call the first one
  152. 6:04highest number which will hold the
  153. 6:06highest number encounted so
  154. 6:08far and the last one I'll call highest
  155. 6:11name which will hold the name of the
  156. 6:14person who has that number and these
  157. 6:17last two variables will be used in
  158. 6:19script and will keep changing as I come
  159. 6:21across a mentor who's have more protags
  160. 6:23than any yet
  161. 6:25encountered so having created those
  162. 6:27variables what I can now do is to create
  163. 6:31a for each
  164. 6:34container and what I'll do is feed the
  165. 6:36execute L SQL task into that and give
  166. 6:39this a different name so let's call
  167. 6:43this Loop over
  168. 6:48mentors and what this will do is read in
  169. 6:50each row one by one so to configure it I
  170. 6:53can double click on it and the first
  171. 6:56thing I need to do is say rather
  172. 6:57bizarrely I have to go to the second had
  173. 6:59to do this what sort of a collection it
  174. 7:01is I'm leaving over now there's a few
  175. 7:04here there's for each file which I
  176. 7:05covered in a pre previous tutorial and
  177. 7:08I'm going to cover most of these in the
  178. 7:10current tutorial so later on we'll look
  179. 7:12at for each item and we'll look at for
  180. 7:13each node list and we'll also look at
  181. 7:15for each Ado for each schema but what
  182. 7:19we're going to do for now is look at for
  183. 7:20each Ado enumerator which we'll look at
  184. 7:23each record in
  185. 7:24turn I then need to say which variable
  186. 7:27I'm going to use to get the information
  187. 7:30from and I'm going to use my M's
  188. 7:32variable which if you remember contains
  189. 7:34a whole set of
  190. 7:36rows what I can then do is create
  191. 7:38something called variable mappings and
  192. 7:41what I'm going to do is say that the
  193. 7:43first variable called first name will
  194. 7:45take the value of the first column in
  195. 7:48the set of
  196. 7:49Records the last name column will
  197. 7:52contain the value in the second
  198. 7:54column and finally the prot's column
  199. 7:57will contain the value in the third
  200. 7:59column so basically it's mapping the
  201. 8:01columns on one by one if I then choose
  202. 8:04okay to confirm that and if I run my
  203. 8:06package what you should see again is
  204. 8:08success but again you're going to have
  205. 8:10to trust me with this what it's doing is
  206. 8:12looping through every single Row in the
  207. 8:14underlying table in turn let's just have
  208. 8:16a look at that it's reading Cheryl into
  209. 8:18the first name variable Cole into the
  210. 8:21last name variable and protes into the
  211. 8:23Pro's variable then discarding all those
  212. 8:26values and going on to the next record
  213. 8:28and doing that for each of the nine
  214. 8:29records in turn until it's run out of
  215. 8:31rows at which point it will
  216. 8:33finish so what I now need to do is
  217. 8:36within my for each container actually do
  218. 8:39something with the information I'm
  219. 8:44gathering so what I'm going to do now is
  220. 8:47to add a script task within my container
  221. 8:52and what will happen is this will run
  222. 8:53every single Row in the underlying table
  223. 8:56which has been loaded into the object
  224. 8:58variable what it's going to do is the
  225. 9:00check for the highest number of
  226. 9:06proes and what I can now do is edit it
  227. 9:08to say
  228. 9:09how now I'm going to put three variables
  229. 9:13into this which are equivalent to the
  230. 9:14three columns for this particular record
  231. 9:18so if I click on that little icon I'm
  232. 9:20going to pass in the first name the last
  233. 9:23name and also the number
  234. 9:26protes and those will be readon
  235. 9:28variables because the code only needs to
  236. 9:30check
  237. 9:31them I'm also going to set two read
  238. 9:33write variables which are the highest
  239. 9:35name and the highest number so that at
  240. 9:37any time in running through the code
  241. 9:39those will always be set the maximum
  242. 9:41number of prot encountered so far and
  243. 9:43the name of the person corresponding to
  244. 9:45that so I'll choose okay to confirm
  245. 9:48those two things and now I can edit my
  246. 9:50script to say what it's going to do now
  247. 9:53at this point you could have had to sit
  248. 9:55watch me do a lot of typing so I've
  249. 9:57taken the liberty of putting everything
  250. 9:59in clipboard and pasting it
  251. 10:00in let's have a quick look at what
  252. 10:02that's doing the first three lines of
  253. 10:05code are reading in the first name last
  254. 10:07name and number prodigies from variables
  255. 10:10passed in into variables within my C
  256. 10:14script what I'm then doing is also
  257. 10:16reading what the current highest number
  258. 10:18is and if I've come across a number for
  259. 10:21this particular Mentor where the number
  260. 10:24prodigies is greater than the highest
  261. 10:25encounter so far I replace the current
  262. 10:28highest number with a new new one and
  263. 10:30that's what this line of code
  264. 10:32does I also store the name of that
  265. 10:34person by taking the first name and
  266. 10:36concatenating with a space in the last
  267. 10:38name so at any point I can be absolutely
  268. 10:40confident highest number holds the
  269. 10:42highest number of protes encountered so
  270. 10:44far and highest name holds the name of
  271. 10:46that
  272. 10:47person so if I come out of that and
  273. 10:50choose okay to confirm it I now just
  274. 10:52need to add a script task to the end and
  275. 10:55I can then confirm that this is actually
  276. 10:57doing the correct thing
  277. 11:01so what I can now do is add a script
  278. 11:03task to the bottom of my package and
  279. 11:06make sure that it is the last thing
  280. 11:07which runs and what this is going to do
  281. 11:10is display the name of the busiest
  282. 11:11Mentor so I'll call is something very
  283. 11:13similar to that to say what is going to
  284. 11:16do I can then double click on that as
  285. 11:18always to configure it and the script
  286. 11:20task is going to know need to know two
  287. 11:22bits of
  288. 11:23information the first one is the name of
  289. 11:25the mentor who's been the busiest who's
  290. 11:27got the most proes and the second thing
  291. 11:29is how many proes they
  292. 11:31had if I then choose okay to confirm
  293. 11:34those two variables being passed in I
  294. 11:36can then edit my
  295. 11:37script and again rather than having to
  296. 11:40watch me type things in I've copied it
  297. 11:42into the clipboard so I should just be
  298. 11:44able to paste it in
  299. 11:45there so what it's going to do is read
  300. 11:47in the names value of two variables the
  301. 11:49name of the person and the how many
  302. 11:51protes they had and then use a message
  303. 11:53box to display that information on
  304. 11:55screen so we should say busiest ment is
  305. 11:58Louis Walsh with 30
  306. 12:00proes so let's see if it does if I now
  307. 12:03come out of that and choose okay to
  308. 12:04confirm my script what I should now be
  309. 12:06able to do is to run this and I'm hoping
  310. 12:09i'll see a nice friendly message
  311. 12:12consisting of the me information I built
  312. 12:13up in the C
  313. 12:15script so I can choose okay and stop
  314. 12:17debugging that and that all seems to
  315. 12:20have
  316. 12:21worked it's time now to have a look at
  317. 12:23some of the other containers and other
  318. 12:25for each Loops you can use within
  319. 12:26integration services
  320. 12:30the type of FR Loop which is called an
  321. 12:33Ado enumerator which I just covered is
  322. 12:36probably the most useful in
  323. 12:38ssis but just for the sake of completion
  324. 12:41this part of the tutorial will show two
  325. 12:42or three
  326. 12:43more the first one I'm going to show is
  327. 12:45how to use loopover items now to do that
  328. 12:49I can embed the data within the package
  329. 12:51so what I'm going to do is I've taken a
  330. 12:53copy of my original package and I'm
  331. 12:55going to delete the execute SQL task so
  332. 12:58rather the information coming from an
  333. 13:00SQL Server table what I'm going to do is
  334. 13:02configure my loopover mentors so that it
  335. 13:04does something slightly
  336. 13:06different instead of leaping over the
  337. 13:08records in a SQL Server table what is
  338. 13:12going to do is leap over a set of
  339. 13:14items and in order for that to work I
  340. 13:16need to Define what the items are here
  341. 13:19I'm going to use exactly the same table
  342. 13:21just to make it easy to understand so
  343. 13:23I'll have three columns the first two
  344. 13:25being a string column and the last one
  345. 13:27being an integer so if I chose okay to
  346. 13:29confirm that and I'm now going to type
  347. 13:32in
  348. 13:33three potential mentors in The X Factor
  349. 13:37perhaps these are for a future Series so
  350. 13:40I'll have Nigel farage I'll have Adele
  351. 13:43Atkins who I think would be a busy
  352. 13:44person and I'll have Basel brush he
  353. 13:47tends to feature in a lot of my
  354. 13:50examples if I then go to variable
  355. 13:52mappings what I need to do as I did
  356. 13:55before is say that the first name
  357. 13:57variable maps onto the First Column I've
  358. 13:58created
  359. 13:59the last name to the second column and
  360. 14:01the proes to the third column so in fact
  361. 14:04the only difference with what I've done
  362. 14:06is rather than refer to a SQL Server
  363. 14:08table externally I've embedded that data
  364. 14:11within the actual
  365. 14:13task if I then choose okay just to show
  366. 14:16there's no trickery about this I'll just
  367. 14:17make sure that that is my startup object
  368. 14:20and if I now run that package it should
  369. 14:23produce exactly the same result although
  370. 14:25obviously with a different name and a
  371. 14:26different number of
  372. 14:28protes so using items is just an
  373. 14:30alternative to using SQL Server tables
  374. 14:33but on balance I would argue probably
  375. 14:35less
  376. 14:38useful we've looked now at how to Loop
  377. 14:41over uh tables in SQL server and also
  378. 14:44how to Loop over items what I'm now
  379. 14:47going to do is showare how to Loop over
  380. 14:48SQL Server
  381. 14:50schemas you can see what's possible by
  382. 14:52typing this command in SQL Server select
  383. 14:54star from information schema Dot and
  384. 14:58when you type in the dot which I'll now
  385. 15:00do you can see all the possible schemas
  386. 15:02you can um list out and loop over so
  387. 15:05what I'm going to do is Loop over all
  388. 15:06the tables and when I run that you can
  389. 15:09see there's four rows and what I'm going
  390. 15:11to do is store the third column so
  391. 15:13that'll be column number two from the
  392. 15:15point of view of integration Services
  393. 15:17I'm going to store that in a variable
  394. 15:18called table name and then write out
  395. 15:21those tables to a text
  396. 15:23file so let's see how this works in
  397. 15:27integration Services I've already
  398. 15:29created a package called looping over
  399. 15:32schemas and what I'm going to do is to
  400. 15:34add to that add to that a for each Loop
  401. 15:37and what this is going to do is Loop
  402. 15:39over
  403. 15:40tables I'll configure that as always and
  404. 15:44the sort of collection this is
  405. 15:46is for each ado.net schema row set in
  406. 15:50numerator and what that basically means
  407. 15:53is ssis will create a table in its
  408. 15:55memory of all the records within the
  409. 15:57schema you've chosen and then Loop over
  410. 15:59all those
  411. 16:01rows now I need to create a connection
  412. 16:03and this is where it gets a bit strange
  413. 16:06I could have done this separately but
  414. 16:07I'm going to create the connection from
  415. 16:09within this
  416. 16:11task and I need to create a new
  417. 16:14connection and the provider for this has
  418. 16:18to be this a SQL native
  419. 16:22client I'm sure Googling would tell you
  420. 16:25why and I'm sure at one point I knew why
  421. 16:27but for the moment for me it's enough to
  422. 16:28know that that's what I need to
  423. 16:30use my server
  424. 16:34name is that and I can choose my
  425. 16:37database I'm connecting to as X Factor
  426. 16:39and then choose okay and okay again and
  427. 16:43the scheme I'm going to import is all
  428. 16:44the tables from that
  429. 16:47database so having set that up I now
  430. 16:49need to create my variable mappings I
  431. 16:52haven't had the forite to create a
  432. 16:54variable called table name so just for a
  433. 16:56way of contrast what I'm going to do is
  434. 16:58create it on the f by choosing to create
  435. 17:00a new variable at this
  436. 17:01point I'll call my new variable table
  437. 17:05name it's going to be a string
  438. 17:08variable and I'll assign it to the third
  439. 17:11column in the schema which is column
  440. 17:14index number
  441. 17:15two so if I choose okay that will
  442. 17:18automatically create a table in memory
  443. 17:22corresponding to the scheme of tables
  444. 17:25within the xact database and store for
  445. 17:28each row the name of the table in the
  446. 17:30variable I've created called table
  447. 17:34name so it's time now to see how to use
  448. 17:36that within
  449. 17:39script what I'm going to do then is to
  450. 17:41add in a script task which will be
  451. 17:44executed for every single table found in
  452. 17:46the schema and what it will do is write
  453. 17:49out the table name to a text
  454. 17:52file and although that's a bit over the
  455. 17:55top as a name it certainly does describe
  456. 17:56what it's going to do if I then
  457. 17:59configure that I need to pass into my
  458. 18:01script task the name of the table and if
  459. 18:04you remember I created the variable name
  460. 18:05on the fly but it's been added to the
  461. 18:07collection of all the variables within
  462. 18:09this
  463. 18:10package I can then edit my script and as
  464. 18:13before what I've done is put the code
  465. 18:15into the clipboard to save home to sit
  466. 18:17watching me type it out here's what it's
  467. 18:19going to do it's going to use a variable
  468. 18:21called tame to hold the name of the
  469. 18:23table this time around the loop it's
  470. 18:26then go to write out to a text file
  471. 18:27called tables. TX
  472. 18:29the name of the table and then close the
  473. 18:32text
  474. 18:33file if I now close that and try
  475. 18:36executing my
  476. 18:38package what it should be doing is
  477. 18:40creating a text file the reason that
  478. 18:42runs slightly more slowly than you might
  479. 18:44have expected is it's not a very
  480. 18:45efficient way to do things keeping
  481. 18:47opening and then closing the text file
  482. 18:50and now stop debugging I should find
  483. 18:53that in Windows Explorer which I think I
  484. 18:56have open here I've got my file called
  485. 18:58tables. txt and if I double click on
  486. 19:01that to have a look you can see it
  487. 19:02contains lots and lots and lots of
  488. 19:03system files and then right at the
  489. 19:06bottom the four
  490. 19:08user uh sorry the four tables which
  491. 19:10aren't system
  492. 19:13tables if I'd had a gain a bit of
  493. 19:15foresight it might have been a good idea
  494. 19:17to add an additional check that the
  495. 19:20table scheme was dbo before writing out
  496. 19:22the information to the text
  497. 19:25file what I'm going to do now is to
  498. 19:28create a an overview of a package to
  499. 19:31import an XML
  500. 19:33file I could use the wiow website
  501. 19:35sitemap but it's too complicated it's
  502. 19:38got an opening line and it's got an
  503. 19:40additional attributes for the URL set
  504. 19:42tag none of which will all of which will
  505. 19:45stop it working so instead I'm going to
  506. 19:48use a tidied sitem file where I've got
  507. 19:51rid of all those extra features and it's
  508. 19:53just nice and simple and easy to read
  509. 19:55the three nodes are URL set URL
  510. 19:59and then
  511. 20:00Lo and so what I'll need to do is
  512. 20:02specify what those nodes are and it will
  513. 20:04automatically be able to import the
  514. 20:06websites contained in the middle of it
  515. 20:08and create that as a list in a text
  516. 20:10file so let's do that I've already got a
  517. 20:14package called loopover node list what
  518. 20:16I'm going to do is add to that for each
  519. 20:18Loop container which will Loop over the
  520. 20:22nodes what I can then do is configure
  521. 20:25that and say what sort of a loop it is
  522. 20:28so in this case it's going to be for
  523. 20:30each node list in
  524. 20:33numerator it's going to get this
  525. 20:34information not by type typing it in but
  526. 20:37from a file so I need to create a new
  527. 20:39connection to that file and because it's
  528. 20:42an existing file I'll be able to find it
  529. 20:45and there it is on my hard
  530. 20:48disk what I now need to do is specify
  531. 20:51the outer path string so basically the
  532. 20:53nesting of the nodes and this
  533. 20:56is starting with URL set
  534. 21:00within that I've got
  535. 21:02URL and within that I've got
  536. 21:05L my variable mappings I'm going to
  537. 21:08create a single variable on the Fly
  538. 21:10which I'll call node
  539. 21:13name and that will tie into the first
  540. 21:15bit of information returned and probably
  541. 21:17the only one as
  542. 21:19well so I've now got a position where
  543. 21:21it's going to Loop over all the nodes in
  544. 21:22that file to test it out as always I
  545. 21:25need to add a script task within that
  546. 21:28container so that each for each node it
  547. 21:31will write it out to a text
  548. 21:34file so I'll call my script task write
  549. 21:37out node to text file if I then
  550. 21:40configure that I need to pass into it
  551. 21:43the variable which I've just created
  552. 21:45node name which will contain each URL
  553. 21:47within the XML sitemap
  554. 21:50file I can then specify my script and
  555. 21:54yet again I've got the code in my clip
  556. 21:58board so I should just be able to paste
  557. 22:00it in there it's going to get a variable
  558. 22:02to find out the name of this node and
  559. 22:05then write it out a file called nodes.
  560. 22:08txt so let's see if it works if I choose
  561. 22:10okay to confirm that I've set this
  562. 22:12already to be my startup package so I
  563. 22:14should just be able to play that and
  564. 22:16it's looking like it's worked but as
  565. 22:19always the proof will be did it create
  566. 22:21the text file that file definitely
  567. 22:24wasn't there before and if I look at it
  568. 22:26you can see it contains the three
  569. 22:28website addresses so it
  570. 22:31worked you can find lots more training
  571. 22:34resources on Microsoft Office sequel
  572. 22:36server andet training at
  573. 22:39www.wis al.uk

About this transcript

This page contains the full transcript of SQL Server Integration Services (SSIS) Part 12 - Other Foreach Loops by WiseOwlTutorials, generated from the public captions YouTube serves with the video. The transcript has 4,052 words across 573 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.