Monday, February 20, 2012

Programatically Evaluating SSIS Expression

Is there an object in the DTS object model that will allow me to evaluate an SSIS expression? I am trying to build a custom task that will require re-evaluation of an expression multiple times within the execute method and I can't seem to find a way to do this.

Thanks,

Adam

Add a reference to Microsoft.DataTransformationServices.Controls

Use the Microsoft.SqlServer.Dts.Runtime.Wrapper.ExpressionEvaluatorClass class. You will want to use DTSInfoEvents to capture error details when calling Evaluate or Validate. Pass the events to the Events property of the ExpressionEvaluatorClass.

Take a look at the File Watcher Task (http://www.sqlis.com/) for an example of this in action, just set an expression through the task UI to see the Expression Editor Dialog we have built in action. It use the ExpressionEvaluatorClass behind the scenes to provide the evaluation functionality.

Not documented, so not supported, but it works.|||As Darren said, this is not documented and will not be supported by Microsoft. It could change at anytime and break your component if you use it.
User beware.|||

I have logged a bug to document and publicly expose this, but it was on Beta Place, so if someone wants to do the Product Feedback thing I'll vote for it.

Programatically Email a report

Does anyone have any code to run a report and email it. I want to run the
report that has one parameter and then email it. With the report as the Body
of the email and then the same report as an attachment in pdf format. I would
like to also add some text to the email in front of the report. Or could you
point me to a sample or book that would help. Which report interface would I
use?
--
Thanks,
Jon AYou could use subscriptions - see "E-Mail Delivery in Reporting Services" in
reporting Services Books On Line.
If you want more control over the email you could create the pdf file
programatically either using URL access (again in BOL) or the Web Services,
then write a bit of code to send email - that will depend on what your email
system is.
"Jon A" wrote:
> Does anyone have any code to run a report and email it. I want to run the
> report that has one parameter and then email it. With the report as the Body
> of the email and then the same report as an attachment in pdf format. I would
> like to also add some text to the email in front of the report. Or could you
> point me to a sample or book that would help. Which report interface would I
> use?
> --
> Thanks,
> Jon A|||Which is more efficient Web services or url access. I tried using
subscriptions but I can't figure out how to get the report in the body of the
message. Also my mail server needs you to logon. Where do I put the user name
and password for the mail server to get or does subsciptions use an outlook
profile?
--
Thanks,
Jon A
"Mary Bray [SQL Server MVP]" wrote:
> You could use subscriptions - see "E-Mail Delivery in Reporting Services" in
> reporting Services Books On Line.
> If you want more control over the email you could create the pdf file
> programatically either using URL access (again in BOL) or the Web Services,
> then write a bit of code to send email - that will depend on what your email
> system is.
>
> "Jon A" wrote:
> > Does anyone have any code to run a report and email it. I want to run the
> > report that has one parameter and then email it. With the report as the Body
> > of the email and then the same report as an attachment in pdf format. I would
> > like to also add some text to the email in front of the report. Or could you
> > point me to a sample or book that would help. Which report interface would I
> > use?
> > --
> > Thanks,
> > Jon A

PROGRAMATICALLY ELIMINATE DUPLICATE ADDRESSES

I am trying to find a way to eliminate duplicate addresses from a table. I
have a table that is imported from a seperate system so I have no control
over it but I need to be able to design a query that brings out last name,
first name, zip code, city, and state, address1 and address2 for a mailing
list.
Currently I have many people at the same address that I need to remove and
when I check the zip code against our zipcode table it removes any with a zi
p
+4 setup.
Is there any way to set this up to keep the zip+4 part and eliminate all of
the duplicate addresses?
You can modify the "double cursor" example at:
http://groups.google.com/group/micr...cbce3491367da2f
Where I have
declare curOrders cursor FAST_FORWARD for select OrderID , OrderDate
from Orders where CustomerID = @.CustomerID
put a counter there. (of course reset it for each new Customer)
if the counter > 1 (aka, #2, #3, etc , etc) you can run a DELETE.
..
Its a hack, but it works.
"Don" <djw@.nospam.postalias> wrote in message
news:D9647F2A-8402-40AB-A464-E8CCDEE5AD34@.microsoft.com...
> I am trying to find a way to eliminate duplicate addresses from a table.
I
> have a table that is imported from a seperate system so I have no control
> over it but I need to be able to design a query that brings out last name,
> first name, zip code, city, and state, address1 and address2 for a mailing
> list.
> Currently I have many people at the same address that I need to remove and
> when I check the zip code against our zipcode table it removes any with a
zip
> +4 setup.
> Is there any way to set this up to keep the zip+4 part and eliminate all
of
> the duplicate addresses?|||I am sorry, I did not state my problem completely. I also cannot delete fro
m
the original table so it must all be done in a query
"sloan" wrote:

>
> You can modify the "double cursor" example at:
> http://groups.google.com/group/micr...cbce3491367da2f
> Where I have
> declare curOrders cursor FAST_FORWARD for select OrderID , OrderDate
> from Orders where CustomerID = @.CustomerID
> put a counter there. (of course reset it for each new Customer)
> if the counter > 1 (aka, #2, #3, etc , etc) you can run a DELETE.
> ...
> Its a hack, but it works.
>
>
>
>
> "Don" <djw@.nospam.postalias> wrote in message
> news:D9647F2A-8402-40AB-A464-E8CCDEE5AD34@.microsoft.com...
> I
> zip
> of
>
>|||I also cannot affect the original table as we rerun other queries that use
the extra information for other purposes.
I am pretty weak when it comes to SQL also, sorry.
"Don" wrote:

> I am trying to find a way to eliminate duplicate addresses from a table.
I
> have a table that is imported from a seperate system so I have no control
> over it but I need to be able to design a query that brings out last name,
> first name, zip code, city, and state, address1 and address2 for a mailing
> list.
> Currently I have many people at the same address that I need to remove and
> when I check the zip code against our zipcode table it removes any with a
zip
> +4 setup.
> Is there any way to set this up to keep the zip+4 part and eliminate all o
f
> the duplicate addresses?|||Select 'distinct' (without the quotes of course). This will eliminate
duplicates as long as you have selected all the data properly. Be careful
that you are getting all the data you want though.
"Don" wrote:
> I also cannot affect the original table as we rerun other queries that use
> the extra information for other purposes.
> I am pretty weak when it comes to SQL also, sorry.
> "Don" wrote:
>|||Why not just:
select distinct
firstname, zipcode, city, and state, address1, address2
from sometable
or you want to keep only the row with the longest zipcode? If so, try:
select
firstname, max(zipcode), city, and state, address1, address2
from sometable
group by firstname, city, and state, address1, address2
"Don" <djw@.nospam.postalias> wrote in message
news:D9647F2A-8402-40AB-A464-E8CCDEE5AD34@.microsoft.com...
> I am trying to find a way to eliminate duplicate addresses from a table.
I
> have a table that is imported from a seperate system so I have no control
> over it but I need to be able to design a query that brings out last name,
> first name, zip code, city, and state, address1 and address2 for a mailing
> list.
> Currently I have many people at the same address that I need to remove and
> when I check the zip code against our zipcode table it removes any with a
zip
> +4 setup.
> Is there any way to set this up to keep the zip+4 part and eliminate all
of
> the duplicate addresses?|||I have used distinct to get rid of duplicate entries, but distinct does not
seem to help with different people at the same address.
This is where my problem is.
First, Last, Addr1, Addr2, City, State, Zip
Joe Brown PO Box 33 NULL Town ST 99999
George Brown PO Box 33 NULL TOWN ST 99999
Jay Sherman 123 Somestrret NULL TOWN ST 99999
More specifically, I want to remove the PO Box 33 or only send to one of
them not both.
"MattB" wrote:
> Select 'distinct' (without the quotes of course). This will eliminate
> duplicates as long as you have selected all the data properly. Be careful
> that you are getting all the data you want though.
> "Don" wrote:
>|||Don what is the primary key for this table?
Say you have the customerID (ideally you should be having one), So your
query should go like this (untested, of course).
SELECT LAST_NAME, FIRST_NAME, ZIP_CODE,
CITY, STATE, ADDRESS1,ADDRESS2
FROM YOUR_TABLE A
where
CustomerID in (SELECT MIN(Customer_id) from your_table group by ZIP_CODE,
CITY, STATE, ADDRESS1,ADDRESS2 )
Let me know if this is what u r looking for.|||You could use an aggregate function (such as MIN or MAX) when you select the
names. Don't change anything related to the address information.
Keith Kratochvil
"Don" <djw@.nospam.postalias> wrote in message
news:A558C92F-EE0E-4835-9C31-BAF798905A62@.microsoft.com...
>I have used distinct to get rid of duplicate entries, but distinct does not
> seem to help with different people at the same address.
> This is where my problem is.
> First, Last, Addr1, Addr2, City, State, Zip
> Joe Brown PO Box 33 NULL Town ST 99999
> George Brown PO Box 33 NULL TOWN ST 99999
> Jay Sherman 123 Somestrret NULL TOWN ST 99999
> More specifically, I want to remove the PO Box 33 or only send to one of
> them not both.
> "MattB" wrote:
>|||Omni's subquery should work, but if you want different parameters another wa
y
is;
begin
create table ##address (LAST_NAME varchar(50) null,
FIRST_NAME varchar(50) null,
ZIP_CODE varchar(10) null,
CITY varchar(50) null,
STATE varchar(50) null,
ADDRESS1 varchar(50) null,
ADDRESS2 varchar(50) null)
set nocount on
insert ##address
SELECT distinct
null,
null,
ZIP_CODE,
CITY,
STATE,
ADDRESS1,
ADDRESS2
FROM table (NOLOCK)
WHERE your_parameter
AND no po boxes, etc
--you could also use a case stmt to eliminate wanted or unwanted parameters
--this will load the addresses only into temp table.
update ##address
set LAST_NAME = a.LAST_NAME,
FIRST_NAME = a.FIRST_NAME
FROM table a (NOLOCK)
WHERE your parameter to tie to address
select LAST_NAME,FIRST_NAME,ZIP_CODE,CITY,STATE
,ADDRESS1,ADDRESS2
from ##address (nolock)
drop table ##address
end
"Don" wrote:
> I have used distinct to get rid of duplicate entries, but distinct does no
t
> seem to help with different people at the same address.
> This is where my problem is.
> First, Last, Addr1, Addr2, City, State, Zip
> Joe Brown PO Box 33 NULL Town ST 99999
> George Brown PO Box 33 NULL TOWN ST 99999
> Jay Sherman 123 Somestrret NULL TOWN ST 99999
> More specifically, I want to remove the PO Box 33 or only send to one of
> them not both.
> "MattB" wrote:
>

Programatically disable trigger

Is it possible to disable a trigger for the duration of a stored procedure
? It would become enbled after the sp runs.See "ALTER TABLE" in BOL.
Example:
ALTER TABLE t DISABLE TRIGGER tr_t_ins
GO
AMB
"Rob C" wrote:

> Is it possible to disable a trigger for the duration of a stored procedure
> ? It would become enbled after the sp runs.
>
>|||ALTER TABLE trig_example DISABLE TRIGGER trig1
GO
-- Re-enable the trigger.
ALTER TABLE trig_example ENABLE TRIGGER trig1
GO
BUT, if you disable the trigger, it is disabled for everyone connected to
the server that does something against the specific table. Use with great
caution.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Rob C" <rwc1960@.bellsouth.net> wrote in message
news:Ze9Pd.4999$a06.2028@.bignews1.bellsouth.net...
> Is it possible to disable a trigger for the duration of a stored procedure
> ? It would become enbled after the sp runs.
>|||alter table disble trigger - check the BOL for more details. but, be very
careful how you use this - it disables trigger (or all triggers for a given
table) for all sessions and for all users. make sure you enable it back
asap.
dean
"Rob C" <rwc1960@.bellsouth.net> wrote in message
news:Ze9Pd.4999$a06.2028@.bignews1.bellsouth.net...
> Is it possible to disable a trigger for the duration of a stored procedure
> ? It would become enbled after the sp runs.
>|||You can disable a trigger via the ALTER TABLE command but this will affect
all connections to the database.
One trick is to add a flag column to your table(s) that the triggers work on
which the trigger can examine in order to see if the logic should be
executed.
"Rob C" <rwc1960@.bellsouth.net> wrote in message
news:Ze9Pd.4999$a06.2028@.bignews1.bellsouth.net...
> Is it possible to disable a trigger for the duration of a stored procedure
> ? It would become enbled after the sp runs.
>

Programatically determine if column supports full-text searching

Hi,
Is there a way to programmatically determine (perhaps by interrogating the
system catalogs) if a column supports full-text searching.
In my application I want to use "CONTAINS" where support is available but
deprecate to "LIKE" where it is not.
TIA
Robin
call sp_help_fulltext_columns
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"DbNetLink" <info@.NOTTHISdbnetlink.co.uk> wrote in message
news:%23vi0o$pYFHA.2128@.TK2MSFTNGP14.phx.gbl...
> Hi,
> Is there a way to programmatically determine (perhaps by interrogating the
> system catalogs) if a column supports full-text searching.
> In my application I want to use "CONTAINS" where support is available but
> deprecate to "LIKE" where it is not.
> TIA
> Robin
>

Programatically deploying reports

Hi All,

I want to programatically deploy the report in VS2005 environment,ie.from an asp.net page if i click deploy report Button ,the report should be deployed into the report server automatically.So that i can view the report in report server.
the input to the asp page would be the.rdl file...
If anyone could help then it would be good.

thankyou.


See the sample here:

http://www.codeproject.com/sqlrs/SQLReportDeploy.asp

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

Jens,

Thanks for the link! I posted a similar question twice in the past couple of weeks without a response and now I have one!

|||I was tired watching the Reporting Services groups, but now I am planning to visit it more regulary. :-)

Jens K. Suessmeyer.

http://www.sqlserver2005.de
|||

Another way of doing this can be found out at

http://sqlblog.com/blogs/rhundhausen/archive/2006/12/26/deploy-rdl-files-to-multiple-sql-server-2005-reporting-services-servers.aspx

check it out this really works.

Programatically Creating Report In PDF Format

My users have a lot of reports that they need to generate and save in PDF
format. Each report is the same, except using different parameters.
What I'd like to do is programatically generate a bunch of PDF report files
to a folder on the network, each one using just a different set of parameters.
I have successfully generated a report using the URL:
http://localhost/reportserver?/Profit%20And%20Loss%20Report&Company=0&JobCode=757375&CustomerGroup=&rs:Command=Render&rs:Format=PDF&rc:OutputFormat=PDF
This pops up a Save As... dialog box, prompting the user for a path and
file name. I'd like to control and set the path file name programatically to
automatically generate all the report permutations by passing different
parameters.
Is the URL method the right approach? Any advice would be appreciated, or at
least point me in the right direction so I can research the actual mechanics
of doing this.
Thanks!!!I think what you want can be accomplished using the Subscription feature of
Reporting Services. You can specify a subscription with the "Report Server
File Share" delivery method in order to save PDFs to a folder on the network
on a specified schedule. You can also set up a shared schedule so all the
subscriptions run at the same time.
- Byron
"Smit-Dog" wrote:
> My users have a lot of reports that they need to generate and save in PDF
> format. Each report is the same, except using different parameters.
> What I'd like to do is programatically generate a bunch of PDF report files
> to a folder on the network, each one using just a different set of parameters.
> I have successfully generated a report using the URL:
> http://localhost/reportserver?/Profit%20And%20Loss%20Report&Company=0&JobCode=757375&CustomerGroup=&rs:Command=Render&rs:Format=PDF&rc:OutputFormat=PDF
> This pops up a Save As... dialog box, prompting the user for a path and
> file name. I'd like to control and set the path file name programatically to
> automatically generate all the report permutations by passing different
> parameters.
> Is the URL method the right approach? Any advice would be appreciated, or at
> least point me in the right direction so I can research the actual mechanics
> of doing this.
> Thanks!!!|||Thanks for the reply Bryon.
The only problem with setup up report subscriptions is that there are about
5 different parameters for the report, and basically I need to cycle through
dozens and dozens of possible parameter values for each parameter. And the
values are database driven, so they will change over time.
I'd like to programatically query the database for a list of valid parameter
values, then loop through the parameters list and generate all the PDF
reports with the proper syntax.
I'm guessing that I can do this from VB or .NET by accessing the SRS web
service interface. I just can't seem to find or understand the documentation
for doing this. Any example code would be great.
Thanks...
"Byron" wrote:
> I think what you want can be accomplished using the Subscription feature of
> Reporting Services. You can specify a subscription with the "Report Server
> File Share" delivery method in order to save PDFs to a folder on the network
> on a specified schedule. You can also set up a shared schedule so all the
> subscriptions run at the same time.
> - Byron
> "Smit-Dog" wrote:
> > My users have a lot of reports that they need to generate and save in PDF
> > format. Each report is the same, except using different parameters.
> >
> > What I'd like to do is programatically generate a bunch of PDF report files
> > to a folder on the network, each one using just a different set of parameters.
> >
> > I have successfully generated a report using the URL:
> >
> > http://localhost/reportserver?/Profit%20And%20Loss%20Report&Company=0&JobCode=757375&CustomerGroup=&rs:Command=Render&rs:Format=PDF&rc:OutputFormat=PDF
> >
> > This pops up a Save As... dialog box, prompting the user for a path and
> > file name. I'd like to control and set the path file name programatically to
> > automatically generate all the report permutations by passing different
> > parameters.
> >
> > Is the URL method the right approach? Any advice would be appreciated, or at
> > least point me in the right direction so I can research the actual mechanics
> > of doing this.
> >
> > Thanks!!!|||programmatically...
you mean something like this? I think this is right.
warnings = rs.CreateReport(asReportName, "/", True,
reportDefinition, Nothing)
If Not (warnings Is Nothing) Then
Dim warning As ReportService.Warning
For Each warning In warnings
lblMsg.Text = warning.Message
Next warning
Else
lblMsg.Text = "Report: {0} created successfully with no
warnings"
End If
result = rs.Render(reportName, "PDF", historyID, devInfo,
parameters, credentials, showHideToggle, encoding, mimeType,
reportHistoryParameters, warnings, streamIDs)
sh.SessionId = rs.SessionHeaderValue.SessionId
lblMsg.Text = "SessionID after call to Render: {0}" &
rs.SessionHeaderValue.SessionId
lblMsg.Text = "Execution date and time: {0}" &
rs.SessionHeaderValue.ExecutionDateTime
lblMsg.Text = "Is new execution: {0}" &
rs.SessionHeaderValue.IsNewExecution
' Write the contents of the report to an pdf file.
Try
' Dim stream As FileStream = File.Create("C:\" &
asReportName & ".pdf", result.Length)
Console.WriteLine("File created.")
stream.Write(result, 0, result.Length)
Console.WriteLine("Result written to the file.")
stream.Close()
Catch ex As Exception
lblMsg.Text = ex.Message
GoTo Exit_Sub
End Try
--
Message posted via http://www.sqlmonster.com