How to get the SQL query from a file in SSIS - sql

I'm new to SSIS. I have a DataBase from which i'm getting the data. Suppose DB is the source and destination may be anything. (I tried DB to Excel and it worked fine)
In the source i have a custom query to get the data. I have written that in the properties.
Now i want to change it. I want to put it in some configuration file (xml file). i.e., i want to
get the query of the source from the xml file. How can i do this?
I'm a complete newbie trying the things. So please give your answer specifically.
UPDATE:
This is my package
I double clicked the OLE DB source. Now This is what i written there
I want to put the query (select id, age from emp where exp > 4), in a configuration(xml) file.

Create a package level variable for your query:
Change your source editor to use SQL command from variable (with appropriate variable) instead of SQL command:
Go to the SSIS menu and click "Package Configurations..." then click the checkbox to Enable package configurations, then click the "Add..." button.
... By default, it uses an XML Configuration file, which is probably easiest to work with. Specify a filename - the file extension is .dtsConfig. If the file doesn't exist on your machine, it will create one for you. Click Next.
Find your Variable, find the Value property for the variable, and check the box for it. Click Next.
Choose a name for your configuration. Click Done, then click Close in the Package configuration list, making a note of where on your file system you saved your configuration file.
Find the configuration file on your file system. Right-click and edit with an XML editor as needed.

Related

Set define off permanent

When running queries in SQL Developer and using the character & in my literals, a popup appears asking me to provide a variable. I then execute SET DEFINE OFF; and I can run my query for the rest of the session.
Is there any way to configure Oracle so it can never ask for manual variables when containing the & character?
Create a text file on your PC which contains set define off and any other set-up instructions you might want.
Then in SQL developer, go to the Tools menu and pick the Preferences... option. In the panel on the left click on Database.
Then either type the path to the file you created, or click Browse and navigate to the file in the 'Select connection startup script' dialog that appears.
That script will then be run every time you connect to any database.
Put SET DEFINE OFF into
login.sql (so that it works for you only, i.e. use user profile file), or
glogin.sql (so that its affect is global, i.e. use site profile file)

Possible to manually trigger automatic source code formatting in STM32CubeIDE?

I use STM32CubeIDE version 1.6.1, and have noticed that CubeMX outputs formatted code (e.g. indented with 2 spaces). I would like to reapply this source code formatting manually (that is, manually trigger the source code formatting on selected files).
I have found this post: https://www.openstm32.org/forumthread6435 , which mentions:
go the preferences dialog and select C/C++ > Code Style > Formatter
click on “Edit...” change the tab size field. close the preferences
Then, select all the project you want to apply it, click right and select “Source > Format”
So, I'm not 100% sure the above quote refers to STM32CubeIDE, however, the first part is still there, in Window/Preferences I can get to this:
However, I cannot see how to trigger this source code formatting manually, on selected files. For instance, https://dvteclipse.com/documentation/e/Format_Multiple_Files.html for Eclipse (that STM32CubeIDE is built upon), mentions that by right-clicking source files, one can call the command "Format Source Files"; however, when I click my main.c in the STM32CubeIDE Project Explorer, I cannot see anything like that:
So, is there a way to manually trigger automatic source code formatting on selected (single or multiple) source code files in STM32CubeIDE?
Got it, finally - when you right-click the Core node, or any of its children, in Project Explorer in STM32CubeIDE, you get a "Source >" entry in the right-click context menu, which has only one child, "Format":

How to run a SSIS Package which has a file based source automatically

I have a similar issue as this question: How to run a SSIS Package which has a file based source and a target. At first, there was no known program to open the dtsx package (my package grabs a table from one server and places it on another). I did some digging and found the DTEXECUI program file, and now it does open the Execute Package Utility, but it doesn't populate the Package Source (file) or Package Name (Desktop\xxx.dtsx). How can I get it so that double-clicking the file just executes the SSIS package - or at least populates the names for the file I clicked on? Thanks in advance.
I'm guessing that since Windows didn't automatically create that association for you, the default is missing some parameters for the executable (because that program should open with those fields populated).
Try this:
Download Default Programs Editor and run it
Click File type settings
Click Context menu
Locate .dtsx in the list and click Next
Click the Open list item and then Edit Selected Command
The path should look something like "C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\DtExecUI.exe" /F "%L" - your path to the DtExecUI may be different, but of special note is the /F "%L"
Click Next and then Save Context Menu

Where is the SQL File Template in Visual Studio 2010?

I notice in VS2010's Tools > Options dialog, there is a section on how to format the SQL:
I am working with a very large stored procedure on our server that is not formatted well at all. I was thinking it would be great to create a new SQL File in my project, copy and paste the text from the stored procedure in there, and have the text editor apply auto formatting to all of the SQL.
When I call "Add > New Item" and get that dialog, there does not seem to be any Installed Template with the .sql extension.
I see the SQL Server Database template, but that is not what I need. The LINQ to SQL Classes is not right, either.
What template do I need to use to use the auto formatting built into the VS2010 interface?
Judging from your screenshot, you have a C# project (e.g. a library dll) open. This won't show an option to add a .sql file as those files are not normally associated with a C# kind of projects.
One way around it is:
In VS2010 main menu, go to File -> New -> File. In General tab, there's a SqlFile file type.
Add a file and save it to the disk in the location of your project.
Right-click on your project and select Add -> Existing Item. In the open file dialog, change the extension to *.* to show your .sql file.
Add file to the project. If needed, change "Build Action" and "Copy to Output Directory" properties to control how it behaves during the build.
What you are looking for shows up when you create a SQL Server Database project.
File > Add > New Project
Then when you add items you see options that should work:
*Note my screenshots are from VS2012 - but I think it is the same.
I hate Visual Studio's T-SQL designer, even with SQL Data Tools installed. I opt to open my project's .sql files in Management Studio.
Right-Click any .sql file in VS.
Navigate to "Open-with"
Choose "Add"
In the Program dialog type "explorer.exe"
Type whatever you want for the friendly Name, I use Management Studio
Click "OK"
Highlight the new record and choose "Set as default".
Now double clicking any .sql file in VS will open up whatever program opens when you double click a .sql file outside of VS. Using this method, I'm able to edit, add, and modify my sql files in management studio and save them back to the project seamlessly.
Hope this helps.

URL to make SSMS start and connect to a db?

It would be nice to have a bunch of reference links somewhere, that could also be used to start SSMS.
Is this possible? and get it to use an already open instance?
e.g. sqlwb -E -S Server\instance
but I'm not sure if you can do this in the form of a URL
i.e. how to make a URL run CMD
Right click on your shortcut for SSMS (or copy existing one),i.e. that thing on which you click to open SSMS.
Open Properties --> tab Shortcut.
Add options to target text box
For ex., I have:
"D:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe" -nosplash -S localhost -d _A
to avoid splash, to connect automatically to database __A, etc.
You will get help by adding non-existent option
, pressing OK, double-click shortcut
I'm not sure you can do this in a URL directly, but you could certainly create URLs to .cmd batch files (in the form of a UNC path) which contained the relevant commands.
To make a "url" run a cmd file, format it in this way:
file:///c:\folder path\myfile.cmd
If you want to embed one of these file links in a document (like Word or email) then you may need to add angle brackets around it:
<file:///c:\folder path\myfile.cmd>
and the editor will make it into a link automatically. (alternatively you could just highlight some text, right click and create a file hyperlink using the first syntax).
Launching executables from URL is a very bad idea and a security hole. I advise to avoid doing this for many reasons.