SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Script Task to check file existance is OK in Visual Studio but fails when Deployed


Script Task to check file existance is OK in Visual Studio but fails when Deployed

Author
Message
Tim Pain
Tim Pain
SSC-Addicted
SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)

Group: General Forum Members
Points: 436 Visits: 1055
Phil,

As mentioned above, if its called via the Agent, then SQLAGENT.
It's is called directly or via the Catalog.Create stuff, then CALLER_INFO is blank.
Thanks


Tim
Tim Pain
Tim Pain
SSC-Addicted
SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)

Group: General Forum Members
Points: 436 Visits: 1055
Sorry, misread what you had asked.
Caller is me "MicrosoftAccount\MyName@gmail.com"


Tim
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)

Group: General Forum Members
Points: 96052 Visits: 21950
Tim Pain - Thursday, October 12, 2017 10:54 AM
Sorry, misread what you had asked.
Caller is me "MicrosoftAccount\MyName@gmail.com"

Is that account a local admin?



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Thom A
Thom A
SSC-Dedicated
SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)

Group: General Forum Members
Points: 33199 Visits: 11355
Sorry, I hadn't noticed that this was all being run locally, so no, network guy is the wrong person.

If, however, the OP can use DTExec to do it, this still likely points to Kerboros Double hop. Even if you are running locally (SSMS on the same Machine as the SQL Instance, which, in turn is the same machine the file is on) the double hop issue will still arise. The credentials are still going SSMS->SQL Server->File System, it doesn't matter if it's all the same server, at the point of SQL Server-> File System you're at the point of the "double hop". I would put money on betting that if the OP tried to execute the task via Agent it would also work.

I'm not going to lie, I have no idea on how to resolve the matter of the double hop. Sorry (I realise not being helpful there). I am, however, intrigued to hear if it does work via Agent (as I suspect).


Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does :-P

Please always remember to encapsulate your code in IFCode Markup. For example [code=sql] [/code].
Click here to read Jeffs Guide on how to post SQL questions, and get swift and helpful answers from the community
Tim Pain
Tim Pain
SSC-Addicted
SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)

Group: General Forum Members
Points: 436 Visits: 1055
Phil - Yes the account is local admin

Thom - Everything is on the laptop, so I should be able to kill the WiFi connection and it should still run.
Using the Agent, I get the same results as executing the Package i.e.: It runs without errors, but fails to find any of the 6 files and then outputs 6 records to the error log.

Thanks


Tim
sgmunson
sgmunson
SSC-Dedicated
SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)SSC-Dedicated (31K reputation)

Group: General Forum Members
Points: 31942 Visits: 5149
Create another package to do nothing but list the files in that directory into a table and see what happens. That might make it more clear as to where the problem comes from.

Steve
‌(aka sgmunson)
Smile Smile Smile
Health & Nutrition
Tim Pain
Tim Pain
SSC-Addicted
SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)

Group: General Forum Members
Points: 436 Visits: 1055
Steve, thanks for your suggestion.

One thing I have noticed in Visual Studio 2015, is that the Script Task seems to occasionally loose its settings and reverts to Visual C#, the Read Only and ReadWrite variables and the custom code disappear. So I do wonder if this is also happening when the project gets deployed? As during deployment, sometimes it does complain about Script Tasks and mismatching versions. I'm using VS 2015 with SQL Server Data Tools 14.0.61707.300 and deploying to SQL 2016.

So my workaround, is to do away with the Script Task and on the ForEach loop and the FTP task within the loop, set the MaximumError Count to 0 and then attach the creation of the Error Log of missing files to the Failure output of the FTP task. This seems to work with my test data, with 4 image files being FTPed and 2 image file errors (missing) being written to the error log - which is exactly what I'm expecting.

So unless somebody has got a brilliant suggestion, I can live with what I've now got.

Many thanks for you help and suggestions


Tim
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)

Group: General Forum Members
Points: 96052 Visits: 21950
Tim Pain - Monday, October 16, 2017 2:25 AM
Steve, thanks for your suggestion.

One thing I have noticed in Visual Studio 2015, is that the Script Task seems to occasionally loose its settings and reverts to Visual C#, the Read Only and ReadWrite variables and the custom code disappear. So I do wonder if this is also happening when the project gets deployed? As during deployment, sometimes it does complain about Script Tasks and mismatching versions. I'm using VS 2015 with SQL Server Data Tools 14.0.61707.300 and deploying to SQL 2016.

So my workaround, is to do away with the Script Task and on the ForEach loop and the FTP task within the loop, set the MaximumError Count to 0 and then attach the creation of the Error Log of missing files to the Failure output of the FTP task. This seems to work with my test data, with 4 image files being FTPed and 2 image file errors (missing) being written to the error log - which is exactly what I'm expecting.

So unless somebody has got a brilliant suggestion, I can live with what I've now got.

Many thanks for you help and suggestions

I am using the same SSDT and SQL Server versions as you. And only last week, I experienced the 'disappearing script task' problem you appear to be describing. Twice, with the same script (which, luckily, I was able to recover from source control). It seems that, under certain circumstances, the script task 'initialises' itself. So far, this has happened only during development, not deployment.
Regarding your comment about mismatched versions of script tasks during deployment, I have not seen that. Are you able to post the exact text of the message you are seeing?
One idea I might try would be to write a logging row to a SQL table somewhere, both at the start and then at the end of your script, just to confirm that it is being executed.



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Tim Pain
Tim Pain
SSC-Addicted
SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)

Group: General Forum Members
Points: 436 Visits: 1055

For me the 'disappearing script' is a nuisance, but not big deal, as I only have one Import and now only one line of code. But in other circumstances, it could be a real pain.

As suggested, I added some code to create a log entry at the start and finish of Script code sections. And again hit the issue of deploying it and then the version mismatch.
So I re-installed the SSDT tools into VS and checked I was still deploying to SQL Server 2016 and re-deployed the package.
Now everything seems to be working exactly as expected.




Tim
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search