Tag Info

Hot answers tagged

11

Just to get these out of the way: Technically speaking, both of these options are "dynamic" / ad hoc queries that are not parsed / validated until they are submitted. And both are susceptible to SQL Injection since they are not parameterized (though with the SQLCMD scripts, if you are passing in a variable from a CMD script then you do have an opportunity ...


4

Add -e option: · --execute=statement, -e statement Execute the statement and quit. The default output format is like that produced with --batch. See Section 4.2.4, “Using Options on the Command Line”, for some examples. With this option, mysql does not use the history file. mysql -uroot -pPassword1 -e "select column_name from ...


3

This is really a Unix/Linux question, but it does relate to Oracle, so I'll give an answer. In Unix, the system makes great use of what it calls "spawning" (or "giving birth"). When you run a command, a new process is created which takes all of its information from the parent. Essentially, it's a copy of the parent - it's a new bash shell, which then sets ...


2

It rather depends on what the scripts are intended to do... If you can cope with the occasional dirty read or unrepeatable read issue (or they are truly simple enough that these are unlikely/impossible), also set your transaction handling to the most lenient mode possible with SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED. This is actually equivalent to ...


2

Converting comment to an answer. This is not my area of expertise, but you might look at Dennes Torres Simple Talk post from January 2015 for any takeaways that help you. https://www.simple-talk.com/sql/database-administration/centralize-your-database-monitoring-process/ Two subheadings of particular interest may be: Configure Data Collector through ...


2

Instead of issuing PRINT @tsql;, you can issue EXEC( @tsql );, if I understand what you're asking. If so, I would suggest declaring a preview parameter ( something like DECLARE @Preview BIT = 1; ) and then use an IF to either print or execute. IF ( @Preview = 1 ) BEGIN PRINT @tsql; END ELSE BEGIN EXEC( @tsql ); END;


2

The spatial index, as with other objects, have their own script <object> as menus and need to be done separately. This can be done to the clipboard and pasted to the query window generated by the script table as command. I can't confirm at the moment, but I suspect that the primary key and other constraints come out in the script table as options ...


1

Three options: export it to the environment. put it in the script use nzpassword the examples are off the top of my head, I don't have an instance to test it out right now, you might need to tweak them a bit. exporting it to the environment: NZ_PASSWD_ENCRYPTED=29TY20T98= export NZ_PASSWORD=`DecryptFunc $NZ_PASSWD_ENCRYPTED` NzResult=$(nzsql -db ...


1

From 2012 onwards this is possible and can be done with help OF sys.dm_exec_describe_first_result_set DMV. This dynamic management function takes a Transact-SQL statement as a parameter and describes the metadata of the first result set for the statement You can refer here for a read on this sys.dm_exec_describe_first_result_set Also, refer to ...


1

There are a couple of problems with this approach: The immediate problem is that you cannot continue an empty line. So the two lines (following each go ^ line) that are only the single character ^ are causing the line to end and not continue. It has nothing to do with the go. So you can just add a space before the carrot and it will build the full string. ...


1

Get rid of GO altogether. It's recognized by sqlcmd only in the interactive prompt or when reading from a file using the -i switch. If some statements need to be in a separate batch, use EXEC to wrap them. Example: EXEC('CREATE VIEW SomeView')



Only top voted, non community-wiki answers of a minimum length are eligible