stored-procedures

How to EXEC a stored procedure from SSIS to get its output to text file

北城以北 提交于 2021-01-28 00:41:01
问题 I wrote a stored procedure that reads records into a temp table and then creates a pivoted output from the data in the temp table. Running the stored procedure from SSMS works just fine. What I am facing problems is now that I am trying to create the SSIS package that will execute the sproc, and write its output to a tab delimited text file. I am using Visual Studio 2015. My first problem is that when I try to configure the OLE DB Source within the Data Flow Task, when adding the SQL Command

SQL-Server: Is there an equivalent of a trigger for general stored procedure execution

天大地大妈咪最大 提交于 2021-01-28 00:04:05
问题 Hope you can help. Is there a way to reliably detect when a stored proc is being run on SQL Server without altering the SP itself? Here's the requirement. We need to track users running reports from our enterprise data warehouse as the core product we use doesn't allow for this. Both core product reports and a slew of in-house ones we've added all return their data from individual stored procs. We don't have a practical way of altering the parts of the product webpages where reports are

MySQL - select first 10 bytes of a string

混江龙づ霸主 提交于 2021-01-27 21:28:38
问题 Hello wise men & women, How would you select the first x bytes of a string? The use case: I'm optimizing product description texts for upload to Amazon, and Amazon measures field lengths by bytes in utf8 (not latin1 as I stated earlier), not by characters. MySQL on the other hand, seems to operate character-based. (e.g., the function left() is character-based, not byte-based). The difference (using English, French, Spanish & German) is roughly 10%, but it can vary widely. Some tests

ADODB not passing in parameters

给你一囗甜甜゛ 提交于 2021-01-27 18:54:10
问题 I have a SQL SP with the following parameters... myProc(@param1 AS TINYINT, @sparam2 AS TINYINT, @param3 AS TINYINT, @param4 AS TINYINT, @param5 AS TINYINT, @param6 AS TINYINT, @param7 AS TINYINT, @paramOut NVARCHAR (255) OUTPUT) and I have the following ADODB code in VBA... sVal1 = 1 sVal2 = 1 sVal3 = 1 sVal4 = 1 sVal5 = 1 sVal6 = 1 sVal7 = 1 Dim cnn As ADODB.Connection Dim cmd As ADODB.Command Dim param1, param2, param3, param4, param5, param6, param7, param8 As ADODB.Parameter Dim Rs As

Backup SQL Server database using PHP

谁说我不能喝 提交于 2021-01-27 18:19:30
问题 I am trying to backup a MS SQL database calling a Stored Procedure using PHP. When I execute de SP on SSMS, everything works fine. However, when I call it from the PHP script, I can see a ".bak" in the backup folder and right after the PHP finishes processing, the BackUp.bak file disappears. Here is the Stored Procedure: DECLARE @date VARCHAR(10) SET @date = (SELECT date FROM tbl_date) Declare @fileName VARCHAR(100) SET @fileName = ('C:\db_backup\BackUp_' + @date + '.bak') BACKUP DATABASE

How to call a procedure with a rowtype literal as parameter in PL/SQL?

落爺英雄遲暮 提交于 2021-01-27 16:29:23
问题 Lets say I have a table and a procedure that accepts one argument of the tables rowtype: CREATE TABLE t (a NUMBER, b NUMBER); CREATE PROCEDURE p (x t%ROWTYPE) IS BEGIN NULL; END; Can I call that procedure using a rowtype literal, that is without explicitly creating a rowtype variable (or at least not explicitly listing and assigning every field of it)? The two following approaches both generate the below error: p(1, 2); p((1, 2)); PLS-00306: wrong number or types of arguments in call to 'P'

Generate list of new unique random numbers in T-SQL

倖福魔咒の 提交于 2021-01-27 07:38:23
问题 I need a stored procedure to generate @n records, each with a unique random 8 digit number. This number must not be incremental and must not exist already in the table. CREATE TABLE Codes ( ID UNIQUEIDENTIFIER PRIMARY KEY, Code INT, CONSTRAINT UQ_Code UNIQUE(Code) ); I can generate random numbers: DECLARE @min int = 0, @max int = 99999999, @n INT = 100; SELECT TOP (@n) FLOOR(CAST(CRYPT_GEN_RANDOM(4) AS BIGINT) / 4294967296 * ((@max - @min) + 1)) + @min FROM sys.all_objects s1 CROSS JOIN sys

stored procedure parameter values logging

纵然是瞬间 提交于 2021-01-27 07:10:31
问题 Is there a way to check when and with what parameter values a stored procedure has been executed in SQL Server 2008 R2? 回答1: As usr said there is no way to do this at all, but you can do this as workaround, which I did in my projects. Create a log table and implement in each procedure a INSERT INTO log_table statement where you insert time with GetDate() , procedure name and logged user. This table you can seek for your informations then. This for sure only works for the future and not if you

jsp jstl sql strange behaviour with as in mysql

北城以北 提交于 2021-01-27 06:51:55
问题 In mysql i m having a stored procedure which has a sql like: select firstname as i_firstname , lastname as i_lastname from roleuser where user_id = uid ; I m using a jstl code to get the values: - <sql:query var="comm_codes" dataSource="jdbc/myDatasource"> call sp_select_username(?); <sql:param>${user_id}</sql:param> </sql:query> <c:forEach var="rows" items="${comm_codes.rows}"> ${rows.i_firstname} ${rows.i_lastname} </c:forEach> But this code does not return anything but when the replace the

jsp jstl sql strange behaviour with as in mysql

你离开我真会死。 提交于 2021-01-27 06:51:06
问题 In mysql i m having a stored procedure which has a sql like: select firstname as i_firstname , lastname as i_lastname from roleuser where user_id = uid ; I m using a jstl code to get the values: - <sql:query var="comm_codes" dataSource="jdbc/myDatasource"> call sp_select_username(?); <sql:param>${user_id}</sql:param> </sql:query> <c:forEach var="rows" items="${comm_codes.rows}"> ${rows.i_firstname} ${rows.i_lastname} </c:forEach> But this code does not return anything but when the replace the