Execute SendMail Depending On A Condition

Apr 17, 2008



Hello All,

I have an Execute SQL Task and a SendMail in the control flow of my package.

If the Execute SQL Task inserts records in the Database, I want the SendMail task to be executed.

But if Execute SQL Task does not inserts even a single record in the Database, I dont want the SendMail task to be executed.

How can I achieve this...

Thanks,
Kapadia Shalin P.

View 1 Replies


ADVERTISEMENT

T-SQL: Different SELECT Executed Depending On Condition.

Apr 30, 2004

I'm trying to execute a different SELECT statement depdning on a certain condition (my codes below). However, Query Analyzer complains that 'Table #Endresult already exists in the database', even though only one of those statements would be executed depending on the condition. Any ideas as to a work around? I need the result in an end temporary table.


IF @ShiftPeriod = 'Day'
SELECT * INTO #EndResult FROM #NursesAvailable WHERE CanWorkDays = 1
ELSE IF @ShiftPeriod = 'Night'
SELECT * INTO #EndResult FROM #NursesAvailable WHERE CanWorkNights = 1
ELSE IF @ShiftPeriod = 'Evenings'
SELECT * INTO #EndResult FROM #NursesAvailable WHERE CanWorkEvenings = 1
ELSE
SELECT * INTO #EndResult FROM #NursesAvailable

View 1 Replies View Related

Execute Select Depending On The Input Parameters

Nov 14, 2006

Hello, a question please. Could anyone say me if I can create a store procedure with 2 'select's statements into. Besides, I'd want to know if I can execute a "select" depending on input parameters.

Something like this:

create storeproc
Param1, param2

if param1 <> null

Select *
from table
where id = param1

else

Select *
from table
where id = param2

end if

Thanks in advance....







View 2 Replies View Related

Execute Process Task Depending On Query Result

Apr 2, 2007

Hi Guys,



I wonder if you can help with the following requirement.



I want to be able to conditionally execute an 'execute process task' depending on the result of a query. I have a table which I will select one record/row from upon each execution, this record has a char 1 'type' field which is the indicator for what process to then execute.



This should be quite a simple package and will be run every 60 seconds so needs to be as efficient as possible.



I am thinking I should go along the lines of using an Execute SQL task to select my row in to a result set, and using a series of precedence expressions to determine what process to execute. But im not really sure how.....



I am a newbie to SSIS and 2005 in general so would appreciate any help you can provide



Chris

View 3 Replies View Related

Sendmail...Urgent Please!!

Jul 21, 2000

When I am executing the following sendmail code,it is apending the results to the mail.But I want the results to be sent as attachment,in .txt format.


exec master..xp_sendmail
@recipients='Tpolasp@hotmail.com',
@query='c2usa..sp_report_daily_pc',
@attach_results='true',
@subject='Daily fastquotes'


Interestingly,even if I use @attachments option by giving a specific file name,then also it is sending the mail in which the contents of the attached file are appended to the mail!
Is there anything that I shall configure somewhere to make it behave properly?
I am using 7.0 standard edition with no SP.Any help is greatly appreciated.

Thanks.

View 2 Replies View Related

SendMail Task

Nov 3, 1999

Hi

I'd like to access to a SendMail object with an ActiveXScript.
I access it by the Tasks property of the package object.
I can retrieve the name or the description but I cannot access to the specific properties of the SendMail object (fileAttachments, ccline, ...)
How can I do it ?

THanks

View 1 Replies View Related

Sendmail In Sql2000

May 2, 2008

hi
how to sendmail in sql2000

View 2 Replies View Related

Can I Print The Results Of A Condition Based On The Condition?

Feb 9, 2006

For example..

select * from mytable where MyNum = 7

If this brings back more than 1 row, I want to display a message that says,

Print 'There is more than one row returned'

Else (If only 1 row returned), I don't want to print anything.

Can I do this? Thx!

View 1 Replies View Related

COndition Spli - Error Date Condition

Apr 19, 2007

Dear friends,

I'm having a problem... maybe it's very simple, but with soo many work, right now I can't think well...



I need to filter rows in a dataflow...

I created a condition spli to that... maybe there is a better solution...

And the condition is: Datex != NULL(DT_DATE)

(Some DATE != NULL)





[Eliminar Datex NULL [17090]] Error: The expression "Datex != NULL(DT_DATE)" on "output "Case 1" (17123)" evaluated to NULL, but the "component "Eliminar Datex NULL" (17090)" requires a Boolean results. Modify the error row disposition on the output to treat this result as False (Ignore Failure) or to redirect this row to the error output (Redirect Row). The expression results must be Boolean for a Conditional Split. A NULL expression result is an error.



What is wrong??

Regards,

Pedro

View 4 Replies View Related

Reporting Services :: SSRS IIF One Condition Or IIF Another Condition

Jun 22, 2015

I  am trying to write an visibility function to have message shown based on two different IIF  conditions:

If behavior is to Add a customer ( if message =NAME ALREADY EXISTS, return " NAME ALREADY EXISTS",    otherwize return " NAME CREATED")If behavior is to  Delete a customer (( if message =NAME DOES NOT EXIST, return "NAME DOES NOT EXIST",    otherwize return "NAME SUCCESSFULLY DELETED")
I tried the following which doesn't work:
=IIF((UCase(First(Fields!Message.Value, "DataSetName")) = "NAME ALREADY EXISTS"), "WARNING: NAME ALREADY EXIST", "NAME  CREATED"),
IIF((UCase(First(Fields!Message.Value,  "DataSetName")) = " NAME DOES NOT EXIST"), "WARNING: NAME DOES NOT EXIST", " NAME DELETED")

View 6 Replies View Related

Sendmail Error: Urgent!

Aug 29, 2001

--------------------------------------------
Declare @filename char(22)
Declare @cmd char(100)

Select @filename = '"' + 'D:Feedsest_' + substring(convert(char(12), getdate(), 12), 3, 4) + substring(convert(char(12), getdate(), 12), 1, 2) + '"'

Select @cmd = "xp_sendmail @recipients = 'test@test.com'

, @attachments = " + @filename + " "

exec(@cmd)

Go
--------------------------------------------


Above T-SQL step is causing the following error:

Server: Msg 103, Level 15, State 7, Line 6
The identifier that starts with 'xp_sendmail @recipients = 'test@test.com'
is too long. Maximum length is 128.

Any help??Thanks.

View 2 Replies View Related

Sendmail Question...URGENT!!

Jul 18, 2000

When I am executing the following sendmail code,it is apending the results to the mail.Actually, I want the results to be sent as attachment,in .txt format.
Any help is greatly appreciated.



exec master..xp_sendmail
@recipients='Tpolasp@hotmail.com',
@query='c2usa..sp_report_daily_pc',
@attach_results='true',
@subject='Daily fastquotes'


Thanks.

View 3 Replies View Related

Sendmail Task &> Where User And Pwd ?

May 3, 2007

hi,

at the end of my ssis package flow, i want to invoke a sendmail task.
now, when configuring the sendmail service, i see i can only enter the name of my smtpserver. however, i see the task fails, probably because a user and a password is missing (i have it, but don't see where to type it in the SSIS).

(i want to use the smtp server of my internet provider)

anyone can help?

View 1 Replies View Related

Sendmail Task - How To Customize ?

May 15, 2007

I have a sendmail task following a data flow task. How can I set "To" attribute on the sendmail task before running it ? for example, read a config table and detemrine who the mail should be sent to...

View 1 Replies View Related

Sendmail With Parameters Problem...URGENT!!

Aug 30, 2001

I have a step like this: I am getting the following error:How to code @attachments in quotes?? thanks.

The name specified is not recognized as an
internal or external command, operable program or batch file.

(2 row(s) affected)

Here is my T_SQL step:


Declare @filename char(22)
Declare @cmd char(100)

Select @filename = 'D:Feedsest_' + substring(convert(char(12), getdate(), 12), 3, 4) + substring(convert(char(12), getdate(), 12), 1, 2)

EXEC xp_cmdshell @recipients = 'test@test.com'
, @attachments = @FileName

View 2 Replies View Related

Xp Sendmail Says 'mail Sent' But No Email Arrives

Sep 14, 2004

I have setup SQL Mail on a SQL Server 2000 (service pk 3a) with outlook 2002.

SQL Mail give me the success message when I test the profile.

When I send a test message to an operator from SQL Agent it works fine.

When I send a message from the Outlook 2002 client (logged in as the Service-SQL domain account), I can send a message without a problem.

However, when I send an xp_sendmail message (xp_sendmail @recipients='email@address',@message='test',@subje ct='test') it tells me 'Mail Sent' in the result window, but the email never arrives or shows up in the 'sent items' folder in outlook 2002.

Anyone else have this issue.

Thanks - Rick

View 1 Replies View Related

How Do You Send The Result Of A Query By SendMail?

Apr 19, 2007

For example the result of an Execute T-SQL Statement task.

This task does not have a hook-up for variable assignment, the SendMail can take in a variable. How do you pass the result of EXEC T-SQL statement be assigned to the variable in the SendMail task?

View 9 Replies View Related

Does ExchangeServer Accept In SendMail Task?

Jun 20, 2007

Does exchangeServer accept in SendMail task?

only SMTP?





who knows?

For internal mail server , it's only via exchange server.

View 1 Replies View Related

Column Size In Emails Generated Using XP Sendmail

Dec 14, 2007

Hi, with some help today I was able to get my stored procedure runningand have the results emailed to me. However, this is how its showingup:Accounting_Year WK_IN_FYEAR LocationGL_AccountCol Data Difference--------------- ----------- ------------------------------------------------------------------ -------------------- --------------------2007 49 Test1500-001-2587872.0200 -2587872.0200 .00002007 49 Test2500-001-3344713.5000 -3344713.5000 .00002007 49 Test3500-001Is there anyway to line them up side by side properly? When i have twocolms selected the format comes out ok. Thanks for all the helpagain!Here is the sp:CREATE PROCEDURE [dbo].[spEmailVariance](@SubjectLine as varchar(500),@EmailRecipient VARCHAR(100))ASDECLARE @strBody varchar(5000)set @SubjectLine = 'Weekly Flash Update'SET @strBody ='Select statement'exec master.dbo.xp_sendmail@recipients= 'XX@XXXX.com',@subject= @SubjectLine,@query = @strbodyRETURNGO

View 2 Replies View Related

How Do I Convey Information With SSIS SendMail Notification

May 24, 2007

How do I Convey Information using Notification - can someone please explain?

View 4 Replies View Related

Transact SQL :: How To Add Condition In Where Clause According To Another Condition

Oct 17, 2015

I write a query to get some data as the following. but i need when a user check specified condition a query parameter change to specified condition :

create proc proc_ReservationDetails
(
@status nvarchar(50) = null
)
as
begin
select reservationId, reservationStatus, reservationDesc

[Code] .....

View 3 Replies View Related

How To Pass In The Current Database, Server Name To A Sendmail Task

Sep 28, 2006

Hi all--I am writing a DTS package looking to back up all databases in sequence from a specific instance of SQL Server. I am calling CDOSYS in a stored procedure from support.microsoft.com to send email upon failure. I have two types of SQL tasks I am writing into the DTS package:

1. backup database <database> to disk = '<drive>:<path>.bak' with init

2. Upon failure of a particular database to back up to file, execute the following SQL task:

declare @srvname varchar(128),
@db_name varchar(128),
@msg nvarchar(4000)

SELECT @srvname = @@servername
select @db_name = db_name()
set @msg = 'Hi--check your database backups. The ' + @db_name + ' database backup on ' + @srvname + ' has failed.
Thanks--SQL Server';

SELECT @srvname, @db_name, @msg

(Many thanks to Whitney Weaver and SQL_Menace for help with sections of this code)

Upon success of #1 and/or #2, go on to the next database, repeating cycle of the SQL tasks above for the next database in the task. For example, this logic goes like:

1. Back up master database; if fails, send email in SQL task; if either task is successful, goto database #2;

2. Back up model database; ...<etc>.

My problem is the current database set in @db_name. I apparently need to reset this variable for each database that gets backed up, and I can't seem to get these set as values to be passed from SQL Task #1 to SQL Task #2. Any suggestions on how I might achieve this?

- Jonathan

View 1 Replies View Related

Sendmail Task From Address From A Database In SSIS Package.

Apr 16, 2008

Hi,
I have a sendmail task in my ssis package. In the From field, if i hardcode my from and to address as user@company.com it works fine and mail is sent. But i want to read the from and to values from a database table. SO i defined the package level variables and getting the values into the variables. SO at From if i specify the variable name it gives a compiel time error"the address in th from line is mal formed. it is either missing @ character or not valid".
how do i specify teh variable for from address? I feel, may be i can use expression, but i don't know how to do that.
Can anyone help me with this?

Thanks in advance,

View 7 Replies View Related

SQL Server 2014 :: Send CSV File With DB Sendmail - Missing Records

May 19, 2015

I am trying to send a csv file with 15000 records via the database mail in SQL Server 2014. The problem is that when I open my email the csv only contains 209 records. I have tried the same thing in SQL Server 2012 and it works as expected - it sends the 15000 records in the csv.

I have tested this on several sql servers with 2014 edition on them, and I have the same issue on all of them. The query breaks off at different points on each sever - for example one of them breaks off at 209 records as i said above, another one at 307. The last record always gets truncated at the same place. The csv attachment size it's about 64 kb - which is well below the 4MB limit i've configured the database Maximum File Size bytes parameter.

What i am doing basically is creating a job that is meant to execute a stored procedure and send the results in a csv in an email. The stored procedure is something like:

select col1, col2, col3
from table A1

where col1 > 1000 order by col1

View 2 Replies View Related

Integration Services :: One SendMail Task For Multiple Sequence Containers

Sep 9, 2014

I have multiple sequence containers in my package.  I only want to have one sendmail task for the failure/completion of the package.  If I put the sendmail task in the last sequence container and the first seqence fails, the sendmail task will not be reached and therefore, no email will be sent out.Is there a way to have one sendmail task for all the sequence containers and allow it to send mail regardless of what sequence fails/completes?

View 4 Replies View Related

How Do I Use SendMail Option In The Integration Services - I Found The Code On MSDN, But, How Do I Make It Workable?

May 14, 2007

if I have the following code:


using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.SendMailTask;

class TestSendMailTask
{

public static void Main()
{

Package pkg = new Package();

ConnectionManager smtpCM;
smtpCM = pkg.Connections.Add("SMTP");
smtpCM.Name = "SMTP Connection Manager";
smtpCM.ConnectionString = "smtphost";

Executable exe = pkg.Executables.Add("STOCKendMailTask");
TaskHost thSendMailTask = (TaskHost)exe;
{
thSendMailTask.Properties["SmtpConnection"].SetValue(thSendMailTask, "SMTP Connection Manager");
thSendMailTask.Properties["ToLine"].SetValue(thSendMailTask, "someone1@example.com");
thSendMailTask.Properties["CCLine"].SetValue(thSendMailTask, "someone2@example.com");
thSendMailTask.Properties["BCCLine"].SetValue(thSendMailTask, "someone3@example.com");
thSendMailTask.Properties["FromLine"].SetValue(thSendMailTask, "someone4@example.com");
thSendMailTask.Properties["Priority"].SetValue(thSendMailTask, MailPriority.Normal);
thSendMailTask.Properties["FileAttachments"].SetValue(thSendMailTask, "C:\test_image.jpg");
thSendMailTask.Properties["Subject"].SetValue(thSendMailTask, "Testing the SendMail Task");
thSendMailTask.Properties["MessageSourceType"].SetValue(thSendMailTask, SendMailMessageSourceType.DirectInput);
thSendMailTask.Properties["MessageSource"].SetValue(thSendMailTask, "This is only a test.");
}

DTSExecResult valResults = pkg.Validate(pkg.Connections, pkg.Variables, null, null);

if (valResults == DTSExecResult.Success)
{
pkg.Execute();
}

}

}



-------

How do I make it a workable package so it compiles , w/ javadoc style comments and instructions, so, other people can use it?

View 20 Replies View Related

How Not To Display A Row Depending On Other Rows.

Oct 8, 2007

Hello,
I am very new to SQL and ran into a problem using Access. I hope you can help me here.
The question is the following:
I have to tables:
Table 4x4: CommodityCode(string)/NeedofBU(high,low)
Table ASDBComplete: CommodityCode/Manufacturer/Rating(red,green,yellow)

What I want to get as a result is to display all ComodityCodes that have a 'red' rating and a 'high' NeedOfBU. So far no problem. But now there usually is more than one manufacturer for one CommodityCode. What I need now is that the CommodityCode is not displayed if there actually exist a Manufacturer with 'green' or 'yellow' rating.
How would you do that?
What I have so far is:

SELECT [4x4].[CommodityCode], [4x4].NeedofBU, ASDBComplete.CommodityCode, ASDBComplete.Rating, ASDBComplete.Manufacturer
FROM 4x4 LEFT JOIN ASDBComplete ON [4x4].[CommodityCode] = ASDBComplete.CommodityCode
WHERE ((([4x4].NeedofBU)="high") AND ((ASDBComplete.Rating)="red"));

But this gives me all the Commodities with red ratings. Even if there is a supplier with a green or yellow rating.

I would need somting like:
if exists 'commodityCode.XY with 'manufacuturer rating = green OR yellow' do not display commodityCode.xy

I really appreciate your help

View 8 Replies View Related

COUNT Depending On Data

Jul 20, 2005

Hello.I have one serious problem with COUNT in TSQL.I use MS SQL Server 2000.I would like to count rows depending on data in it.What I meat is:I have fields like:region | month | year | some_count |-------|-------|------|-------------|LA | 1 | 2003| 4 |LA | 2 | 2003| 2 |LA | 3 | 2003| 1 |LA | 4 | 2003| 6 |VV | 1 | 2003| 3 |VV | 2 | 2003| 7 |VV | 4 | 2003| 20 |VV | 6 | 2003| 3 |BB | 2 | 2002| 1 |etc...And what I would like to get from it is:region | jan2003 | feb2003 | mar2003 | apr2003 | may2003 | june2003 | etc...-------|----------|---------|-----------|----------|----------|-----------|--LA | 4 | 2 | 1 | 6 |0 | 0 | 0VV | 3 | 7 | 0 | 20 | 0| 3 | 0BB | 0 | 1 | 0 | 0 |0 | 0 | 0etc...Is it possible to do it in views? if yes then how?I could use temp tables for each month but it is not solution when I have 3yearsand more later then it will be round 40 temporary tables.Thanks for any response.Regards,Casper

View 3 Replies View Related

Adding Two Parameters With One Depending On The Value Of The Other

Feb 25, 2008



hello

sorry to distub you again

in fact i'm a beginner and i don't really see how i can do some tasks

when i display a report i want the reader to choose a client, and when he chooses a client, he can choose in the second parameter list, the missions that correspond to THIS client

so i have 3 datasets

one in which i get all my data needed
and i have a filter in where part of query




Code Snippet
where client=@client
and mission=@mission




and i filter on these 2 values

in the second dataset , i gather all the clients i have by doing this query







Code Snippet
select distinct name from client





and i have this third dataset where i gather all the missions corresponding to one client

and here i write




Code Snippet
select mission_label from client
where name=@client


the two fields are in the same time and in this third dataset i apply a filter on Parameters!client.value

but when i execute the report, the second parameter doesn't work, it gives me no choice of mission for a client, it doesn't return anything while when i execute the query in the dataset i have these values

how can i do this please?

thanks a lot in advance

and sorry or bothering with such questions



View 4 Replies View Related

Insert Identity Depending On The Value Of A Column

Apr 23, 2008

Would like to have Identity Inserted wrt a date column
Eg:
ProdDate ID Details
============================
2008.04.01 1 afafafaf
2008.04.01 2 GAFSGHFGF
2008.04.02 1 GAGJAGSDH
2008.04.02 2 QYTYTT
2008.04.03 3 QYTWRRT

At present it is not an Auto increment , I check for the Maximum ID and add One to the next Inserted record. Is there any simpler method?

View 13 Replies View Related

Insert The Rows Depending On The Cell Value

Jun 4, 2008

I want to insert the rows automatically depending on the cell value in column from another table.
Like if the value of cell "blabla" is 4 it automatically insert the 4 rows in my table with values.

Is it possible in TSQL?

View 13 Replies View Related

How To Apply An Inflation Factor Depending On The

Oct 5, 2007

Anybody knows how to apply an inflation factor depending on the date to a measure



The Inflation Factor is (Current Month Rate / X Month Rate)



So lets say for current year the rates are



Jan 121.64

Feb 121.98

March 122.244

April 122.171



For example



If I want to calculate for March I would show a column for January February and March, the column for January would be multiplied by (122.244/121.64) the column for February would be multiplied by (122.244/121.98) and march by one (122.244/122.244)



But in April the factors would be different I would have 4 columns, January February March and April, January amounts would be multiplied by (122.171/121.64) February by (122.171/121.98) March by (122.171/122.244) and April by one (122.171/122.171)


Im using SSAS 2005

Thanks in advance



Isaac

View 1 Replies View Related

T-SQL Create Self-reference In Depending Table

Jul 23, 2005

Hello all,I have two tables - Projects and ProjectStructTable Projects contains master records of the projects, ProjectStructallows to define a project herarchie and contains the fieldsPrjStructId, ProjectId, PrjStructName, ..., ParentIdPrjStructParent contains a reference to the parent or to itselves ifrecord is top-level-record for a project.I try to create a trigger on table Projects (INSERT) whichautomatically creates the top-level-entry in ProjectStruct but Ididn't succed.Tried to use (several variations similar to)INSERT INTO ProjectStruct (ProjectId, PrjStructName, ParentId)SELECT prjProjectId, 'top-level',IDENT_CURRENT('ProjectStruct'))FROM INSERTEDbut this inserts a reference to the last inserted record. Why thishappens is pretty clear to me, but I found no way to get the referenceto the identity column of the record currently inserted.Is there a way to do this?

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved