Variables to input in file name for Reporting Services subscriptions - sql-server-2005

Is there a list anywhere that lists all the variables I can use in file names for report subscriptions from within SQL Server Management Studio? I currently use #timestamp in my file names, but would like to use other options or even remove parts of the time stamp (for example, just use the date, not the time).

Unfortunately #timestamp is the only variable available. There are various workarounds for formatting #timestamp, but nothing that is simple. Here is a thread that explains one (but not the only) workaround:
http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/81f47009-946a-4ebc-be43-7690236e829b
In case that link goes away, here were the recommendations:
To solve the issue, I would suggest using Data-Driven Subscription
A data-driven subscription provides a way to use dynamic subscription
data that is retrieved from an external data source at run time. A
data-driven subscription can also use static text and default values
that you specify when the subscription is defined. We can use
data-driven subscriptions to do the following:
Distribute a report to a fluctuating list of subscribers. For example,
you can use data-driven subscriptions to distribute a report
throughout a large organization where subscribers vary from one month
to the next, or use other criteria that determines group membership
from an existing set of users. Filter the report output using report
parameter values that are retrieved at run time. Vary report output
formats and delivery options for each report delivery. .
In this case, we can define the filename with timestamp in database
and then use Data-Driven Subscriptions to delivey the report.
For more information about Data-Driven Subscriptions, please see:
For SQL Server Reporting Services 2005:
http://msdn.microsoft.com/en-us/library/ms159150(SQL.90).aspx
For SQL Server Reporting Services 2008:
http://msdn.microsoft.com/en-us/library/ms159150.aspx

Related

Best practice: sending a stored procedure for "SQL Command from Variable" in OLE DB Source?

In a SSIS ETL, I have a query that I need to run on a server/db that does not allow us to create stored procedures.
I would normally use the stored procedure in my variable as the source for my OLE DB source:
However, since we can't put the stored procedure on this server, I was going to store the code for the stored procedure into a variable by executing a SQL statement, retrieving the text from our home database, then use the text stored in this variable as the SQL command for the source:
This way, I can still remotely change the SSIS OLE DB Source object WHERE clause (as long as I don't change the SELECT portion).
I can't imagine that this is very common, so I wanted to get some opinions - is there a better way to do this? I don't want to put all of the code for this SP into the OLE DB Source editor directly because we can't afford to redeploy in case of a WHERE clause update.
You've got the part down that many folks don't do and that's using Variables to drive your package execution. You are further correct in that you can't exactly swap out your columns. To be pedantic, which I am, you can completely change out the query as long as the same metadata is presented.
So, then this question becomes how best to accomplish allowing a package to have a query's filter driven by an external force. Factoring in maintainability, ease of debugging, etc.
My gut reaction is 3 Variables
QueryBase: String. Hardcoded. SELECT * FROM MyTable except of course I'd enumerate my columns
Query: String. EvaluateAsExpression = True Expression: #[User::QueryBase] + #[User::QueryFilter]
QueryFilter: String
So, we use Query in the OLE DB Source much as you have your longer variable name in there. The only downside to this approach, pre SSIS-2012 is the limitation on string length in an expression. It was ... 4k I believe. If you assign a value of 5k characters, it's fine. It's just in the expression language, adding two strings together can't exceed 4k.
I didn't specify what QueryFilter is going to have in it or the magic to get it there. That, I would base on the bigger picture of your environment, usage, etc. but the general concept is that it will eventually turn into WHERE Condition1 IS NOT NULL but maybe in a full reload situation, it becomes an empty string.
So, what are our options for changing the value of QueryFilter
/SET is an optional parameter passed to the invoking process (dtexec.exe) that makes SSIS packages go. If you have a very limited set of choices and aren't interested in building additional infrastructure out to support the parameters, just hard code some examples. Approximately dtexec /file p1.dtsx /set \Package.Variables[User::QueryFilter].Properties[Value];" WHERE Condition1 IS NOT NULL" Save it into .bat files, different sql agent jobs, whatever. Click and run and you're done.
Configuration approach. SSIS offers native ability to use configurations from a SQL Server table, XML, Registry, Parent Package and Environment Variable for 2005 to current edition. The only downside to this approach is that it would not support concurrent execution with different parameters like the first would.
Environment approach. 2012 and 2014, with their new Project Deployment Model, give us the concept of Environments within the SSISDB catalog which is similar to configuration with a SQL Server table but it is done after development is complete and the packages are deployed. It's rather nice as it builds out a history of values used so if someone asks why is the data all wrong, you can write a query to pull back the parameters used and Oh look someone used the initial load filter instead of the daily. Whoopsidaisy. Same concern over concurrent execution and changing values.
Table driven approach. Instead of using the Configuration with SQL Server table backing, you roll your own table and then add into your package an Execute SQL Task to retrieve the filter, Single Row, into our QueryFilter Variable.
Script Task. Use whatever floats your boat to determine what the filter should be.
Message Queue. They have built in a Message Queue Task and might be of use here if you're already doing it. Otherwise, too much effort to manage

Reuse of SSRS Report parameter

I am new to SSRS, I am creating a report which will take ID's as parameter e.g. 1,2,6,7,8,9 and so on. This parameter will be used for multiple reports. As a good practice I am thinking the user should not enter the ID for each report. Once entered/selected the ID parameter should be persistent for all the reports.
I am using Visual Studio 2008 to create the report and SQL Server 2008 R2 for backend scripting.
This can be done in an elegant way, but requires some work on the back end database.
If your reports are executing stored procedures, you can have the stored procedure for each report write the user's choice of a parameter to a table. Then the next report can check that table for a value. You could design this to be user specific, time-dependent, etc., depending on the effort you put in. It might be cleaner to set the parameter in a separate dataset. That is, in each report, you have multiple datasets. One grabs the parameter value, and your report parameters will default to that result. The other report data set can display the "main data."

I need to know the ids of inserted,updated,deleted in Microsoft Sql Database 2012 with dates

I want to sync my local db with microsoft sql database so I need to know the ids of added records , updated and deleted records after last sync date, I mean I have the last sync date and I need to get all these ids after that date
is microsoft sql server store this information in logs or anywhere ?
This isn't logged anywhere by default unless you either create a mechanism yourself to store the information or perhaps use Change Data Capture as documented here:
Change Data Capture
This allows SQL server to track data that changes in a table and then exposes the changes via functions that you can call to retrieve the data that has changed with each sync.

SQL SELECT WHERE value IN ('Huge list of Values')

Note: C# 3.5 application calling a SQL Server 2005 DB on a remote server.
I'm developing a two step process.
1) I search a Windows Indexing Service for a list of files that contain a given word, such as "Bob".
2) I then need to retrieve a list of rows from a DOCUMENT table in a SQL DB by passing in the list of filenames from the Indexing Service.
At the moment I retrieve a list from the indexing service AND all rows from the DOCUMENT table, then filter them in code. This isn't practical as there are 10,000+ documents and the database is through a firewall.
I considered creating a query such as:
SELECT DocName FROM Documents WHERE DocName IN ({list of files from indexing service})
...but given the list of files could be thousands it won't work.
So, what's the best thing I can do? I don't want to query the DB for all 10,000+ rows and pass them back over the firewall (takes 10 minutes). I somehow need to pass in the list of filenames retrieved from the indexing service.
How would linq work in this scenario?
Any advice greatly appreciated.
If you had SQL Server 2008, you could use Table Valued Parameters, but for 2005, there's nothing quite as elegant.
The simplest solution I can think of is:
Create a table in the database
Bulk Insert the results of your Indexing Service into the table
Join your query to this table to filter the results
Retrieve the filered results
It's not a great solution, but I don't know that a great solution exists - that's why TVPs were created.
You can evaluate different solutions for this kind of "massive" operation, may be not necessary to use linq. For example, try to implement a stored procedure on SQL Server, that receives in input the list of file name and returns the list of documents.
I opted for a solution similar to what Bazzz mentioned.
I've set up a nightly operation to copy the required fields from the database and set meta tags on the document files (PDFs). The meta data can then be used in the Indexing Service ;o)
This has proved to be a good solution for this instance, but otherwise what Hallainzil said would've been the best option albeit painful on Sql Server 2005.

How to let end users customize report chart in SSRS?

i am working on sql server business intelligence to generate reports. i did all the staff that i want to be in the report except the ability for the end user to customize the report without making another request to the server to generate another report based on another request. first i did this through a parameter of type Boolean and wrote an expression to check the parameter before generating the report,but my project leader said i don't want to make a request each time instead i want to bring all possible data and let the end user decide what to show.
in other words, my report contains a chart of three series i want the end user have the ability to show a set of them or all of them in client side + one request.
how can i do it through sql server business intelligence 2008
What is Your SSRS project based on ? SQL Server DataBase or SQL Server Analysis Service ?
AFAIK you can design the SSRS report with many conditions which the end user can input their own value in .
if It's based on SQL Server DataBase the conditions looks like parameters of procedure that you use in SSRS
if it's based on SSAS , The conditions looks like MDX code