![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
How does one retrieve the COUNT(*) value from the following SSIS Ole Db Command query ?? SELECT COUNT(*) FROM wr_xfer_application WHERE xfer_char = ? AND xfer_nbr = ? In the current case I need to determine if a record exists for xfer_char / xfer_nbr ... if it doesn't exist I need to direct the script to create a new wr_xfer_applicaiton record. Thanks in advance !!! Barry in Oregon |
#3
| |||
| |||
|
|
I think you may want to look at using a Lookup transform to do this, or use a stored proc to wrap the check and insert in one go from the OLEDB Command "frostbb" <frostbb (AT) newsgroups (DOT) nospam> wrote in message news:OrNLjuW7GHA.1188 (AT) TK2MSFTNGP05 (DOT) phx.gbl... How does one retrieve the COUNT(*) value from the following SSIS Ole Db Command query ?? SELECT COUNT(*) FROM wr_xfer_application WHERE xfer_char = ? AND xfer_nbr = ? In the current case I need to determine if a record exists for xfer_char / xfer_nbr ... if it doesn't exist I need to direct the script to create a new wr_xfer_applicaiton record. Thanks in advance !!! Barry in Oregon |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Hi Barry, My understanding of your issue is that: You wanted to create a new wr_xfer_application record if it didn't exist by using script in SSIS. You tried OLE DB Command, but it seemed not appropriate for your task. If I have misunderstood, please let me know. I am not sure if you want a parameterized query or constant query. If you just want a constant query, you can use OLE DB Command like: IF NOT EXISTS ( SELECT * FROM wr_xfer_application WHERE xfer_char = 'A1' AND xfer_nbr= 'B1') BEGIN INSERT INTO wr_xfer_application VALUES(...) END If you want a parameterized query, I recommend that you use Execute SQL Task at the Control Flow panel. You can set the SQLStatement like: IF NOT EXISTS ( SELECT * FROM wr_xfer_application WHERE xfer_char =? AND xfer_nbr= ?) BEGIN INSERT INTO wr_xfer_application VALUES(...) END You can set the parameters according to the section "Using Excute SQL Task" in this article: SQL Server 2005 Integration Services, Part 1: Lessons from Project REAL http://msdn.microsoft.com/library/de...us/dnsql90/htm l/SQL05InSrREAL.asp If you have any other questions or concerns, please feel free to let me know. It's my pleasure to be of assistance. Charles Wang Microsoft Online Community Support ================================================== ==== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from this issue. ================================================== ==== This posting is provided "AS IS" with no warranties, and confers no rights. ================================================== ==== |
#6
| |||
| |||
|
#7
| |||
| |||
|
| \/ |
|
| ------- ---------------------- | \/ \/ |
|
Dear Barry, Thanks for your detail response. I am interested at the parameters that you set. For further research, could you please let me know: 1. What is the source of the parameters, manual input or a result set from other query? 2. Could you describe your whole data transfer process for me including how to set the parameters? Sincerely, Charles Wang Microsoft Online Community Support |
#8
| |||
| |||
|
|
------------------------OLE DB Destination |
#9
| |||
| |||
|
|
Hi Barry, Thank you for your detailed description. I performed a similar test with SQL Server due to no informix database at my side according to your process, and I managed to execute the task. My test was as following: Data Source ================================================ Data Source: <MySQLServer 2000 Instance>.Northwind Transferring Table: Shipper Record Table: transfer create table transfer ( RecordID int primary key IDENTITY(1,1), ShipperID INT, CompanyName nvarchar(50), Phone nvarchar(50) ) Data Destination ================================================== Data Destination: <My SQL Server 2005 Instance>.TestDB Stored Procedure of the destination: proc_test CREATE PROCEDURE proc_test ( @shipperId int, @companyName nvarchar(50), @phone nvarchar(50) ) AS IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Shipper]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[Shipper]( [ShiperID] [int] NOT NULL, [CompanyName] [nvarchar](50) NOT NULL, [Phone] [nvarchar](50) NULL, CONSTRAINT [PK_Shipper] PRIMARY KEY CLUSTERED ( [ShiperID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END INSERT INTO Shipper VALUES(@shipperId,@companyName,@phone) Data Flow =============================================== Same as yours: Data Reader Source--------Multicast-------------------OLE DB Command |------------------------OLE DB Destination OLE DB Command: exec proc_test ?,?,? Connections: Data Reader Source <------> mysqlinstance2000.Northwind (ADO.NET Connection) OLE DB Destination <------> mysqlinstance2000.Northwind1 (OLE DB Connection : OLE DB Provider for SQL Server) OLE DB Command <-----> mysqlinstance2005.TestDB (OLE DB Connection : OLE DB Provider for SQL Server) Mappings: OLE DB Command: ShipperID <----> @shipperId CompanyName <----> @companyname Phone <----> @phone OLE DB Destination: ShipperID <---->ShipperID CompanyName <----> CompanyName Phone <----> Phone After setting up above connections and relations, I switch to the Control Flow, right click the Data Flow Task, and click Execute Task, then I managed to execute the task. All the rows are imported into the destination table ( Shipper ) and the monitor table ( transfer ). From your previous reply, I noticed that you said "I finally realized that the approach I was trying to use won't work because of SSIS batch approach to record processing.". Based on my test, I didn't encounter this issue. Could you please lighten me more on your meaning? To be honest, I couldn't understand that clearly. If you encountered some error when you executed the task, you may mail me (changliw (AT) microsoft (DOT) com) a screenshot for better understanding. Hope this helpful. If you have any other questions or concerns, please feel free to let me know. It's always my pleasure to be of assistance. Charles Wang Microsoft Online Community Support ================================================== ==== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from this issue. ================================================== ==== This posting is provided "AS IS" with no warranties, and confers no rights. ================================================== ==== |
#10
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |