Тёмный
No video :(

15 Execute SQL Task in SSIS | Use variables in Execute SQL task in SSIS 

Learn SSIS
Подписаться 33 тыс.
Просмотров 78 тыс.
50% 1

Execute SQL Task in SSIS | Use variables in Execute SQL task in SSIS
Download the file\script used in the Video from below link
drive.google.c...
SSIS Tutorials: • SSIS Tutorials
SSIS real time scenarios examples: • SSIS real time scenari...
SSIS Interview questions and answers: • SSIS Interview questio...
Execute SQL Task in SSIS
How execute SQL Task works in SSIS?
Why we use execute SQL task in SSIS?
How do I run an SQL file in SSIS?
What is the difference between execute SQL task and execute SQL task?
Happy Learning.
If you have any questions or suggestions please comment on the video or write to me at “aqil33@gmail.com”

Опубликовано:

 

5 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 103   
@data9051
@data9051 2 года назад
ERROR: [Execute SQL Task] Error: Executing the query "insert into persons values (?.?.?)" failed with the following error: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. SOLUTION: I had the same issue and fixed this issue. In the video he actually copy pastes a different Query and you can see it for a short second to be able to copy it. Deleting GO and CREATE TABLE parts of the query wasn't enough because I needed to actually change the GO statement to 'ON [PRIMARY]' Query below: IF NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = N'Person') CREATE TABLE PERSON( ID INT IDENTITY, NAME VARCHAR(50), GENDER VARCHAR(1), AGE INT) ON [PRIMARY] INSERT INTO PERSON VALUES (?,?,?)
@learnssis
@learnssis 2 года назад
Its good to know that you were able to fix it.
@AOAMuse
@AOAMuse 7 месяцев назад
Or just remove GO
@Mohamed-yb2xy
@Mohamed-yb2xy 6 месяцев назад
hi i get the same error o tried different solution but i did not solve the probleme can you help me this is the query i use : INSERT INTO SSISParameterValues (ParameterName, ParameterValue, CreatedDate) VALUES ('PackageName',CAST(? AS varchar(500)), GETDATE()); i tried to not use parameters in the query and it runs correctly but when i use parameter or variable i get this same error ?
@LucasMaster
@LucasMaster Год назад
if you have problems on the second sql statement (using variables), remove the 'go' from the query
@LifeInMelbourne31
@LifeInMelbourne31 4 месяца назад
Great find man, great help😊
@KRaJWanders
@KRaJWanders 3 месяца назад
Thanks, that helped
@nivetha.meceskct6693
@nivetha.meceskct6693 3 года назад
Aqil you are the best SSIS person the video is very much helpful you have covered variable and parameters as well with execute SQL task....thanks a lot for your help
@learnssis
@learnssis 3 года назад
So nice of you.
@mdsamiulislam2522
@mdsamiulislam2522 3 года назад
Aqil, My dear brother, i am samiul from bangladesh... really helpful your guide line
@learnssis
@learnssis 3 года назад
Thank you Samiul for watching the videos.
@christopherhorton9198
@christopherhorton9198 7 месяцев назад
Thanks. That was very informative. Keep it up !
@learnssis
@learnssis 7 месяцев назад
Thank you Christopher.
@sanjeevaranisalluri9976
@sanjeevaranisalluri9976 2 года назад
[Execute SQL Task] Error: Executing the query "create table persons (id int,name varchar(20),gend..." failed with the following error: "There is already an object named 'persons' in the database.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
@learnssis
@learnssis 2 года назад
In the execute sql task, before creating the Persons table add this clause IF NOT (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'Persons')) Now Persons table will only be created if it does not exists in the database.
@vijaybodkhe8379
@vijaybodkhe8379 2 года назад
Thank you for sharing Knowledge
@learnssis
@learnssis 2 года назад
Thank you Vijay.
@sathiyamoorthi9224
@sathiyamoorthi9224 8 месяцев назад
Hi Aqil ,your video all are very useful.can you please share any video it,s getting data from one table based on smallest id and max id between data only daily .the daily trucate load. Thanks in Advance
@learnssis
@learnssis 8 месяцев назад
Not sure if I got your question currently. 1. First you can use execute sql task to truncate the data from destination table. Put a truncate query in that. 2. Use a data flow task to pull the data from source table. And Use the OLE DB source, inside OLE DB source select sql command option and write your query similar to below one, it will select data ranging from min to max declare @min_id int, @max_id int set @min_id = (select min(id) from [Customer]) set @max_id = (select max(id) from [Customer]) select * from Customer where id between @min_id and @max_id 3. Now use the OLE Db destination to write the data to a sql server table that you truncated in step 1.
@sathiyamoorthi9224
@sathiyamoorthi9224 8 месяцев назад
Thanks Aqil
@sathiyamoorthi9224
@sathiyamoorthi9224 8 месяцев назад
@@learnssis I need to check duplicate data between the min id and Max I'd in the table .if any possible to store min id and Max Id store in variable.could you pls let me know Thanks for understanding!
@learnssis
@learnssis 8 месяцев назад
@@sathiyamoorthi9224You can write a query similar to below in execute sql task and select the option single result set declare @min_id int, @max_id int set @min_id = (select min(id) from [Customer]) set @max_id = (select max(id) from [Customer]) select @min_id, @min_id Now in the result set, add first result set name 0 and select the ssis variable that will hold the min id and the add another result set and name it as 1 and select another ssis variable that will hold the max id. To select only the distinct records you can see how you can select only distinct records. You can use row_number function along with cte to select the unique records. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-8ohs43g9X5Y.html ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-WRCu-7avec8.html
@sathiyamoorthi9224
@sathiyamoorthi9224 8 месяцев назад
@@learnssis Thanks you!
@sathiyamoorthi9224
@sathiyamoorthi9224 8 месяцев назад
Hi Aqil, Thanks for videos, i have one doupt. To find duplicate data Select name,gender,memberid,,,,count(1 ) from ABC Group by name,gender,memberid Having count(1)>1 I need to insert above query duplicate result set in temporary table and mail send to user also copy of duplicate result set . After that If find any duplicate data i need to update . Could you pls let me know how will achieve in ssis package Thanks in Advance!!
@VishalJaybhaye-kq4hh
@VishalJaybhaye-kq4hh 2 месяца назад
SIr it is giving me this error when we created parameters for Ram person, Execute SQL Task: Executing the query "insert into Person values (?,?,?)" failed with the following error: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. Task failed: Execute SQL Task. Can u pls tell me the issue?
@learnssis
@learnssis 2 месяца назад
Are you using Go statement inside the query ? Do not use any go statements.
@dhirendramaurya5361
@dhirendramaurya5361 Год назад
Awesome all videos
@learnssis
@learnssis Год назад
Thank you Dhirendra.
@user-vy5ck5sv2l
@user-vy5ck5sv2l Год назад
Hi Aqil, if i want to insert only the name. what format should be used. I created a table with one column (name alone), when i give the below insert under expression, the evaluate expression throws error. insert into Person values (@[User::Name] )
@learnssis
@learnssis Год назад
You would need to write "insert into Person values '"+ @[User::Name] +"' "
@SoftwareCouple
@SoftwareCouple 2 года назад
Sir after giving the server name in the top for the connection in the below drop down i am not able to find the database name.please help me
@learnssis
@learnssis 2 года назад
For Database Name it will be Initial_Catalog
@yuvanak1028
@yuvanak1028 3 года назад
Nice Lecture. But when I have tried using parameters. I was getting the following error. "Multi-step OLE DB operation generated errors. Check each OLE DB Status value, if available. No work was done ". Possible reason for failure with query,"Resultset" property is not set correctly. Can you please help.
@learnssis
@learnssis 3 года назад
Are you returning any value from execute sql task and assigning it to an SSIS variable ?
@abhi-vt2xg
@abhi-vt2xg 2 года назад
@@learnssis [Execute SQL Task] Error: Executing the query "insert into persons values (?.?.?)" failed with the following error: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. ------- THIS ERROR IM GETTING
@Jigyasuh
@Jigyasuh 2 года назад
@@learnssis Same error, what to do?
@Jigyasuh
@Jigyasuh 2 года назад
Same error what to do?
@abhi-vt2xg
@abhi-vt2xg 2 года назад
Hi sir help out with this error
@rightplacetoeat7420
@rightplacetoeat7420 5 лет назад
Hi sir , Thanks for your video.You made a such a nice video. If you dont mind please make a video on real time example bY using the Execute sql task ..Thanks in advance
@learnssis
@learnssis 5 лет назад
Its good to know that you liked the video. Sure I will try to make a video as per your suggestion. Thank you.
@learnssis
@learnssis 5 лет назад
Its good to know that you liked the video. Sure I will try to make a video as per your suggestion. Thank you.
@oshriamir
@oshriamir 10 месяцев назад
Hi all , i got this error : [Execute SQL Task] Error: Executing the query "insert into NPerson values (?,?,?)" failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. What i can do ?
@learnssis
@learnssis 10 месяцев назад
Are you providing 3 parameters to this query ? insert into NPerson values (?,?,?)
@MVinodKumar-tt1tu
@MVinodKumar-tt1tu 10 месяцев назад
Hello Sir, First Doubt: So through variables in this case each time we can enter only each record from variables into table? or can we enter multiple records at single time using variables?.... Second Doubt: INSERT INTO PERSONS VALUES ('"+ @[User::Name] +"','"+ @[User::Gender] +"','"+ (DT_WSTR,12)@[User::Age] +"') In this while using variables to enter the values into table, why we used single quote and double quote both. First single quotes and inside it double quotes and inside variable.... Please explain sir
@learnssis
@learnssis 10 месяцев назад
1. At a time we can insert only one record from variable, because at one time you can store only one value in a variable. 2. If we need to use the string variable inside expression, then the syntax is that we should first write a double quote ", then + sign then drag and drop the variable then put the + sign then put the double quote ". This way we will get the value from variable. however if you have noticed if you need to insert a string value into a sql server table then we enclose the string in a single quote, same is the case here that we got the value but now to enclose the value within single quote we need to put a single quote ' before the double quote " and then in the end put a single quote ' after double quote ".
@sonelsharma1687
@sonelsharma1687 Год назад
Hi, Getting error regarding parameters. Location_ID, Long,0 Location_Name,varchar,0 Sales_start_Date,Date,0 Total_Sales,Long,1 Kindly review
@learnssis
@learnssis Год назад
Hi Sonel, Can you email me with all details like your query, variables screnshot and parameters screeshot to aqil33@gmail.com then I should be able to tell what is going wrong here.
@abhi-vt2xg
@abhi-vt2xg 2 года назад
Please do comment that expression which you used for dynamic entry
@learnssis
@learnssis 2 года назад
Hi, Can you try this one INSERT INTO PERSON VALUES('"+@[User::Name]+"', '"+@[User::Gender]+"', "+ (DT_WSTR,12) @[User::Gender]+") The Rule is simple. 1. When you start writing any code start the code with double quote " and close it with double quote " as well. 2. Any string value will be surrounded by single quote followed by double quote, then put a + sign and then put SSIS variable there and after it, again put a + single, followed by double quote single quote like below ' " + @[User::FILEPATH] + " ' 3. Any Int SSIS variable will be surrounded by just double quote. So put a double quote " then put a + sign, then place the SSIS variable there and put the + sign there and then put the double quote there. You also need to convert the Int to string so that it can be used in the expression. An example is below " + (DT_WSTR,12) @[User::COUNT] + "
@sachinnavik4904
@sachinnavik4904 2 года назад
Hello sir i am not able to see integreation servuce catalog node in ssms my sql server is 2019
@learnssis
@learnssis 2 года назад
Right click on Integration services catalog and click on Create Catalog (7:43) ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-xaBIYxe5qVA.html
@LearnYouAndMe
@LearnYouAndMe 6 месяцев назад
please provide sql expression script in your description. I am not to write it in right way.
@learnssis
@learnssis 6 месяцев назад
You can download the script from the link in the description of the video if not exists(select * from information_schema.tables where table_name = 'Person') create table Person(Id int identity, Name varchar(50), Gender varchar(1), AGE int) go insert into Person values ('ABHISHEK','M', 35) --------------------- if not exists(select * from information_schema.tables where table_name = 'Person') create table Person(Id int identity, Name varchar(50), Gender varchar(1), AGE int) insert into Person values (?,?,?) ---------------------- "if not exists(select * from information_schema.tables where table_name = 'Person') create table Person(Id int identity, Name varchar(50), Gender varchar(1), AGE int) insert into Person values ('"+ @[User::Name] +"','"+ @[User::Gender] +"','"+(DT_WSTR,12) @[User::Age] +"') "
@sureshareti2843
@sureshareti2843 3 месяца назад
Bhaiyya can we use variable object type in expression in ssis? If yes please tell how to do that
@learnssis
@learnssis 3 месяца назад
Sorry, don't know if we can use it, never tried that.
@sureshareti2843
@sureshareti2843 3 месяца назад
@@learnssis no worries bhaiyya I tried it but it's not working
@iveebhuyan
@iveebhuyan 3 года назад
nicely explained
@learnssis
@learnssis 3 года назад
Thank you so much Bhuyan for appreciating the video.
@manishbaburaisingh1985
@manishbaburaisingh1985 5 лет назад
AWSM
@Jigyasuh
@Jigyasuh 2 года назад
Hi Aqil, I got this error while executing using variable: "[Execute SQL Task] Error: Executing the query "INSERT INTO PERSONS VALUES(?,?,?)" failed with the following error: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly." Please suggest what to do?
@caravindpandi
@caravindpandi 2 года назад
have u found the solution for this error? I too got this error
@Jigyasuh
@Jigyasuh 2 года назад
@@caravindpandiNo
@MpT_Head
@MpT_Head Год назад
I had the same. I removed the 'go' from the query and it worked fine. I had reused the first query and just changed the values but when I checked, there's no 'go' in the second 'variable' query. Did you do the same as I did?
@rammohan1935
@rammohan1935 2 года назад
Hi, i have one doubt for last approach how do we pass variables. can you explain me
@learnssis
@learnssis 2 года назад
In this video I have shown how to pass variables to sql query. You can write the sql query in expressions, under sql query and then you can use system or user defined variable there.
@rammohan1935
@rammohan1935 2 года назад
@@learnssis my query is in .SQL file
@learnssis
@learnssis 2 года назад
@@rammohan1935 In that case, you would need to read the file in the script task using C# code and then if you know what vales you want to provide then you can replace the values with ssis variables using C# code there is a replace function in C# which can be used and then you can assign the final result \ final query to an ssis variable which can be executed using an execute sql task or you can execute it inside script task as well, its kind of pure C# work, there are no inbuilt tasks in ssis to perform this task.
@rammohan1935
@rammohan1935 2 года назад
@@learnssis thank you very much for information
@rammohan1935
@rammohan1935 2 года назад
I approached this way but getting error like Error Failed to lock variable
@learner_SSIS
@learner_SSIS Год назад
Lovely Sir 😀
@sanjeevaranisalluri9976
@sanjeevaranisalluri9976 2 года назад
I have executing error plz tell me how can I resolve this
@learnssis
@learnssis 2 года назад
In the execute sql task, before creating the Persons table add this clause IF NOT (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'Persons')) Now Persons table will only be created if it does not exists in the database.
@kishanbhise4733
@kishanbhise4733 2 года назад
Sir it will be better if you make the video little more lengthy but explanation needs to be little slower I mean the navigation was too fast to catch
@learnssis
@learnssis 2 года назад
Okay, got it. Will take care for future videos.
@phaninath8237
@phaninath8237 7 лет назад
nice video bro can u give me the query to connect multiple Db.
@learnssis
@learnssis 7 лет назад
Hi Phani, thanks for your question. In SSIS if you want to connect to a SQL Server database then you can drag and drop a Data flow task from SSIS toolbox into Control Flow window. After that double click the data flow task and if you are looking to read data from sql server database, then drag and drop an OLEDB Source from Data Flow Sources to the Data Flow Task Or if you want to write data to SQL Server then you can drag and drop the OLE DB Destination into the Data FLow Task. Once done you can connect to a SQL server database. If you need to connect to multiple databases at a time then you can drag and drop multiple OLEDB sources into the Data FLow Task. You can see my video "Copy data from one sql server instance to another" to see how to connect to a sql server database. Similarly you can either drag and drop multiple Data Flow Task and do the same thing what I have done for one Data Flow Task ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-z78-R-SAZK4.html
@learnssis
@learnssis 7 лет назад
Okay, I have connected to multiple databases at a time in below video, just take a look at this video if it can be of your use ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-z78-R-SAZK4.html
@phaninath8237
@phaninath8237 7 лет назад
thanks bro
@Maths-learn123
@Maths-learn123 2 года назад
Hi SQL code was not clear and can u the snd the code in Google drive also the file is not there
@learnssis
@learnssis 2 года назад
Sorry for that. I will try to find the code.
@Maths-learn123
@Maths-learn123 2 года назад
I had error that "there is already an object named person in the database" when iam trying excute the variables it was throwing the above error
@Maths-learn123
@Maths-learn123 2 года назад
@@learnssis the video was not properly zoomed the code is not clear kindly pls make this video clarity or provide the code
@learnssis
@learnssis 2 года назад
@@Maths-learn123 you can put below code before the drop statement that if person table will be there it will drop the person table IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'Person')) BEGIN drop table person END go
@learnssis
@learnssis 2 года назад
@@Maths-learn123 Okay, I will try to make another video on this topic.
@krishnachaitanyareddy2781
@krishnachaitanyareddy2781 3 года назад
wow you can insert the sql statements with 5 different ways.
@learnssis
@learnssis 3 года назад
Glad you found it useful.
@asadnaseer7291
@asadnaseer7291 4 года назад
HI, I want to read from sql server database and convert the output into csv and place that into FTP server every 10 minutes, how can we do this? Can you please guide or make a video on this?
@learnssis
@learnssis 4 года назад
Hi, you need to use a data flow task and load the data from sql server to csv and then add a FTP task to move the file to FTP server. Below video can do the export thing. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-n94-pFXP8eA.html I don't have access to FTP server, thus I did not made a video on moving data to FTP server, probably you can find a video on moving file to FTP server. Then you can schedule the SSIS package to run on a particular schedule. I have a video to schedule the ssis package using SQL Agent job. Thanks.
@asadnaseer7291
@asadnaseer7291 4 года назад
@@learnssis Thank you very much for your response. Can you please mention the link for scheduling also? Then I have to create another package for FTP task, as I am unable to direct Flat File output to the FTP task
@learnssis
@learnssis 4 года назад
@@asadnaseer7291 Below link can help you to schedule an SSIS package ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-qrV2FbQpU3I.html
@aniketshende4220
@aniketshende4220 2 года назад
bhai smjha rha hai ya read kr rha hai script tu
@learnssis
@learnssis 2 года назад
Sorry bhai, I know in some videos I was very quick, but I think if I create the videos lengthy then people also don't watch 😀
@mrtorque4353
@mrtorque4353 2 года назад
bro ur eating words while telling i am not able to understand what ur saying
@learnssis
@learnssis 2 года назад
Sorry bro, yeah this is one of my oldest video and I am too quick for it. I am trying to improve.
@learnssis
@learnssis 2 года назад
I have created one more video recently on execute sql task you can take a look at it ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-_8nbAMHXGIQ.html
@antwanwimberly1729
@antwanwimberly1729 7 месяцев назад
@@learnssisyou are doing a phenomenal job teaching us the SSIS way. No worries!
@learnssis
@learnssis 7 месяцев назад
@@antwanwimberly1729thank you.
Далее
7 Database Design Mistakes to Avoid (With Solutions)
11:29
05 Hindi | Execute SQL task in SSIS
38:21
Просмотров 1,9 тыс.
Create an ETL package with SSIS! // step-by-step
13:11
Просмотров 157 тыс.
Database Indexing for Dumb Developers
15:59
Просмотров 55 тыс.