At the beginning of the project I created 3 variables with Scope size Package:
I then created a SQL EXECUTE TASK:
Checking this query on SQL SERVER returns:
Setting EXCEL source as the variable which will get the file location:
Now on SSIS, I checked both ways
64bit debugging as true and as false. But rest of execution works when it is false, therefore I changed it back to false and saved it.
This is the Flow of project:
Whenever I Execute, it gives me this error:
How to resolve this error. It has taken my whole day but i am still clueless about it. I am new to SSIS. Help will be appreciated.
Edited:
Please see the result set of SQL EXECUTE TASK:
I noticed that the DelayValidation is False in your Excel Connection String.
You have to make DelayValidation=TRUE for both Excel Connection String and the Data Flow Task within which the excel connection is used.
Hope this would help you out.
After alot of struggle i've resolved the issue, but i am really thankful to the people who have given me some extra knowledge about this Tool and some of their guidance must have worked as well at some point as i have set my things accordingly.
what i did at last, which made it work and running were:
1) In package property, under Execution set DelayValidation to True. After following:
(Above, Viki helped me also by setting property DelayValidation to True, but in Excel Connection Manager which counts.)
When Building your ExcelFilePath in an expression (or any part of it I guess), make sure the "combination of" variables contains the full path to reach the file, otherwise you will not be able to open the excel source, since it does not find a file.(should be fine at runtime).
Secondly it could be that the values that was used in the original file is not the same in the "new file/next file". Meaning excel wants to convert the column from Unicode to double-precision float or something.
Try adding this in your ConnectionString in the properties window.
IMEX=1
like "*;HDR=YES;IMEX=1";
This could help with these types of mixed columns where it contains numbers and alpha values (causing conversion issues).
HTH
Related
I have inherited a spreadsheet with a macro which isn't working from someone who's left the company.
I didn't design it, but am trying to work out why it appears to be not working (in terms of not generating the correct outputs).
I noticed that there is a section which uses an OleDb connection to run a T-SQL query and update a particular sheet, beginning with the line:
With ActiveWorkbook.Connections("Daily_Production").OLEDBConnection”
and ending with the line:
ActiveWorkbook.Connections("Daily_Production").Refresh
The thing is, there is no worksheet in the book (including in hidden sheets) called "Daily_Production". However, it does not appear to generate an error on the "refresh" line.
I'm surprised that this didn't generate an error. Surely if there is no sheet with that name, it must generate an error?
Or am I missing something? I don't have much experience with OleDb connections - is it possible that it fails to generate an error and simply doesn't bring anything through?
Option 1:
The name of the connection is "Daily_Production", it's not a sheet's name. Simply write "Daily_ProductionALEALEALE" in your code and see if there is an error. If there is one, then Option 1 is correct :)
Option 2:
You have On Error Resume Next written somewhere.
Is there a way to use a user defined variable to define a connection string for an SSIS OLE DB Connection?
1) I had originally set it up to use a package parameter.
2) I execute the SSIS Package from a file using xp_cmdshell in a SQL stored proc, but found out that package Parameters are read only.
I got this error ... "Changing the Value of a variable failed because it is a parameter variable. Parameter variables are read-only"
3) So it looks like I need to use variables... However, I don't see a way to use a variable for the connection string. When I use the 'Parameterize' option for the connection, it only gives me the option to select a parameter, not a variable.
Any thoughts? Thanks!
I am sure from the comments that you are going to get a lot of advice but you asked how do you use a variable as a connection string so to answer that part. It is fairly easy,
add the Package Variable (right click in control flow on empty space and choose variables will bring you where you can add one)
Choose the Connection Manager and then go to properties (I use right click properties)
click in Expressions and then the ... button
select "ConnectionString" in Property and set your expression to your variable or whatever you desire.
Yes, Matt's answer is correct. You can use a user defined variable in expression of the connection manager.
This has a limitation. This variable will work only for this package only.
You should make a project parameter instead of a user defined variable So that you can configure any of your package of the project in future also.
You can move your connection manager at project level if the same connection is being used for multiple packages.
I am transferring a very large table that has a column called EndOfSessionTime and I would like to get a var LastSess=MAX(EndOfSessionTime) from the destination and transfer only rows WHERE EndOfSessionTime > LastSess.
I set the variable using a ScriptTask in the control flow, but I can't seem to find a straight-forward way to use the variable in a data source.
2 options:
1) Stuff your entire SQL Query into a variable, and in the OLEDB Data Source, choose "SQL Command From a Variable"
2) Use parameters in your SQL query. Indicate a placeholder for a parameter with a Question Mark character, and then hop over to the Parameters tab to assign the variable to the parameter. Google "SSIS Data Source Parameters" for tutorials and examples.
To use connection parameters is a must in SSIS, but I had a heck of a time to find how. Microsoft made up a word "Parametrization" and using it as a search term seems to be the only way to come up with how.
The connection manager names at the bottom of the SSIS desktop are actual objects. Right-clicking on one and selecting "Parametrization" is how connection parameters are set. One more note on that: There is no "Apply" on this dialog, so set one paramter at a time, OK, then right-click-Parametrize again. If you set a parameter and go on to the next one without clicking OK, the first one will be lost.
I am loading 30 files at a time using a MULTIFLATFILE connection from SSIS into a raw table. These files are constantly coming in and a job loops through to exec the package and pick these up. Some of the files can have bad data every once in a while. I am having trouble when one of the 30 files is bad. I have no way to know which of the files actually failed so I can move it into a Suspect folder, roll the other 29 files back into my Input folder and try again. Can't find any info on the net on this, or in Microsoft's documentation. Any help appreciated. Thanks.
I would rebuild your Connection using the FLATFILE type, then use it within a Foreach Loop Container that sets a Variable to the file name. In the Connection definition, you can use an Expression to set the ConnectionString property to your Variable value.
Then you can use that Variable value to take whatever action you need when your "bad" condition occurs.
Configure the FileNameColumnName property of the Flat File Source component. That will add a column containing the file name.
I have inherited an existing SSIS package that imports flat file data into my SQL Server 2005 database. I need to change the data type of the "Gross Sales" column from "numeric" to "currency". When I change the data type and export the package the data type remains numeric.
I have also tried creating a new flat file connection to use in the same package, but for some strange reason it still remains numeric instead of "cy" currency. I guess there is something "stuck" in some other area that is forcing the last column to remain numeric?
Does anyone know the trick to changing the data type for a flat file data source?
Thanks for all the help everyone. It looks like in my case I needed to delete and re-add the flat file source step and add a new flat file connection manager. Maybe there was a better way to do it and I was just clicking in the wrong order in the GUI maze in SSIS. :D
Did you try adding a Data Conversion Transformation Task in your DT?.
e.g. You can modify the Gross Sales as
Gross Sales, Gross Sales_CONV Choose Currency [DT_CY] as your currency.
I've also found that sometimes changing ValidateExternalMetaData to false on the Source and Destination properties will help.
When some changes don't apply, even though there's no apparent reason for the data to be "stubborn" and resist change, you should try closing Visual Studio and open it back again.
In my case it works for this mentioned failure, as well as when the Script Editor won't open. It looks like some information remains on cache and prevents some functionalities from working properly.
In my case I had a lot of columns in my flat file connection manager, so deleting the connection and adding those columns back again one by one was the last thing I would try.