SSIS In SQL Server 2005

Oct 26, 2006

I have a sequence container with 6 data flow tasks in it. The tasks are mainly importing text files.

Sometimes the text file to be imported won't be there and this is OK in some cases. But then I get errors because the file does not exist.
What is the best way to process this?
Is there a File System Task that test for the files existence, I couldn't find it?

View 1 Replies


ADVERTISEMENT

Parameter Passing In SQL Server 2005 Integration Services (SSIS) 2005 From VB.Net2005

Sep 7, 2007

Is it possible to parm in a value to a SSIS

in my SSIS i have a variable;

Name : FileName
Scope : PackageName
Type : String

Value : ""

I have tried adding the following code in my vb.net project ;

pkg.Variables("filename").Value = "C: emp estfile.001"
pkg.execute()

but come up with the following error

A first chance exception of type 'System.MissingMemberException' occurred in Microsoft.VisualBasic.dll
Public member 'Variables' on type 'IDTSPackage90' not found.

can anyone help ?

View 11 Replies View Related

Parameter Passing In SQL Server 2005 Integration Services (SSIS) 2005

Jan 16, 2007

Hi All,

Parameter passing in SSIS 2005 sometimes appears to be a cumbursome task. I have been digging into this topic for quite some time and here i note down some simple steps to demonstrate parameter passing at Package level.

(1) Create a SSIS project using Business Intelligence 2005 Or VS 2005.

(2) Create datasource (.ds) and Data Source View as required.

(3) A default SSIS Package by the name Package.dtsx is created. Double click this and you are shown tabs for Control Flow, Data Flow, Event Handlers, Package Explorer. On the Control Flow, drap and drop Execute SQL Task from Control Flow Items in the toolbar.

(4) Lets now create a variable at Package level. Right click anywhere in the control flow box (not on the Task created in Step 3 above). Click on the Variables on the context menu displayed. Variables window appears on the left of the screen. Click the Add Variable box in this window to create a variable. Name it var1 (or whatever you may like), Scope as Package, DataType as String and Value as MyValue. This is only the default value.

(5) Now let us edit the SQL Task created in Step 3. Double on it, on the General tab you can change its Name, Description. Set ResultSet as None. We shall proceed to execute a stored procedure by name MySPName and pass it a parameter. Set ConnectionType as OLE DB. Select the connection you creates in step 2. Set SQLSourceType as Direct input. SQLStatement as MySPName ? . Note the ? mark after the name of the stored procedure. This is important to accept the variable value (var1) created in Step 4.

(6) Select Parameter Mapping tab now. Click on Add button. Select the Variable Name as User::var1. This is the user created variable of Step 4. Select Direction as Input, DataType as Varchar and Parameter Name as @var1. Click on OK now.

(7) This sets up the basic of parameter passing. Compile the project to verify everything works. Right Click on the SQL Task and select Execute Task. This will execute the package taking default value of the variable. This can be used along with dtexec command with /set option to pass the parameter at command prompt.





View 5 Replies View Related

Unable To Connect To SSIS Or SSRS On SQL Server 2005 Standard Edition Server Via Desktop Connection

Mar 8, 2008

Hi,

I€™ve developed a BI system using the SQL Server 2005 Developer€™s Edition.

SSAS, SSIS and SSRS have been added to a SQL Server 2005 Standard Edition Server in preparation for delivering the developed database to this live environment.

So I am able to connect directly to the Database Engine, SSAS, SSIS and SSRS successfully from the actual SQL Server 2005 Standard Edition box which is sat on a Windows 2003 Server operating system.


However when I launch SQL Server Management Studio from a desk top PC which is connected to the SQL Server Standard Edition box I can€™t connect to either SSIS or SSRS, however I can connect to the Database Engine and it also seems that I can connect to SSAS OK.

I am using Windows Authentication where the I used a SQL Server account which exists with €œsysadmin€? permissions and this SQL Server account has the same login name as the Windows Server 2003 desktop login.

What do I do next please?

View 4 Replies View Related

SSIS - SQL Server Integration Services Errors. SQL Server 2005

Nov 8, 2006

I created an SSIS package for a client that does data importing. When I run the pacakge from Visual Studio there is an error window showing all the errors and warnings. A good example of an error is if the import file is in the wrong format.When there is a error or warning can I write the error log to a file OR notify someone of the errors so they can make corrections and rerun the package OR any ideas that the client can find out what went wrong and then make corrections accordingly? Thanks

View 1 Replies View Related

Can I Access SQL Server 2000 Tables Via SSIS/SQL Server 2005

Apr 9, 2007

Can I access SQL Server 2000 tables via SSIS/SQL Server 2005?

View 1 Replies View Related

Moving Data In Ssis From Sql Server 2000 To 2005 On Same Server

Feb 9, 2007

hi, does anyone know how I can make a connection to a 2000 db thru ssis?

View 8 Replies View Related

Migrate SQL Server 2000 DTS To SQL Server 2005 DTS Or SSIS

Apr 8, 2008



We have DTS packages in SQL Server 2000, which populates the data from SQL 2000 to Ms-Access tables.
We are moving our database from SQL Server 2000 to SQL Server 2005.

Why & How & What is the best approach to migrate DTS packages?

Migrate SQL Server 2000 DTS to SQL Server 2005 DTS Or SSIS

View 3 Replies View Related

SQL Server 2005 SSIS Issues

Sep 27, 2007

All,

From last few days I was working with SQl Server 2005 SSIS tool. I wanted to share my findings and my questions to all of you. so that you can also share your exp with SSIS.

1. When I imported SQL Server 2005 database data into one Access mdb file.My all Varchar data type columns of SQL database converted into the memo type in the Access database mdb file.

Now when I was trying to import a data from this MS Access File into the another SQL Server 2005 database, got the error of Unicode Converting a memo data type conversion in Export/Import data wizard.

Error : "Error 0xc02020f6: Data Flow Task: Column "QUESTIONTEXT" cannot convert between unicode and non-unicode string data types.


Solution: After doing a all kind of research I found that it is not possible to import this mdb file using SSIS wizard. After that I found the Microsoft SQL Server Migration Assistant (SSMA) for Access is a tool for migrating databases from Microsoft Access to Microsoft SQL Server 2005 and it works fine.

Is this the only one solution?

Please note that I am using SSIS to expot a sql server 2005 data into the mdb file.

2. I am not able to direct export a Oracle data into the mdb file using the SSIS.Previously I was able to export the same file into the SQL 2000 using DTS.

Question: Any way to export Oracle data into the mdb file using SQL Server 2005 SSIS tool?

3. While exporting a 350 tables together from SQL Server 2005 to access using SSIS I got below warning messages :

Warning : " A large number of tables are selected for copying, and the wizard may not be able to copy all the tables in a session.Select No to go back and unselect some tables, or select Yes to attempt to copy all the currently selected at one time"

If I bypass this error and go ahead after clicking Yes button.I got the below error while validation.
Error :
- Prepare for Execute (Error)
Messages
Error 0xc0202009: {E4703917-E1C9-4815-A84A-C80CDA36E545}: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft JET Database Engine" Hresult: 0x80004005 Description: "Unspecified error".
(SQL Server Import and Export Wizard)

Error 0xc020801c: Data Flow Task: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "DestinationConnectionOLEDB" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed.
(SQL Server Import and Export Wizard)

Error 0xc004701a: Data Flow Task: component "Destination 64 - CLIMBINGEXP" (8065) failed the pre-execute phase and returned error code 0xC020801C.
(SQL Server Import and Export Wizard)

Any help ?





View 10 Replies View Related

Can SSIS Work Without SQL SERVER 2005

Feb 20, 2006

Can I install only [Bus....integ.. dev.... st..]. on my machine without SQL 2005? I have a sybase database management system.. can I work with SSIS?

Can it extract something from IBM DB2/DATACOM/LOTUS NOTES/VSAM/???

 

pl give me answers with justifications!!!!

View 8 Replies View Related

Run SSIS Package On SQL Server 2005

Feb 18, 2008

I've build the deployment manifest of my ssis package, and installed it on the sql server machine, now, how do i run this packege on sql server 2005?

View 1 Replies View Related

SQL Server 2005 Run SSIS Job Is Slow.

Dec 14, 2007

hi~
our system to run the the job with SSIS package is slower than DTS package.
The SSIS package action is the same as DTS package.
Why?
What do I take care??

Thanks!!!



View 7 Replies View Related

SQL Server 2005 Encryption And SSIS

Dec 21, 2007

Hi everyone! I have a problem and I was hoping someone could help me with it.


Here's my scenario:
I have to access to an intermediate SQL Server 2005 database, which I cannot change or alter. In this database is information that a I need to retrieve and put in our website database. One item of information is a persons SSN which is stored in a varbinary field and encrypted using a certificate.

In my Data Flow task which processes this information I am using an Ole Db Source to retrieve the information with the SQL Script:


SELECT
CAST(DecryptByCert(Cert_ID('Certificate_Name'), [IntermediateDB].[SSN]) AS VARCHAR) As SSN
FROM
[dbo].[IntermediateDB].[SSN]


BTW, This script runs fine from within SQL Server Management Studio. It decrypts the SSN to the appropriate value. However, when I run it in SSIS, I receive a truncation error which is no small surprise b/c the SSN value is in a large binary format. I.e:


0x55 0x56 0x69 0x99 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ...


It goes on further, but for the sake of brevity and my own sanity I thought I should truncate it.


It seems like SSIS's use of the certificate is failing (although I don't get an error for that) and is simply pulling the encrypted SSN from the intermediate table.


So my first question would be, is this actually what's going awry? And secondly, is there a way to fix this without touching the source database??


Thanks! I greatly appreciate it! And Happy Holidays!

Derek

View 4 Replies View Related

SSIS AcquireConnection Error Is SQL Server 2005

Oct 11, 2006

I open a package in SSIS I get the following errors.Validation error. Create TestKeys For Scan Records: TestKeys Table in AEISIT Import db [1]:The AcquireConnection method call to the connection manager "AEISIT Upload" failed with error code 0xC0202009. ScanUpload.dtsx 0 0 I open my connections in the connection manager and set them to the (local) server and the errors go away.Then I close and reopen the package and the errors are back.What am I doing wrong??

View 2 Replies View Related

Ssis Package,job Schedules In Sql Server 2005

Jan 16, 2008

can any one tell me the sql server 2005job schedules,ssis packages 

View 1 Replies View Related

SQL Server 2005 SSIS Package Error

Mar 31, 2007

Hi,

We are migrating our production environment from 32-bit SQL Server 2005, Windows 2003 server to 64-bit SQL Server 2005, Windows 2003 server environment with 4GB of RAM. We have recompiled the SSIS packages to run in 64-bit mode and stored them in database. But one of the package fails with initial information as

Information: The buffer manager detected that the system was low on virtual memory, but was unable to swap out any buffers. 34720 buffers were considered and 34720 were locked. Either not enough memory is available to the pipeline because not enough is installed, other processes are using it, or too many buffers are locked.

And the subsequent error messages received as

Error Message 1

A buffer could not be locked. The system is out of memory or the buffer manager has reached its quota.

Error Message 2

An OLE DB error has occurred. Error code: 0x80040E14. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".". An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.". An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "Reading from DTS buffer timed out.".

Please guide us in troubleshooting this issue.

Thanks & Regards
Amit

View 21 Replies View Related

Deploy SSIS Without Installing SQL Server 2005

Apr 13, 2007

SSIS packages can also be run on systems where SQL Server is not installed.



How do we package the DTUTil.exe and DTEXEC.EXE. with the manifest file

How do we execute the packages using the file system utility.



Any suggestions/help is appreciated.



Regards,

Rashmi



View 7 Replies View Related

Is There A Way To Use SSIS With SQL Server 2005 EXPRESS EDITION?

Apr 11, 2008

I understand there is no Import/Export data feature within SQL Server 2005 Express Edition but i was wondering if there is a way to use SSIS/DTS with SQL 2005 Express?

I have used the DTSWizard tool to create a number of DTS packages. I was hoping to be able to execute them from some C# code.
However, a lot of examples i have seen indicate that i need to add a reference to Microsoft.SqlServer.ManagedDTS.dll in order to do this. The problem is, i cannot find this .dll file anywhere. I'm told it should be in C/Program Files/Microsoft SQL Server/90/SDK/Assemblies, but it isn't.

Is this because i only have the Express Edition installed and not the ful version of 2005?

Another .dll file i have found is Microsoft.SqlServer.DTSPkg80. Is that in anyway useful? I'm not too familiar with the DTS and SSIS tools/processes.

Any help would be appreciated.

Cheers,

Jon

View 4 Replies View Related

Running SSIS Packages In MS Server 2005

Jan 31, 2008

Hi
Just a brief question,
is there a way of displaying a success or not success message when running (testing) an SSIS package on SQL 2005 ?

Because i have to go through the steps to see if there was an error or not and for large SSIS packages this is a pain.

With DTS 2000 after it ran you got a message saying successfull or not, is there a way to activate this in SQL 2005 ?

I suppose i could just run the job ... but I prefer the other way as sometimes a job fail is a permissions problem, not a SQL/datapump task problem...

View 1 Replies View Related

SSIS Help Loading From Sql Server 2005 To Informix 7.3.1 SE

May 16, 2008

HI

I am transferring the data from sql server 2005 to Informix 7.3.1 SE using SSIS .

I am using the OLEDB data connection for both source as well as destination databases.

I am trying to mapping the source and destination tables .I am getting the following error.


TITLE: Microsoft Visual Studio
------------------------------
Error at Data Flow Task [OLE DB Destination [184]]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E21.
Error at Data Flow Task [OLE DB Destination [184]]: Opening a rowset for ""srinivas"."company"" failed. Check that the object exists in the database.

------------------------------
ADDITIONAL INFORMATION:
Exception from HRESULT: 0xC02020E8 (Microsoft.SqlServer.DTSPipelineWrap)
------------------------------
BUTTONS:
OK
------------------------------


I am using the following ODBC driver for the connecting INFORMIX 7.3.1 which is running on LINUX environment.
Openlink Generic ODBC Driver

It's creates the table in the informix 7.3.1 but it's not mapping the source and destination databases columns.

Please help me any one. it's urgent .


Thanks,
Srinivas Unnam

View 3 Replies View Related

Executing SSIS Package In SQL SERVER 2005

Oct 5, 2007

Hi, here is my problem :

I want to run ssis package in sql server 2005 agent.
i've made a new JOB with 3 steps ( 3 ssis package)

But when i run the job, i see only 2 "actions step" in the windows :

Start job .....
Execute job ....

I would like to see at least the execution status of every ssis package and if it's possible,
the execution of every task ( to see quickly if there's some error and what's wrong)

What's the best solution to doing that

Thank for helping
BG.

View 1 Replies View Related

SSIS Access Import To SQL Server 2005

Feb 22, 2007

Hi,


I have created a SSIS dtsx package file on my file system that I want to manipulate in .NET

The package gets an access DB file and the a Preparation SQL Task creates the necessary sql statements for the data flow task. The data flow maps the tables from the source to the destination and then if you execute the package, it copies the Access DB into SQL Server.

My problem is, I want to manipulate this package in code, so that I can change the path to the source Access DB and then re execute the Preparation SQL Task so it recreates the new SQL statements, and then I want to update the data flow so that I it uses the new SQL and creates the necessary tables.


How is this possible in .NET

I have looked everywhere and have found some topics but with no luck.

Can anybody please help me

View 3 Replies View Related

Sql Server 2005 SSIS And AS400 Connectivity

Mar 29, 2006

Hi all

I am trying to connect to an AS400 to download data to a 64bit sql server 2005 server. I am able to do this easily by migrating existing sql2000 DTS packages but how do i do this is in an SSIS project creating the process from scratch? and how do i incorporate activex transforms like you could in DTS2000 into the trasnform with copy columns?

Please help i am slowly turning grey trying to get this to work.

thanks

Chris

View 1 Replies View Related

Derived Column In SQL Server 2005 SSIS

Oct 5, 2006

Hi,

I am trying to upload a csv file into a destination SQL Server table using Data FLow objects in MS SQL Server 2005 SSIS. My destination table X has a date column while my source data file (for which i have a flat file connection) does not have a date column. I created a Derived column for date using the system date function in my Source data object and ran the package but it returned errors. I changed the data type of the derived column but I still get errors.

is there any other way i can get the date on the fly i.e generate a date for the incoming source file and map that (insert into) to the destination table ?

Thanks.









View 2 Replies View Related

MS SQL Server 2005 SP2 Problems With SSIS Packages

Mar 8, 2007

I installed SP2 to one of our servers to see what we'd need to do for our Production systems. The server in question is used for a log shipped copy of production, SSRS, SSIS and general duty stuff. I got errors in two areas during the installation -- 1 dealing with SSNS (don't use it yet on that server) and the second being the Client product.

After a reboot I went into a Business Studio solution I've been working on (and using) for several months. None of my packages are working--each having the following problem:

Unable to cast COM object of type 'Microsoft.SqlServer.Dts.Runtime.Wrapper.PackageNeutralClass' to interface type 'Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSContainer90'.
This operation failed because the QueryInterface call on the COM component for the interface with IID '{8BDFE892-E9D8-4D23-9739-DA807BCDC2AC}'
failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))..

It seems to be in the designer as it is unable to display the the graphical version but it does let me switch to the code view.

What is the easiest way to troubleshoot and/or fix this?

View 6 Replies View Related

Major SQL Server/SSIS 2005 Performance Issue

Mar 24, 2006

SQL Server 2005 is installed on a brand new 64-bit server (Windows 2003 x64 std. Edition, 2.4 Ghz AMD opteron- 2cpu, 8.8 Gb of RAM). There is barely few hundred rows of data scattered among few tables in one database.

SQL server and SSIS performace grossly degrades overnight and in the morning everything is slow including the clicking of tool bar selection.It takes 3 seconds to execute a simple select statement against an empty table.

It takes15-20 seconds to execute a SSIS package that normally would take 2-3 seconds.

But once SQL Server is restarted, everything returns to normal and the performance is good all day and then the next day everything is slow again.

Thank you for your help.

View 3 Replies View Related

It's Possibel Run SSIS In SQL Server 2005 Express Edition

Sep 19, 2006

Hy,



I wont now if it's possible to run SSIS in my server client that have instaled SQL Server 2005 Express Edition?



Regards,



Filipe Silva

View 2 Replies View Related

Converted Our DTS 2000 Packages To Sql Server 2005 SSIS

Nov 7, 2007

We are converted our DTS 2000 packages to Sql Server 2005 SSIS. I am getting following error on my ActiveX script that got converted. I am new to SSIS and DTS. Never ever worked with ActiveX also. So any help would be appreciated. Following is the script followed by error I get:



'**********************************************************************

' Visual Basic ActiveX Script

'************************************************************************

Function Main()

Dim oPkg

SET oPkg = DTSGlobalVariables.Parent

SET stpBeginJob = oPkg.Steps("DTSStep_DTSActiveScriptTask_1")

SET stpFinishedJob = oPkg.Steps("DTSStep_DTSActiveScriptTask_3")

IF DTSGlobalVariables("Count").Value > 0 THEN



stpFinishedJob.DisableStep = True

stpBeginJob.ExecutionStatus = DTSStepExecStat_Waiting

ELSE

stpFinishedJob.DisableStep = False

stpFinishedJob.ExecutionStatus = DTSStepExecStat_Waiting

END IF



Main = DTSTaskExecResult_Success

End Function


Error I get Is:

[ActiveX Script Task] Error: Retrieving the file name for a component failed with error code 0x000A39BC.

Thank You

View 1 Replies View Related

SQL Server 2005 - SSIS: Global Package Configuration

Jan 7, 2008

I am new to SQL server 2005 and have a config question:


I am controlling database connection info using XML indirect config - no problems there.


Essentially I am going to have a number of packages that need to use a common file path, that might change from one server to the next, e.g. Server 1: C:sourceFiles versus Server 2: D:sourceFiles. Within this directory the filenames will remain static. So in the flat file connection manager I'd like to use a variable to reflect the folder - but I don't want to have to create this for each package.


So, I thought I would create a system environment variable and create expressions for the connection managers - something like %SOURCE_DIR% + "file.csv" - but this does not evaluate correctly.


So then i though I could use the SQL server configurations table with a configurationFilter SOURCE_DIR and appropriate configuration value - but then how do I access this in the flat file connection manager to create a dynamic file name?

So essentially I want a variable/property available globally to all my packages and potential flat file connection managers that help me to centrally control file path locations.


Any help would be most appreciated.

View 3 Replies View Related

Usage Of Dtutil And Dtexec In SQL Server 2005 SSIS

Nov 22, 2006

1) We are migrating data from SQL Server 2000 to 2005 DB.

2) We are developing SSIS packages in client, build, deploy and install and copying to SQL Server 2005 server to execute for migration.

3) For this we encrypt all packages with password, then decrypt all while executing in a batch file using dtexec. This works fine.

4) What does not work is executing a master execute task in which are individual execute tasks. This is so since the other packages are still encrypted.

5) We decrypted them separately first using dtutil using Decrypt and Copy/Move option but while executing error is thrown that these other packages are still protected by password.

6) Do we need to decrypt, then encrypt using default package protection level and then decrypt again.

7) How exactly to just execute a master package when packages are developed on client.

View 1 Replies View Related

Problem Using Merge Join Transformation In Sql Server 2005(SSIS)

Aug 10, 2006

Hi,
 I am pretty new to SSIS. I am transferring some rows from 2 source tables to 1 destination table.
 The 2 source tables have 1000 rows.They act as the 2 inputs to a merge join transformation where i perform the join between the 2 tables based on a couple of fields. But for some reason the output of  the merge join gives me about 1018 rows .Shouldnt the destination also have only 1000 rows?
 How do i solve tis problem?
 
Thanks in advance
Sat
 

View 1 Replies View Related

After Full SQL Server 2005 Install SSIS Is Still Not A Service On The Machine?

Aug 5, 2006

I have done a full Sql Server install on a server and the SSIS service is not available. Normally when I load Sql Server I get €œSQL Server Integration Services" as a service that I can start. On this machine it is not listed after the install. I don't get any errors through out the install.

Please Help!

Steve

View 1 Replies View Related

Setup Email To Notificate From SQL Server 2005 For SSIS Package

Aug 19, 2007

Hi,
My name is Vinh, I am a new bee in SQL Server 2005. I am using template script (see below) from SQL Server to create account but when I am right click in database mail for testing email and I got the message, could not connect to mail server.

Below I am trying to use smtp to connect but I know in my company we are using Exchange Mail Server. will that make a lot different?

Please help me,

Thank you very much,



sp_configure 'database mail xps', 1
GO
reconfigure
GO

-------------------------------------------------------------
-- Database Mail Simple Configuration Template.
--
-- This template creates a Database Mail profile, an SMTP account and
-- associates the account to the profile.
-- The template does not grant access to the new profile for
-- any database principals. Use msdb.dbo.sysmail_add_principalprofile
-- to grant access to the new profile for users who are not
-- members of sysadmin.
-------------------------------------------------------------

DECLARE @profile_name sysname,
@account_name sysname,
@SMTP_servername sysname,
@email_address NVARCHAR(128),
@display_name NVARCHAR(128);

-- Profile name. Replace with the name for your profile
SET @profile_name = 'TestProfile';

-- Account information. Replace with the information for your account.

SET @account_name = 'vdang';
SET @SMTP_servername = 'smtp.cgdnow.com';
SET @email_address = 'vdang@cdgnow.com';
SET @display_name = 'Vinh, Dang';


-- Verify the specified account and profile do not already exist.
IF EXISTS (SELECT * FROM msdb.dbo.sysmail_profile WHERE name = @profile_name)
BEGIN
RAISERROR('The specified Database Mail profile (<profile_name,sysname,SampleProfile>) already exists.', 16, 1);
GOTO done;
END;

IF EXISTS (SELECT * FROM msdb.dbo.sysmail_account WHERE name = @account_name )
BEGIN
RAISERROR('The specified Database Mail account (<account_name,sysname,SampleAccount>) already exists.', 16, 1) ;
GOTO done;
END;

-- Start a transaction before adding the account and the profile
BEGIN TRANSACTION ;

DECLARE @rv INT;

-- Add the account
EXECUTE @rv=msdb.dbo.sysmail_add_account_sp
@account_name = @account_name,
@email_address = @email_address,
@display_name = @display_name,
@mailserver_name = @SMTP_servername;

IF @rv<>0
BEGIN
RAISERROR('Failed to create the specified Database Mail account (<account_name,sysname,SampleAccount>).', 16, 1) ;
GOTO done;
END

-- Add the profile
EXECUTE @rv=msdb.dbo.sysmail_add_profile_sp
@profile_name = @profile_name ;

IF @rv<>0
BEGIN
RAISERROR('Failed to create the specified Database Mail profile (<profile_name,sysname,SampleProfile>).', 16, 1);
ROLLBACK TRANSACTION;
GOTO done;
END;

-- Associate the account with the profile.
EXECUTE @rv=msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = @profile_name,
@account_name = @account_name,
@sequence_number = 1 ;

IF @rv<>0
BEGIN
RAISERROR('Failed to associate the speficied profile with the specified account (<account_name,sysname,SampleAccount>).', 16, 1) ;
ROLLBACK TRANSACTION;
GOTO done;
END;

COMMIT TRANSACTION;

done:

GO

View 1 Replies View Related







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