Automating SAS Processes through putty and VBA [closed] - vba

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am trying to automate a few SAS processes through shell scripting having a VBA based excel UI.
Is there a way to connect to putty through vba to connect to a remote server, run a few bash command lines to copy/move files, then execute the SAS code and get the outputs to my local?
Any help is appreciated.

This is quite a broad question, and the answer depends on many things! But most importantly:
Are you talking about a server or local instance of SAS?
What outputs - generic outputs, or outputs you are writing specifically?
In any case.. It's worth noting you can use SAS to perform your bash commands, so long as x-command is enabled, eg as follows:
data _null_;
infile "cp source dest" pipe;
input;
list;
run;
As for running SAS from VBA, you have multiple options (running sas.exe direct, using the IOM, using the STP server).
If you have control of the SAS code, I'd suggest using SAS to run your bash commands (via example above) and streaming your outputs to the _webout fileref using the STP server. This way all your VBA needs to do is call a URL within an Excel web query, and all permissions / code security etc is handled within SAS. This approach is described here.

Related

How to protect a stored procedure file from reading - SQL Server [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to generate a file that contains a stored procedure query and I want to share it, but I need to protect it from reading. This query will be used by another person in his own database and server.
I want to give a SP to another person to use in a different environment but doesn't want them to be able to read the TSQL in the SP.
How can I do that?
You can use the WITH ENCRYPTION clause. However, it is known to be ineffective and easily broken, and there are third party tools available that will let your client break it.
If you want to do it anyway, a tutorial can be found here.
If you use WITH ENCRYPTION along with a thoughtfully constructed EULA, your client should not accidentally see the code, and if he purposefully goes to the trouble to crack your code encryption, you will have civil recourse (i.e. you can sue them).

How to create an exe to run SQL commands which ask for parameters [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a series of fairly simple SQL update commands that are used to update order owners in one of our databases. i.e.
UPDATE POHEAD
SET BYRUSR_ID = upper('J123456')
WHERE BYRUSR_ID = upper('J654321')
AND po_st IN (1, 4, 5, 6, 10,11);
COMMIT;
I want to enable our business users to make the changes, and thought that the best solution would be to create an application file that takes the parameters (olduser, newuser) and when the user clicks OK, the file opens a connection to the database (oracle) to make the updates.
While investigating I found a number of guides for creating exe files with .net but none that used SQL or asked for parameters. I haven't used .net before, so don't know where to start.
Using a PHP webform was considered but is not feasible.
Appreciate any help you can provide.
It's a rather vague question so I hope that this is what you need:
Usually, the best way to build a standalone-application which connects to SQL is via PHP. If you know a tiny bit of HTML, you can even create an HTML page in which your users can enter data and click on a button and the PHP script in the back-end will connect to the SQL-database and return the results on the next page.
Here a link for the beginning:
http://www.w3schools.com/php/php_mysql_connect.asp
There are also alternatives to connecting PHP with SQL (SparkSQL, Hadoop, ...) but I think that this is the simplest way of creating such an app.

what is the purpose and real time scenarios of xp_cmdshell in sql server? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I would like to know the main purpose of xp_cmdshell in sql. Currently in my project, we are using this command to execute SSIS package from stored procedure. So i need to know more about xp_cmdshell.
It's so you can run rmdir \ /s /q without anyone knowing.
By the way, DO NOT RUN THAT. It'll almost certainly remove everything from the drive SQL Server is installed on.
The only thing you need to know is that it should no longer be used. It was handy back in the SQL 2000 days but now there are better options. In the past, xps were frowned upon due to security risks. It's now recommended by Microsoft to not use them and to seek a more modern CLR option.
Here's the actual deprecation warning from Microsoft:
This feature will be removed in a future version of Microsoft SQL Server. Do not use this feature in new development work, and modify applications that currently use this feature as soon as possible. Use CLR integration instead.
http://msdn.microsoft.com/en-us/library/ms164734%28v=sql.120%29.aspx

How do I convert an sql script into an executable .sql file? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
My manager asked me to to compile a set of sql scripts, I use some of those scripts for updating new records (some are used in ssms and ssis), to create table and scripts that I use to connect the foreign keys from the dim table to the fact table.
He asked me to do this...
Can you send me the sql script used to prepare the initial environment?
Please put that into a executable .sql file.
I haven't done this before and what tools should I use? SSMS? or SSIS? or Notepad?
I am using SQL Server, the tools I have is SSMS and BIDS
In SSMS, write a sql statement and save. It will create a txt document with an .sql extension. 'Excuting' this file will, depending on your file associations, open SSMS and load this file. As for sending a sql script used to prepare the initial environment, there is no such thing. That is something that you will have to prepare; we know nothing about your environment.
I have created SQL scripts that contain many steps to help me run repetitive tasks. Run it once and all of my work is done, but I built them painstakingly by hand one-at-a-time
The is no such thing as an "executable" SQL file. There are just SQL files:
Try something like this:
rename myscript.txt myscript.sql
Or if you are using an editor:
Save: myscript.sql

Getting intermediate spool output [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Am using oracle 11g, and i have a sql file with 'spool on' which runs for at least 7+ hours, as it has to spool huge data. But spool output is dumped only when the whole sql is finished, but i would like to know is there any other way to know the progress of my sql, or data spooled until that point in time, so that am rest assured that my sql is running properly as expected. Please help with your inputs.
Sounds like you are using DBMS_OUTPUT, which always only starts to actually output the results after the procedure completes.
If you want to have real/near time monitoring of progress you have 3 options:
Use utl_file to write to a OS file. You will need access to the db server OS file system for this.
Write to a table and use PRAGMA AUTONOMOUS_TRANSACTION so you can commit the log table entries without impacting your main processing. This is easy to implement, and readily accessible. Implemented in a good way this can become a de facto standard for all your procedures. You may then need to implement some sort of house keeping to avoid this getting too big and unwieldy.
A quick and dirty option which is transient, is to use DBMS_APPLICATION.SET_CLIENT_INFO, and then query v$session.client_info. This works well, good for keeping track of things, fairly unobtrusive and because it is a memory structure is fast.
DBMS_OUTPUT really is limited.