SQL Profiler: who modified a column? - sql-server-2008

Is it possible to use SQL Server Profiler 2008 to catch which program, run from which computer, is modifying table SALES column POSTED from false to true, but excluding stored procedure 'salesposting'?
I suppose I can use 'objectname' filter for the table, but how to filter the column, the previous value, and the current value?

You could trace specific procedures or update statements through the text data option in the Filters list.
It is likely simpler to add a simple trigger capturing the user / input buffer is likely the best approach.

There is an ApplicationName and Hostname column that you can trace. Just click the check box "Show All columns" that you'll see them
If you want to filter by Stored Procedure, select filter the RPC:Completed event

Related

MySQL + SSRS | Stored Procedure only returns one single row

I'm working on several reports for SSRS written in MySQL via ODBC Adapter. For some reason, Stored Procedures only return a single row of data instead of an expected set of data.
Below is the same stored procedure when ran on an SQL Editor:
And below is the stored procedure's execution result when SSRS tries to run it (both on Query Designer and Report Viewer):
I have also set parameters properly as far as i can tell:
so i wasn't able to find an exact answer as to why this happens on SSRS with MySQL via ODBC. What i was able to find was a workaround:
by executing the command as an Expression rather than as a raw query via the Query Editor:
Now the only caveat for this is that the DataSet Fields wouldn't be automatically generated, and that you have to plot them all manually. A good workaround for this is to first run a blank/null query with only the column names (i.e.: SELECT NULL 'column_name_1', NULL 'column_name_2') then later change the query source to Expression. The good thing about using expression is that you only need minor knowledge about how it works and it reduces the confusion with ODBC '?' Parameters.
Cheers!

RedShift Query via SSRS with user parameters: Say WHAT?

I'm trying to create a query that grabs records that fall within a specified time frame, hence BETWEEN. However, I need to do this from an interactive report which user can specify the endDate and startDate parameters.
I've read that RedShift may not necessarily support variables or parameters and that I may need to use temp tables, but my requirements are that users can pass in values. I'm confused on how using temp tables with pre-defined values allows for in-determinant values to be passed to the base query...
Here's my initial attempt (dont laugh)
prepare prep_select_plan(date)
AS select TOP 10 * from table WHERE date BETWEEN $1 AND $2;
EXECUTE prep_select_plan(#startDate);
EXECUTE prep_select_plan(#endDate);
DEALLOCATE prep_select_plan;
Is there another platform that would allow me to create a web based, interactive report with the ability to have end users enter parameter values?
Update*
I've attached the dataset properties window to elicit feedback on how to pass value to the RedShift query.
When connecting to a database like RedShift or MySQL using ODBC, you have to use a more generic syntax for parameters. Rather than using the # symbol and the parameter name, you just use a ? in the query. For example, one line would look like this:
EXECUTE prep_select_plan(?);
You can map which report parameters go to the query parameters in the parameters tab of the dataset properties. The parameters are simply mapped in the order they appear, you can't reference the same name in multiple places in the query. It's not as user friendly, but SSRS is primarily designed to work with SQL Server.

Running a DFT Based on a condition in SSIS

I've a package where I need to retrieve data from a mysql table and insert it into sql server table.
I've a situation where in old data often gets modified and the client wants to dump all data which is too large and time consuming...So I've come up with a proposal that we'd load only yesterday's data on week days and do complete dump on weekend...Is there a possibility of Enable/Disabling a DFT Based on an expression? I've Tried using Expressions->Disable based on DATEPART(WeekDAY,GETDATE()) but it runs for a complete load irrespective of expression's value
Regards,
Vijay
Create a SQL Task or Script Task that does your expression, and set the result to a variable.
Then create your data flow task.
Then connect the two with an arrow (aka precedence constraint)
Then right-click:Edit on the arror and choose Edit, and in the Precedence Constraint Editor choose
EvaluationOperation: Expression
Value: ##YourVariable= {an expression, such as #iRowsUpdated==True}
You should put the condition as a where clause against your select statement in your source query. You will need to change access mode from table to SQL Statement first

How to create a new column with an SQL function in Pentaho PDI work-flow?

I have one sql function, let's say theFunction(item_id). It takes an item id and computes one value as its return. I read one table from the DB and I suppose to compute a new value to append for each row by this function given the item_id particular to taht row. Which desing block would do this form me with the following SQL (if not wrong).
select thsFunction(item_id);
I assume that the block gives me item_id of each row as a variable.
You can use another table input step, and have it accept fields from previous steps and execute for every row (both config options are at the bottom of the step's window).
Beware that this is a rather slow implementation. Each query is executed separately and as such each row requires a round trip to the database.
Alternatively, you can use the Row SQL Script. I believe it allows you to pass all SQL statements in a single trip to the database.
An SQL function is probably much more efficient to run in the database, for all rows at once, in stead of making a separate call into the database from PDI for each row to execute the function. So if performance is at all a relevant concern, I'd suggest a whole different strategy:
Write your rows to a table in the database. End your transformation here.
On the job level, first execute your transformation from above, then execute the function in an "Execute SQL script..." component, giving it an SQL command somewhat like "UPDATE my_temp_table set target_col = theFunction(item_id)".
Continue your job with the remaining steps in a new transformation, starting from that table as input.
This of course presupposes that you don't have too many other threads going on, but if your transofrmation is simple and linear -- or at least if it can be made single-linear at this particular step -- it may be possible to split it up into two parts before and after this SQL call.

SSRS call stored procedure using ReportItems! textbox. Maybe custom report code?

I need to call a stored procedure during my report to insert values into a table. These values are the result of fields from the dataset added. For example, I have a row of values, and the far right column is "ReportItems!TextBox1.Value + ReportItems!TextBox2.Value ..." This gives the correct total on the report. Now I need to call a procedure using this value as a parameter.
Using a stored procedure as a dataset, I am unable to reference the ReportItems! I am also unable to create additional report parameters (even internal or hidden) which could be a result of a dataset due to the reporting infrastructure we are using.
I know using custom report code, I can call a stored procedure and also reference the ReportItems, but I have been unable to find the correct syntax. I am not familiar with VB.net so please be specific. If i could get an example of how to call: Procedure TEST_INSERT(ReportItems!TextBox1.Value), I would be able to figure out how to implement it.
I am using an oracle backend as my data source.
Thanks
If I've understood you correctly, you want to do an database update using a value calculated with an expression in your report. My answer to this would be threefold.
First up: don't do it!.
Second: seriously, don't do it!! Reporting services is not meant or well suited for this kind of task, you most likely are looking at an XY-Problem.
Third, if you insist on doing it anyways, the easiest way I can think of to accomplish that is by using a seperate report to trigger the update, and pass the value you're after into a parameter for that report. In the main report, you set a click action on the cell with the total that calls the report, with the same value into the parameter.
A similar setup which may work as well, is to create a parameter based on the first dataset with that same "sum" expression you mention, and pass that down to another dataset.
However: don't do it! ;-)
I would set up a dataset in the report service that calls an update or insert function in oracle and returns a value/s. This way you can send in the total you need calculate and produce a result telling the user if the update was successful.
There is no special method for doing this just select or enter your procedure name and refresh the fields to update the parameter/s. See Oracle stored procedure in SSRS.
Also using this method you can run the stored procedure in oracle, update the table and display the results.