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


ADVERTISEMENT

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

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 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

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

Passing In Current Database Name To DTS-based SQL Task?

Sep 28, 2006

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

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

2. Upon failure, send the following message:

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

select @srvname=srvname from master.dbo.sysservers
print @srvname
select @db_name=name from master.dbo.sysdatabases
print @db_name
set @msg='Hi--check your database backups. The ' + @db_name + ' database backup on ' + @srvname + ' has failed.

Thanks--SQL Server';

Upon success, go to the next database to back up, execute through these steps for the next database. Here's my problem: The @db_name variable captures the proper value for the current SQL Server, but I want to turn both @srvname and @db_name into global variables. I would like to pass in @db_name as the current database being backed up (and failing), and @srvname as the current SQL Server instance being backed up.

The above statement "select @db_name=name from master.dbo.sysdatabases" definitely does not capture the current database name value. Any suggestions as to how to pass this in, if not as a global variable?

Thanks in advance,

Jonathan

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

Pass Current Date To SProc

Jan 23, 2004

All,

I have a stored procedure that uses two parameters (@StartDate, @EndDate) and I want to pass the current date (no time) and when I try:

EXEC sp_AMR_AllComplSummary convert(varchar(12),getdate(),101), convert(varchar(12),getdate(),101)

I get Incorrect syntax near the keyword 'convert'.

AND Trying:
EXEC sp_AMR_AllComplSummary [convert(varchar(12),getdate(),101)], [convert(varchar(12),getdate(),101)}]

I get Error converting data type nvarchar to datetime.

This should be simple and I am lost.
Thanks in advanced.

View 4 Replies View Related

How To Get The Current Date In C# And How Do I Pass This Date To SQL Server

Apr 22, 2007

I am writing a ASP.NET C# web application. I will need to store the date in one field in one of my tables. It appears that I need to use the datetime data type for the date in SQL Server 2005.
So I have a question
1.) How do I get today's date in C# and how should this be passed to SQL server?

View 7 Replies View Related

Current Executing Task

Dec 8, 2006

Hi everyone

I'm trying to write a monitoring application for SSIS packages deployed on my machine. I know I can look at running packages via the DtsRuntime.Application object's GetRunningPackages method. Does anyone know if there is any way one can view tasks in that package that are currently being executed?

Cheers

Sachin

View 4 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

XML Task: How To Pass Arguments To XSLT

Aug 10, 2006

In the XML Task if you set the OperationType to XSLT, how do you pass arguments to the Transform like you would in .Net by using the XsltArgumentList class? Thanks.

View 3 Replies View Related

How To Pass Results Of A SQL FOR XML Query To An XML Task?

Aug 15, 2006

How do I pass the results of a sql 'FOR XML' query to an XML Task? I tried using a user variable of type string. In my Exec SQL Task on the General tab I set the ResultType to XML. Then on the Result Set tab I map it (Result 0) to my user variable (string). Then in the XML Task I use that variable as the Source. However, it fails in the Exec Sql Task with error
"End tag 'CustomJob秱孒秱怈пField' does not match the start tag 'CustomJobField'

It looks like some extraneous chars are getting inserted into my tags? 
I also tried setting the ResultType to SingleRow but that failed with error:

"The type of the value being assigned to variable "User::ForXmlResult" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object. ".

Any ideas?  Thanks.

View 2 Replies View Related

How To Pass A Table Name As A Parmater In SQL Task

Dec 22, 2006

I am trying to execute an SQL task in a ForEach container that is the table name for a select statment I want to execute (table name is passed from a rowset created before the ForEach container).

ForEach Container is looping correctly (I've used a watch to make sure each of the table names in the previous rowset are being passed correctly). I want to use the table name to execute the following query:

Select count(*) as TableRowCount from MyLinkedServer...?

(with ? as the table name)

Problem I am having is that the SQL Task Editor keeps placing a space between the last period and the parameter and then telling me it cannot parse the SQL.

I tried:

Declare @SQL varchar(255)

Set @SQL = 'Select count(*) as TableRowCount from MyLinkedServer...' + ?

Exec(@SQL)

Same error as above. My parameter is varTableName

If I used the Declare and hardcode the table name (i.e. MyLinkedServer...MyTable), and it works fine. Just doesn't seem to want to allow the table name as a parameter...

Thoughts, ideas??? Am very new to SQL 2005 but did the above with DTS... Thank you for any assistance...

Danno

View 4 Replies View Related

How Do I Pass A Result Set Into An SQL Task For An Insert?

Feb 19, 2008



Hello,

I am new to SSIS so I'm sure this is easy to do but I can't seem to figure it out. I created a SQL task that creates a result set. I would like to loop through each result of the result set and insert it into another table.

I'm not sure how to map the result set as input to the second SQL task that will do the insert. I can put the variable in the parameter mapping but I don't know what the SQL should look like to insert this into my table. Each row of the result set has five columns. Normally I have something that looks like INSERT...Values(?,?,?,?,?) but because my input parameter is just one result set object this doesn't work.

Help?

View 5 Replies View Related

Disable A Task In The Current Package Programmatically?

Dec 14, 2006

Hi,

I have a package comprising a number of Data Flow Task steps, to import various tables of data from some Access databases into SQL Server. The name of some of these Access databases will change depending on the date, e.g. last year's data is currently in a database called "2005data.mdb". At year end this will be superseded by "2006data.mdb". The Access databases are within a 3rd party system so I have no control over the file names.

I have a Script Task that checks the current date, and changes the name of an Access database in the connection string to reflect last year's date. But to complicate matters, last year's file might not exist.

So the Script Task checks whether the file name exists. If not, I would like to disable the Task that uses this connection. But how do I reference a task within the package that contains my Script Task, by name, to set the Disabled attribute to true?

I want to do something like CurrentPackage.Tasks("MyDataFlowTask").Disabled = True.

I would also welcome alternative suggestions for how to achieve this.

Many thanks,

Keith.

View 10 Replies View Related

Inserting The Current Date And Time Into SQL Server Database

Mar 30, 2007

I need an SQL string that inserts the current date into a database.
So far I have tried:
SQL = "INSERT INTO X (START_DATE) VALUES ('" & Date.Now & "')"
mycomm = New SqlCommand(sql, myconn)
mycomm.ExecuteNonQuery()
However, there is a problem with the SQL command. The problem is related to the date. Is there a way of programatically inserting the current date/time into the SQL database? Language used is VB.

View 1 Replies View Related

Pass A Variable To A DataReader In A DataFlow Task

Feb 13, 2007

How can I pass a variable to a DataReader in a DataFlow task?

My SqlCommand for the DataReader is:
SELECT CustName, CustCode FROM Customers WHERE CustCode = '?'

The DataFlow task is nested in a ForEach loop. I confirmed that the variable is changing with each loop by using a ScriptTaks and a message box. However, the DataReader SqlCommand does not seem to be updating.

View 4 Replies View Related

To Pass A Dataset To .net Script Task As N Object

Mar 21, 2007

I want to pass a dataset to my .net script task as an object. I know how to declare an Obect variable and map the result set of my Execute SQL task to the Object variable lets say tbl1. Then on the Advanced Menu of .Net Script task I input tbl1 as my ReadOnlyVariable. But once in the design view of the .Net Script I am unable to get and work with every row of the my tbl1 variable.

View 5 Replies View Related

How To Pass Parameters Into Data Flow Task

Jul 18, 2007

I have a DTS package of SQL server 2000 which has two "Execute SQL Task", which gets maximum ID (call it maxID1) from table1 in mysql and maximum ID (call it maxID2) from table 2 in sql server. Those 2 as global variables passes into a data flow which grabs all data from mysql's table1 with its ID > maxID2 and ID <= maxID1 and insert into SQL server table3. This package is working so far.



My question is how to achieve the same thing in SSIS? I created two "Execute SQL Task", which will get maxID1 and maxID2, and one "Data Flow Task". But how to pass those 2 parameters into that "Data Flow Task" without using "Script Task"?



Anyone could help? Thanks!

View 4 Replies View Related

Generate Script For Current Sql Server Login And Database Users

Dec 12, 2007

Hello Everyone
How do you generate a script for all the current sql server logins and generate a script for database users for each database.? You can script operaoers, tables, databases, and a lot of other objects by using the “All Tasks” shortcut menu option, but I haven’t figured out to script logins and database users. Any help would be greatly appreciated.

I’m using sql server 2000 and Enterprise Manager.

Thanks
GEM

View 2 Replies View Related

Send Mail Task Component, How To Pass Credentials

May 19, 2008



Exist any way to pass custom user and password info to the Send Mail task using the connection string property?

View 4 Replies View Related

The Server Principal XYuser Is Not Able To Access The Database Ydb Under The Current Security Context

May 23, 2007

SQL2005 on winserver 2003. I have a view in Xdb that accesses tables in 2 different databases (Xdb and Ydb) on the same server. I have mixed mode security. I have a SQL user (XYuser) that has read access to all tables and views on both databases, yet when I try to access the view using a C# windows application I get the following error:



The server principal "XYuser" is not able to access the database "Ydb" under the current security context



This same scenario works under SQL 2000. I looked through the postings and tried to set TRUSTWORTHY ON on both databases but that didn't help. I can access any other views or tables on the SQL 2005 server, just not the one that joins the tables cross databases. Any help is much appreciated... john

View 17 Replies View Related

Windows Server Principal Denied Access To Database Under Current Context

May 1, 2007

Hi guys. I created a database "MyDatabase" using an AD Account "user01" which is a member of a domain group "GroupA". I have created a login in my SQL Server 2005 for this AD group. I have also added the said login as a user of my database. I created other AD users and put them in the same group. When I try to access the database using the other users, I get this message

The server principal "MyDomainuser02" is not able to access the database "MyDatabase" under the current security context.

This KB tells me that my situation is triggered by the first case in which the owner of the database is windows authenticated. I have already set the database to be TRUSTWORTHY. I haven't tried CERTIFICATES though. I believe I haven't done anything complex to warrant this solution.

I'm really lost with the myriads of principals and securables that SQL2005 has. All I want is just to execute a certain set of stored procedures. I can't do this because I can't even execute "USE MyDatabase". What are the permissions I need to give to "GroupA" ?

View 5 Replies View Related

Pass Large Data Into Stored Procedure Using Execute SQL Task

Jan 15, 2008

Dear All!
I use a "Execute SQL Task" to call a Stored Procedure. My Stored Procedure have an input parameter with type: ntext. And in "Execute SQL Task", I set variable in Parameter Mapping as following:

Variable Name: User::xmlDocument (this variable is a String to store xml data)
Direction: Input
DataType: NVARCHAR
ParameterName: 0


When length of "User::xmlDocument" is too large then error is happen but on the contrary, "Execute SQL Task" run successfully.
So, Can you show me how to pass large data into stored procedure using "Execute SQL Task"?
I am looking forward to hearing from you
Thanks

View 20 Replies View Related

How To Pass Values To A Stored Procedure Parameters By Using Script Task

Nov 27, 2007



Hi All,

I have One package that it contains one Execute SQL task in that i have placed a Stored procedure .
Now i want to pass values to Stored procedure parameters from a databse table by dynamically .For this i am trying to use " Script task "
How can i pass that table column values to that stores procedure thru using Script Task?

Regards,
Maruthi..

View 3 Replies View Related

How To Pass Command Line Parms To The Execute Package Task

Oct 2, 2006

I have a ForEachLoop parent pkg that reads thru the file system of dtsx to be executed.

I would like to pass CLI parms to the command itself (dtexec). I'm not looking at passing values to the child pkgs but rather additional command line values such as:

/CONFIGFILE "C:myconfig.dtsConfig.



In my expression builder for the PackageName I added the additional string but during the execution, the reference to my dtsconfig is ignored without any errors and the child pkg runs using the default values provided at design time.

@[User::PackageToRun] + " /CONFIGFILE C:\myconfig.dtsConfig ".



How does one add additional CL values during the runtime for Execute Package Task?



Thanks,

Anatole

View 3 Replies View Related

Integration Services :: Pass Parameters To SSIS Execute Process Task?

Nov 3, 2015

Got a powershell script to split a large XML file to split in smaller chunks. I have Execute ProcessTask in SSIS with: 

Executable: %windir%system32WindowsPowerShellv1.0powershell.exe

argument: -ExecutionPolicy ByPass -command ". 'C:WorkspacesSplitToytPMFile.ps1'"

I need to pass File Name as parameter to the PS script. I tried using the StandardInputVariable but it doesn't work. 

View 11 Replies View Related

Using ForEach And Pass Filename To Flat File Source In Data Flow Task

Mar 11, 2008

How do i use the foreach loop container and pass each file found according to a specified pattern to a Flat File Source in a Data Flow Task Object so i can operate on each file found in the foreach loop object instead of having to specify a static file name

Thanks

View 4 Replies View Related

How Do I Pass A Value In The Next Record To The Current Record?

Sep 20, 2007

Hey Forum,
Below is a solution for passing a previous value (Height) to the current record in a view using two related tables (Plant= ID PK and plantHeight = ID FK) However, I was wondering how I could also do the reverse, that is, pass a next value to the current record.

View 2 Replies View Related

The SQL Server Service Broker For The Current Database Is Not Enabled, And As A Result Query Notifications Are Not Supported. Please Enable The Service Broker For This Database If You Wish To Use Notifications.

Feb 16, 2008

Hello,          I receive this error  "The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported.  Please enable the Service Broker for this database if you wish to use notifications." I attach the database in Management Studio to query and enable the broker using the scrip below but to no avail. ALTER DATABASE DataName SET ENABLE_BROKER ‘''<<------successfulandSELECT is_broker_enabled FROM sys.databases WHERE name = 'Database name' ‘'''<<-------value is 1 Global.asax ...    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)        System.Data.SqlClient.SqlDependency.Start(ConfigurationManager.ConnectionStrings("dataConnectionString1").ConnectionString)    End Sub...Web.config ...    <connectionStrings>        <add name="dataConnectionString1" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|jbp_data.mdf;Integrated Security=True;User Instance=True"         providerName="System.Data.SqlClient" />        <add name="ASPNETDBConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=True;User Instance=True"         providerName="System.Data.SqlClient" />    </connectionStrings>... Hope you could help.  cheers,imperialx 

View 1 Replies View Related

The Database Name Component Of The Object Qualifier Must Be The Name Of The Current Database

Apr 7, 2006

Guys,1st of all.. sorry about my english ok? Im from Brazil...Im trying to get a RS connecting through 2 databases with the querybelow:SELECTscar..osbalcao.numeroos,ccell.dbo.atrib_os.osFROMccell.dbo.atrib_osJOIN scar.dbo.osbalcao on ccell.dbo.atrib_os.os =scar.dbo.osbalcao.numeroosWHERE scar.dbo.osbalcao.localprod = '257'AND scar.dbo.osbalcao.status in ('EM')On a SQL IDE i got a good RS, but, when i try to use that same query onDelphi + ZEOS, the SQL Server tells me that "The database namecomponent of the object qualifier must be the name of the currentdatabase".I really dont understand why. I can only tell that the error isreturned from SQL Server.Have anyone got the same trouble?[]'sTiago Gigli

View 1 Replies View Related







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