.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

merge statement on DB2\linux view

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :


I am using a merge statement to insert and update a view in DB2\linux view, for this we set up a linked server and for normal connections its working fine, but when I use merge statement in ssis its throwing the fallowing error

[Execute SQL Task] Error: Executing the query "SELECT [CUST_NBR]


      ,[CUST_CHRG_..." failed with the following error: "An unexpected token "DECLARE @tableVar TABLE 

      (MergeAction VARerface_1023_Archive)<concat>" was found following "".  Expected tokens may include: 

       "". SQLSTATE: 42601, SQLCODE: -104". Possible failure reasons: Problems with the query, "ResultSet"

        property not set correctly, parameters not set correctly, or connection not established correctly.


can you guys suggest me whether we can use merge statement on DB2\linux linked servers or not?

here the problem is with connection or what else?





View Complete Post

More Related Resource Links

Merge Statement Error

I'm getting the error: Attempting to set a non-NULL-able column's value to NULL. And I can't figure why the error is occurring. Code for replication in SSMS using temp tables: Yes, it's somewhat redundant, it's all dummy tables mimicing our actual setup, this is one of several similar merge statements in an SP, however only this one throws any errors. As for testing: the first pass works fine, but on a second run of just the section marked for testing it will throw the above error when it hits the update section, specifically the phoneNumberOrder seems to be causing it. Interestingly, if you comment out that block and try rerunning, it will throw the same error but it now appears to stem from the INSERT statement's phoneNumberOrder block. Commenting that out will allow the statement to run just fine. The two problem sections are indicated by comments. Any insight is greatly appreciated. -------------------------------------------------Run Once CREATE TABLE #User_PhoneNumbers(     [phoneNumberID] [bigint] IDENTITY(1,1) NOT NULL,     [userID] [bigint] NOT NULL,     [phoneNumberOrder] [int] NOT NULL,     [countryCode] [nvarchar](6) NOT NULL,     [areaCode] [nvarchar](3) NOT NULL,     [localCode] [nvarchar](3) NOT NULL,     [lineNumber] [nvarchar](4) NOT NULL,   

multiple executions of MERGE statement: Help with suitable TRANSACTION ISOLATION LEVEL

Folks, I am reasonably new to SQL Server. I am using SQL Server 2008 (no SP) on Windows XP. I am using the MERGE statement within a TSQL procedure to update a master/detail table pair (Master/Child), in which the MERGE inserts into the MASTER if a record based on the primary key doesn't exist and does, effectively nothing, if it does (well, it does an UPDATE set PK=PK so the record is passed on to the OUTPUT statement for insertion into the CHILD). Regardless as to the situation, the CHILD record has a record created when the MASTER exists or doesn't exist. Now, this code works fine with the standard TRANSACTION LEVELS. But I don't know what to do when I am running two instances of the same MERGE statement at the same time. One execution could create a record in the MASTER which the other process might try and create 5 minutes later. I really don't know what SET TRANSACTION ISOLATION LEVEL to use to allow both processes to run at the same time. I have looked at: ALTER DATABASE $(usedbname) SET READ_COMMITTED_SNAPSHOT ON; ALTER DATABASE $(usedbname) SET ALLOW_SNAPSHOT_ISOLATION ON; But these don't seem to work with their associated TSQL calls. I know this is a complex issue, but as a new SQL Server user, I didn't know where else to go. regards Simon                              

Is this a bug in MERGE statement with DELETE/INSERT?

This looks to me like a bug with MERGE statement. This does not work on SQL 2008 and 2008 R2. Note that the first commneted statement works properly but the second does not. Is there any explanation why not, other than a bug? Duplication script below. use tempdb go /* IF object_id('dbo.Test', 'U') IS NOT NULL DROP TABLE dbo.Test go IF object_id('dbo.Src', 'U') IS NOT NULL DROP TABLE dbo.Src go */ IF object_id('dbo.Test', 'U') IS NULL BEGIN     CREATE TABLE dbo.Test     (         intID int NOT NULL IDENTITY PRIMARY KEY         ,sysID int NOT NULL         ,ioID int NOT NULL         ,Code nvarchar(10) NOT NULL     )     INSERT dbo.test (sysID, ioID, Code) VALUES (1, 1, 'A')       CREATE UNIQUE NONCLUSTERED INDEX [UIXF_Test] ON [dbo].[Test]     (           [sysID] ASC,           [ioID] ASC     )     WHERE ([ioID] IN ((1)))     WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON,

How to avoid "'CREATE VIEW' must be the first statement in a query batch" when I need to use SET Q

I have a problem that I have been unable to solve.  I have a stored procedure in a database on server A that needs to create an indexed view in a database on server B.  (The environment is SQL Server 2005.)  The procedure on server A does the following:  (The EXEC statement inside the quotes is really a variable in my procedure, I've just substituted the value to make the example understandable.) EXEC sp_executesql 'EXEC [ServerB].[Database].dbo.sp_executesql @sqlStatement;' The "outer" sp_executesql causes the "inner" sp_executesql to be execute within the database on server B.  (@sqlStatement contains the CREATE VIEW syntax.)  I am able to create the view that I want to index with no problem.  However, when I attempt to create an index on the view in a subsequent step, it fails with the message "Cannot create index. Object '_dta_mv_51' was created with the following SET options off: 'QUOTED_IDENTIFIER'".  Fair enough, but if I attempt to precede my CREATE VIEW statement with the required QUOTED_IDENTIFIER, I receive an error to the effect that "'CREATE VIEW' must be the first statement in a query batch".  I'm not sure how to get around this problem.  Does anyone have the answer? SQL Server 2008 doesn't object to indexing a view that was created with QUOTED_IDENTIFIER

problem with merge statement query and parallelism plan


I have the query below which is using a parallel query plan, I am not quite sure why its doing so, I think its to do with the design of the query but apart from adding indexes and specifying maxdop 1, I was wondering if there is anything else I can do in order to rewrite the query to be more efficient and stop the use of the parallel plan.


Thanks in advance.

MERGE tblPersonProfile merge_target
USING #newrecs	sourc ON merge_target.PersonURN = sourc.PersonURN AND [AddressURN]=AddressURN AND MatchCode =[ProfileMatchCode] 
INSERT (PersonURN, AddressURN, ProfileMatchCode)VALUES (sourc.PersonURN, sourc.AddressURN, sourc.MatchCode)

How to view merge replication error (sql 2005)


We're using 2005 merge replication and we found that some records deletion cannot synchronize from publisher table to other subscriber table. (This table have very small size(<1000 records). We want to view those replication system tables or any logs for diagnostics this serious problem. Can you suggest any replication system table or logs that can indicate the reasons or hints of records deletion outsync?

Thanks and regards,

Need help with MERGE statement.





there a way to return the last CustId when INSERT but NOT in

Merge Documents as Default View


Hi all,

I use an InfoPath as reporting tool on sharepoint 2010. Upon teammembers submit their reports, team leaders are able to merge these reports into one. In order to make it pretty easy for the team leaders I solely want to display the "merge documents" view. However I am not able to select this as default view.

So if I create another view, I am not able to insert the merge function as column.

Thanks for your help!


Merge replication nested view problem

Using SQL 2005 as pub and SQL EXPRESS as sub using Merge replication. Got the following error message

The schema script 'CD_InTransit_v_153.sch' could not be propagated to the subscriber.
Error Detail:
The schema script 'CD_InTransit_v_153.sch' could not be propagated to the subscriber. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147201001)
Get help: http://help/MSSQL_REPL-2147201001
Unable to replicate a view or function because the referenced objects or columns are not present on the Subscriber. (Source: MSSQL_REPL, Error number: MSSQL_REPL20164)
Get help: http://help/MSSQL_REPL20164
Invalid object name 'dbo.Debit_v'. (Source: MSSQLServer, Error number: 208)
Get help: http://help/208

According to error message, it seems that debit_v is missing. However, I cannot control the sequence of view to replicate.  How can I solve this problem

Record Count on MERGE Statement on Insert,Update,Delete


HI All,

How can I get the numbers of records affected in the Merge statement, INSERT,UPDATE,DELETE  separately and store it in a variable so I can get it in the application side? 



khrizz tell

How to view status or progress when creating merge replication



we're using 2005 ent merge replication with very large database size with binary images (60 GB). However the replication creation process spend very long time to finish and we want to see the merge job progress. Is there any way(e.g. view system table) to see the progress or error when creating replication (merge job progress status)?


Thanks and regards,



MERGE statement not working with replication


Hi all,

I am having problems using the MERGE statement in conjunction with replication (transactional with updatable subscriber - the problem only affect the subscriber).

As specified in the documentation:

For every insert, update, or delete action specified in the MERGE statement, SQL Server fires any corresponding AFTER triggers defined on the target table, but does not guarantee on which action to fire triggers first or last. Triggers defined for the same action honor the order you specify. For more information about setting trigger firing order, see Specifying First and Last Triggers.

Which can make sense but doesn't explain why when inserting a record using MERGE on a subscriber replicated table two replication triggers are fired one of which tries to insert NULL columns to the table failing replication.

I couldn't really find any documentation about that and the only thing left to do was removing all MERGE statements.

Does anyone have an idea on why it happens and has any suggestions?

Here our SQL vesion: Microsoft SQL Server 2008 (SP2) - 10.0.4000.0 (X64)   Sep 16 2010 19:43:16   Copyright (c) 1988-2008 Microsoft Corporation  Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7600: ) (VM)

Thanks a lot.


how to merge two columns value into single column in sql select statement?


i have a query like this

SELECT     tblClientDocument_Base.Document_name, tblJobDocument_Base.Document_Name AS Document_name
FROM         tblClientDocument_Base JOIN
                      tblJobDocument_Base ON tblClientDocument_Base.Tenant_Id = tblJobDocument_Base.Tenant_Id

it returns

Document_name        Document_name

a                                   d

b                                   e

c                                    f

now i want to merge like this









plz help?

Truly Understanding View State

This article provides a detailed understanding of the ViewState.

GridView Parent Child View with JQuery Effects

I was just checked how to add some more cool effects to the GridView control using JQuery. In this post I will display parent-child data in the GridView control with some help of the wonderful JQuery library.

Let's first populate the GridView control.

Model View Controller (MVC) for ASP.NET

Model View Controller (MVC) architectures, immediately wonder how the MVC pattern can be applied in an ASP.NET world. This article will demonstrate how the MVC pattern can be applied to an ASP.NET web application and still maintain the basic Microsoft supplied architecture.

jQuery grid view plugin

jqGridView is new, client-rich, XML-based, ajax grid plugin for jQuery library. jqGridView provides professional solution for representing and editing tabular data on the web. Carefully designed, with powerful script API, this editable DHTML grid is easy configurable with XML, and shows convincing results working with large amounts of data. jqGridView allows easy implementation of nice looking(managed through css). jqGridView is not platform-depending plug-in, it can be used with different web -programming platforms like: ASP .NET/ASP, PHP, JAVA, CGI scripts etc. jqGridView has hight bowser compatibility.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend