Thursday, August 15, 2013

[SQL Server] Using REPLACE in an UPDATE statement

  1. Using REPLACE in an UPDATE statement - SQLTeam.com

    www.sqlteam.com/article/using-replace-in-an-update-statement - Similar
    31 Mar 2010 ... This article covers using the REPLACE function to selectively replace text inside
    a string in SQL Server. The REPLACE function is easy to use ...

  2. Using REPLACE in a UPDATE statement - Dev Shed

    forums.devshed.com/...sql.../using-replace-in-a-update-statement-479993. html - Cached - Similar
    Using REPLACE in a UPDATE statement- Firebird SQL Development. Visit Dev
    Shed to discuss Using REPLACE in a UPDATE statement.

  3. SQL Update Replace statement - Stack Overflow

    stackoverflow.com/questions/9525184/sql-update-replace-statement - Cached
    I need to write a sql update statement using REPLACE. The string looks like 'SE*
    88*000000001'. I need to replace the number between the two ...

  4. error while using replace in an update statement in sql server 2008 ...

    stackoverflow.com/.../error-while-using-replace-in-an-update-statement-in- sql-server-2008 - Cached
    What error are you getting ... Major Error 0x80040E14, Minor Error 25501 >
    update table US14-HSS-SQUARE_AISC14-HSS-SQUARE set ...

  5. sql server 2005 - How to update a part of the string using replace ...

    stackoverflow.com/.../how-to-update-a-part-of-the-string-using-replace- function-in-tsql - Cached
    Hi I have a column of nvarchar(1000) type. I need to get rid of encode ... This will
    replace in the entire column. REPLACE(MyColumn, '&', '&').

  6. tsql - T-SQL String replace in Update - Stack Overflow

    stackoverflow.com/questions/4350482/t-sql-string-replace-in-update - Cached
    I need to update the values so that @domain2 should be replaced to @ ...
    Replacing a string using SQL Server Replace function - string has ...

  7. sql - Oracle UPDATE statement using the `REPLACE` function ...

    stackoverflow.com/.../oracle-update-statement-using-the-replace-function - Cached
    I am trying to remember how form a proper REPLACE statement in ... UPDATE
    TABLENAME SET COLUMN1 = ' ', SET COLUMN2 = ' ' WHERE ...

  8. How to replace a string in a SQL Server Table Column - Stack ...

    stackoverflow.com/.../how-to-replace-a-string-in-a-sql-server-table-column - Cached - Similar
    i have a table (SQL Sever, in this case) which references paths (UNC or .... How
    can I update multiple columns with a Replace in SQL server?

  9. How to use REPLACE() within NTEXT columns in SQL Server ...

    www.sidesofmarch.com/.../how-to-use-replace-within-ntext-columns-in-sql- server/ - Cached - Similar
    27 Feb 2008 ... If you're using SQL 2000, you're out of luck, as NVARCHAR(max) first .... SQL
    UPDATE syntax with a replace on a column of type ntext, ...

  10. mysql - Why would an UPDATE SET REPLACE() statement match ...

    dba.stackexchange.com/.../why-would-an-update-set-replace-statement-match -rows-but-change-none-and-give - Cached
    Why would an UPDATE SET REPLACE() statement match rows, but change ... I'
    m seeking a certain string in a field and want to replace it with...

  11. Changing data in a table using the UPDATE statement

    publib.boulder.ibm.com/infocenter/iseries/.../sqlp/rbafyupdate.htm - Cached - Similar
    To update data in a table or view, use the UPDATE statement. ... Replace the
    column's current value with the contents of another column in the same row.

  12. replace considerations for SQL

    pic.dhe.ibm.com/infocenter/rbdhelp/.../regl_data_sql_replace.html - Cached
    The statement produces an SQL UPDATE statement in the generated code. ...
    Before you use the replace statement, you must retrieve a row for subsequent ...

  13. SQL UPDATE Statement - W3Schools

    www.w3schools.com/sql/sql_update.asp - Cached - Similar
    SQL UPDATE Example. Assume we wish to update the customer "Alfreds
    Futterkiste" with a new contact person and city. We use the following SQL
    statement...

  14. SQL SERVER ? UPDATE From SELECT Statement ? Using JOIN in ...

    blog.sqlauthority.com/.../sql-server-update-from-select-statement-using-join- in-update-statement-multiple-tables-in-update-statement/ - Cached
    30 Apr 2013 ... As you can see that using JOIN clause in UPDATE statement it makes it very
    easy to ... Eg. UPDATE Table SET Col1 = REPLACE(Col1, '.', ' ')

  15. Query to use update statement with Replace function in SQL Server ...

    www.aspdotnet-suresh.com/.../query-to-use-update-statement-with.html - Cached
    12 Jun 2012 ... In previous posts I explained Replace function example and Substring function
    example in SQL Server and many more articles relating to SQL ...

  16. Using REPLACE in an UPDATE statement - Ashish's Blog

    www.ashishblog.com/blog/using-replace-in-an-update-statement/
    30 Nov 2011 ... doing a search and replace in SQL is not radically difficult. You basically do an
    update using the replace() function.

  17. SQL statement for replace/update a stringvalue in an Oracle table ...

    ask.sqlservercentral.com/.../sql-statement-for-replaceupdate-a-stringvalue-in-a .html - Cached
    Please use replace in Oracle, can be done in one update statement. http://www.
    techonthenet.com/oracle/functions/replace.php. Probably you ...

  18. Replacing part of field data of table with another string using SQL

    www.plus2net.com/sql_tutorial/replace.php - Cached - Similar
    We know how to change data inside a field by using update command inside a
    query. Here we will try to learn how to replace part of the data without changing ...

  19. update using replace function - Dbasupport.com

    www.dbasupport.com/.../showthread.php?26372-update-using-replace... - Cached
    I can use select replace (col_nm '-') from table to get the data without dashes but
    how can I use this function in an update statement. Thanks.

  20. Inserting or updating records using MySQL REPLACE INTO ...

    blogs.coldbuffer.com/inserting-or-updating-records-using-mysql-replace - Cached
    Inserting or updating records using MySQL REPLACE INTO. Inserting records
    into a specific table can be achieved simply by using the INSERT statement while
     ...

[SQL Server] Handling SQL Server Errors

  1. TRY...CATCH (Transact-SQL) - TechNet - Microsoft

    technet.microsoft.com/en-us/library/ms175976.aspx - Cached
    Implements error handling for Transact-SQL that is similar to the exception ...
    Errors that have a severity of 20 or higher that stop the SQL Server Database ...

  2. Error Handling in SQL Server ? a Background

    www.sommarskog.se/error-handling-I.html - Cached
    29 Nov 2009 ... However, when it comes to error handling... To be blunt: error handling in SQL
    Server is poor. It is a patchwork of not-always-so-consistent ...

  3. What is the best practice use of SQL Server T-SQL error handling ...

    stackoverflow.com/.../what-is-the-best-practice-use-of-sql-server-t-sql-error- handling - Cached - Similar
    We have a large application mainly written in SQL Server 7.0, where ... You
    should read this: http://www.sommarskog.se/error-handling-I.html.

  4. CODE Magazine - Article: Handling SQL Server Errors in Nested ...

    www.code-magazine.com/Article.aspx?quickid=0305111 - Cached - Similar
    Basic error handling in SQL Server's programming language, Transact-SQL, is
    straightforward.But when you nest calls to stored procedures, and the procedures
     ...

  5. Using TRY?CATCH to Handle SQL Server Errors - About Databases

    databases.about.com/od/sqlserver/a/try_catch.htm - Cached - Similar
    The TRY?CATCH statement in Transact-SQL allows you to detect and handle
    error conditions gracefully within your database applications. This statement is ...

  6. SQL SERVER ? 2005 ? Explanation of TRY?CATCH and ERROR ...

    blog.sqlauthority.com/.../sql-server-2005-explanation-of-trycatch-and-error- handling/ - Cached - Similar
    11 Apr 2007 ... CATCH and ERROR Handling. SQL Server 2005 offers a more robust set of tools
    for handling errors than in previous versions of SQL Server.

  7. SQL Server 2008 error handling best practice - Anthony Bloesch's ...

    blogs.msdn.com/b/.../sql-server-error-handling-best-practice.aspx - Cached - Similar
    10 Mar 2009 ... Error handling in SQL Server 2008 needs careful implementation. The Microsoft ?
    Oslo? Repository's API has the further problem that we cannot ...

  8. Handling SQL Server Errors - SQLTeam.com

    www.sqlteam.com/article/handling-sql-server-errors - Similar
    5 Apr 2010 ... This article covers the basics of TRY CATCH error handling in T-SQL introduced
    in SQL Server 2005. It includes the usage of common ...

  9. Handling Errors in SQL Server 2012 - Simple Talk

    https://www.simple-talk.com/sql/.../handling-errors-in-sql-server-2012/ - Cached
    3 Jan 2013 ... The error handling of SQL Server has always been somewhat mysterious. Now at
    last, the THROW statement has been included in SQL Server ...

  10. Overview of Error Handling in SQL Server 2005 - CodeProject

    www.codeproject.com/.../Overview-of-Error-Handling-in-SQL-Server-2005 - Cached
    1 Aug 2009 ... Overview of Error and Exception Handling in SQL Server 2005 using @@Error
    and Try-Catch; Author: Abhijit Jana; Updated: 1 Aug 2009; ...

  11. SQL Server Error Handling Tips

    www.mssqltips.com/sql-server-tip-category/79/error-handling/ - Cached
    Error Handling Tips. Raiserror. Using the NOWAIT option with the SQL Server
    RAISERROR statement. Throw. SQL Server 2012 Throw Statement Introduction.

  12. Tip (SQL Server): Error Handling in a Stored Procedure

    www.novicksoftware.com/.../tips-erorr-handling-in-a-stored-procedure.htm - Cached
    Tip (SQL Server): how to handle errors in a stored procedure.
  13. Exception Handling in SQL Server - CodeProject

    www.codeproject.com/Articles/.../Exception-Handling-in-SQL-Server - Cached
    17 Jul 2009 ... How to handle the errors effectively in SQL Server?; Author: Erode Senthilkumar;
    Updated: 17 Jul 2009; Section: Database; Chapter: Database; ...

  14. SQL Server Transactions and Error Handling - CodeProject

    www.codeproject.com/.../SQL-Server-Transactions-and-Error-Handling - Cached
    1 Jul 2003 ... SQL Server Transactions and Error Handling; Author: Saumendra Poddar;
    Updated: 2 Jul 2003; Section: Database; Chapter: Database; ...

  15. SQL Server Error Handling (Page 1 of 2) :: BlackWasp Software ...

    www.blackwasp.co.uk/SQLErrorHandling.aspx - Cached
    3 Oct 2010 ... Microsoft SQL Server 2005 introduced new error handling capabilities for scripts
    and stored procedures. This article describes the use of the try ...

  16. Get a handle on errors in SQL Server stored procedures ...

    www.techrepublic.com/.../get-a-handle-on-errors-in-sql-server-stored- procedures/ - Cached
    19 Jul 2002 ... Error handling in SQL Server stored procedures is not difficult, but it may be
    different from what you're used to. Pick up the basics and a general ...

  17. Error handling in sql server Part 56 - YouTube

    www.youtube.com/watch?v=VLDirfx_OQg6 Oct 2012 - 18 min - Uploaded by kudvenkat
    In this video we will lean about handling errors in sql server 2005, 2008 and 20012. Error ...
  18. Error Handling

    users.atw.hu/progsql/prog_guide2sql0054.html - Cached
    SQL Server, Oracle, and DB2 all provide mechanisms for handling errors that
    occur in stored procedure code. Unfortunately, as you've probably guessed,
    these ...

  19. Exception Handling in T-SQL Using @@ERROR: Why Bother?

    dataeducation.com/.../exception-handling-in-t-sql-using-error-why-bother - Cached
    22 Apr 2012 ... ERROR - Handle SQL Server exceptions at the lowest possible scope, in order to
    keep them from interacting with higher levels of the ...

  20. Error and Exception Handling Errors - SQL Server Error Messages

    www.lcard.ru/~nail/sybase/error/26595.htm - Cached - Similar
    Sybase? SQL Server Error Messages · Chapter 2: Writeups. Error and Exception
    Handling Errors. This section contains error messages for SQL Server error ...

[SQL Server] Using Dynamic SQL in Stored Procedures

  1. Building Dynamic SQL In a Stored Procedure - CodeProject

    www.codeproject.com/.../Building-Dynamic-SQL-In-a-Stored-Procedure - Cached
    9 Oct 2007 ... A dynamic SQL in a stored procedure is a single Transact-SQL statement or a set
    of statements stored in a variable and executed using a SQL ...

  2. Using Dynamic SQL in Stored Procedures - SQLTeam.com

    www.sqlteam.com/article/using-dynamic-sql-in-stored-procedures
    7 Mar 2011 ... Dynamic SQL allows stored procedures to ?write? or dynamically generate their
    SQL statements. The most common use case for dynamic SQL ...

  3. Using Dynamic SQL Statements in Stored Procedures ...

    www.4guysfromrolla.com/webtech/102300-1.shtml - Cached - Similar
    23 Oct 2000 ... We've all likely created ASP pages that contain dynamic SQL statements within
    the ASP pages... SQL statements that are constructed on the fly, ...

  4. Coding Dynamic SQL Statements - Oracle Documentation

    docs.oracle.com/cd/B10500_01/appdev.920/.../adg09dyn.htm - Cached
    For example, dynamic SQL lets you create a procedure that operates on a table
    ... "A Dynamic SQL Scenario Using Native Dynamic SQL"; "Choosing Between ...

  5. sql server - How do you convert a stored procedure using dynamic ...

    stackoverflow.com/.../how-do-you-convert-a-stored-procedure-using- dynamic-sql-into-a-non-dynamic-sql-o - Cached
    I've been working on SSRS reports, and for one of my stored ... DECLARE @
    IsSupplierUser BIT = 0, @SQL NVARCHAR(MAX) ='init' -- Initial ...

  6. Using OUTPUT Parameters within Dynamic SQL within Stored ...

    stackoverflow.com/.../using-output-parameters-within-dynamic-sql-within- stored-procedures-possible - Cached
    I have a SP that I have created to check for validations and return an ... Sorry for
    the delay :D, the following code works perfectly (For N.. output ...

  7. Get result from dynamic SQL in stored procedure - Stack Overflow

    stackoverflow.com/.../get-result-from-dynamic-sql-in-stored-procedure - Cached
    I'm writing a stored procedure where I need to dynamically construct a SQL
    statement within the procedure to reference a passed in table name ...

  8. Dynamic SQL and stored procedure optimization - Stack Overflow

    stackoverflow.com/.../dynamic-sql-and-stored-procedure-optimization - Cached
    I've read that using Dynamic SQL in a stored procedure can hurt performance of
    your stored procedures. I guess the theory is that the store ...

  9. Dynamic SQL Stored procedure - MSDN - Microsoft

    social.msdn.microsoft.com/.../sqlserver/.../action?...dynamic-sql-stored- procedure - Cached
    13 Oct 2012 ... I am trying to write a dynamic SQL stored procedure. I am not successful in doing
    so. I am new to this so please kindly help. Below is my Stored ...

  10. The curse and blessings of dynamic SQL

    www.sommarskog.se/dynamic_sql.html - Cached - Similar
    In the introduction, I presented various strategies for data-access for an
    application, and I said that ...

  11. Using dynamic sql inside Oracle stored procedure - Database ...

    dba.stackexchange.com/.../using-dynamic-sql-inside-oracle-stored-procedure - Cached
    Assuming I have the following procedure. CREATE PROCEDURE foo ... The only
    reason why I might do that is if I needed to address an object ...

  12. Database - Advanced Stored Procedures Cursors and Dynamic SQL ...

    www.youtube.com/watch?v=B9zKi8H_IUs5 Feb 2013 - 13 min - Uploaded by Ron Eaglin
    A demonstration of using cursors and dynamic SQL to solve more complex reporting and ...
  13. Dynamic SQL versus stored procedures - Sybase

    infocenter.sybase.com/help/topic/com.sybase.../X80489.htm - Cached - Similar
    Step 5: Deallocate the prepared statement Chapter 9: Using Directory Services.
    Chapter ... There are similarities between dynamic SQL and stored procedures:.

  14. Stored procedure - Wikipedia, the free encyclopedia

    en.wikipedia.org/wiki/Stored_procedure - Cached - Similar
    Also, some DBMSs will check the parameter's type. A stored procedure that in
    turn generates dynamic SQL using ...

  15. Speed Test: Dynamic SQL vs Stored Procedures :: BlackWasp ...

    www.blackwasp.co.uk/SpeedTestSqlSproc.aspx - Cached - Similar
    25 May 2008 ... This web site uses cookies. By using the site you accept the cookie policy. ...
    Speed Test: Dynamic SQL vs Stored Procedures. by Richard Carr ...

  16. Using Dynamic Sql Stored Procedure | Teradata Developer Exchange

    forums.teradata.com/forum/.../using-dynamic-sql-stored-procedure - Cached - Similar
    Hi ,I am trying to write a dynamic sql using Stored procedure wherein I am using
    the underlying table as one of the input parameters.Below is the SP which I am ...

  17. MySQL :: Using dynamic SQL in Informix's stored procedure..

    forums.mysql.com/read.php?64,548,548 - Cached - Similar
    Using dynamic SQL in Informix's stored procedure.. Posted by: Puneet (). Date:
    August 09, 2004 05:26AM. hi, i want to create a procedure in informix in which ...

  18. Using Execute As with Stored Procedures and Dynamic SQL ...

    www.sqlmatters.com/.../ Using%20Execute%20As%20with%20Stored%20Procedures%20Co... - Cached
    In most situations it is sufficient to grant a user 'EXECUTE' rights to a stored
    procedure in order to run it, however if the stored procedure contains dynamic
    SQL ...

  19. SQL injection: Dynamic SQL within stored procedures - The What ...

    https://blogs.msdn.com/.../sql-injection-dynamic-sql-within-stored-procedures .aspx - Cached
    5 Sep 2007 ... SQL injection: Dynamic SQL within stored procedures ... This is in spite of using
    parameterized input in data access code to call the stored ...

  20. Java stored procedure with dynamic SQL using JDBC database ...

    publib.boulder.ibm.com/infocenter/.../v8/.../r_samplespjava1.htm - Cached
    JDBC Stored Procedure jdbcsamp */ import java.sql.*; // JDBC classes public
    class Jdbcsamp { public static void jdbcsamp ( String dpt, ResultSet[] rs ) throws ...

[SQL Server 2008 issues] Import\export wizard

[SQL Server 2008 issues] Import\export wizard


Import\export wizard

Posted: 14 Aug 2013 12:09 AM PDT

I am currently using the wizard to import some data from excel to SQL.typical values im importing..16773 1 8362 19277742516114 8 8028 19277377616885 7 8064 19281108916116 5 4561 192977000it all works fine until the third fourth colum has a letter involved such as 16112 2 5551 16401127XIf i was doing this through script.. i would obviously put the fourth value in single quotes '16401127X' which works fine. And in this case if i insert it manually.. it works fine.But as there are thousands of rows this isnt practical. What do i need to do for the import\export wizard to recognise these values and insert them properly?

Better insert performance on a table only with a clustered index or a table without any index on SqlServer 2008?

Posted: 14 Aug 2013 07:01 PM PDT

[b]Note, I am not talking about a clustered index against a non-cluster index, I mean a clustered index comparing to no index at all for inserting performance.[/b]I saw lots of links as below said that, a clustered index has better performance against no index even for insert operation, due to IAM/PFS/bitmap/..., but with my testing, seems no index is faster than cluster index, what's the problem?http://stackoverflow.com/questions/7264820/removing-a-primary-key-clustered-index-to-increase-insert-performancehttp://support.microsoft.com/kb/297861my test scripts:[quote]---------------------------------------------prepare table with clustered indexCREATE TABLE [dbo].[BigTable_CI]( [id] [int] IDENTITY(1,1) NOT NULL, [BigChar] [char](4100) NOT NULL) GOCREATE CLUSTERED INDEX CIX_BigTable_CI ON BigTable_CI(id)GOALTER TABLE [dbo].[BigTable_CI] ADD CONSTRAINT [DF_BigTable_BigChar_CI] DEFAULT ('a') FOR [BigChar]GOCREATE PROCEDURE [dbo].[AddDataToBigTable_CI](@NumberOfRows bigint) AS SET NOCOUNT ON; DECLARE @Counter int = 0; DECLARE @Start datetime = GETDATE(); DECLARE @End datetime; DECLARE @ElapsedTime int = 0; DECLARE @RowsPerSecond int = 0; WHILE (@Counter < @NumberOfRows) BEGIN INSERT INTO dbo.BigTable_CI DEFAULT VALUES; SELECT @Counter += 1; END; -- Calculate elapsed time and rows/second SET @End = GETDATE(); SET @ElapsedTime = CONVERT(INTEGER, DATEDIFF (second, @Start, @End)); SET @RowsPerSecond = @NumberOfRows/@ElapsedTime; -- Record results in local table INSERT INTO dbo.Results (StartTime, EndTime, ElapsedTime, NumberOfRows, RowsPerSecond) VALUES (@Start, @End, @ElapsedTime, @NumberOfRows, @RowsPerSecond); RETURN;---------------------------------------------prepare table without any index at all.CREATE TABLE [dbo].[BigTable_NI]( [id] [int] IDENTITY(1,1) NOT NULL, [BigChar] [char](4100) NOT NULL) GOALTER TABLE [dbo].[BigTable_NI] ADD CONSTRAINT [DF_BigTable_BigChar_NI] DEFAULT ('a') FOR [BigChar]GOCREATE PROCEDURE [dbo].[AddDataToBigTable_NI](@NumberOfRows bigint) AS SET NOCOUNT ON; DECLARE @Counter int = 0; DECLARE @Start datetime = GETDATE(); DECLARE @End datetime; DECLARE @ElapsedTime int = 0; DECLARE @RowsPerSecond int = 0; WHILE (@Counter < @NumberOfRows) BEGIN INSERT INTO dbo.BigTable_NI DEFAULT VALUES; SELECT @Counter += 1; END; -- Calculate elapsed time and rows/second SET @End = GETDATE(); SET @ElapsedTime = CONVERT(INTEGER, DATEDIFF (second, @Start, @End)); SET @RowsPerSecond = @NumberOfRows/@ElapsedTime; -- Record results in local table INSERT INTO dbo.Results (StartTime, EndTime, ElapsedTime, NumberOfRows, RowsPerSecond) VALUES (@Start, @End, @ElapsedTime, @NumberOfRows, @RowsPerSecond); RETURN; ---------------------------------------------prepare the results table create table dbo.Results ( StartTime datetime, EndTime datetime, ElapsedTime int, NumberOfRows int, RowsPerSecond int )---------------------------------------------run scripts: exec [dbo].[AddDataToBigTable_NI] 1000000 exec [dbo].[AddDataToBigTable_CI] 1000000[/quote]

How to create a time based trigger in sql server 2008?

Posted: 14 Aug 2013 05:11 PM PDT

Hi, I need How to create a time based trigger in sql server.Pls....and thanks :-)

Identify string or integer

Posted: 13 Aug 2013 11:20 PM PDT

Hi Team,am passing a parameter to a stored procedure, i want to know whether the parameter is string or integeri want a print statement in stored procedure to print the parameter is string or intEg : EXEC Stored_procedure1 ('abc')output : stringEXEC Stored_procedure1 ('123')output : integerEXEC Stored_procedure1 ('abc112')output : string

Maintain the sort order of data file while using bcp

Posted: 14 Aug 2013 12:05 AM PDT

Sql server 2008 r2 service pack 2When trying to import a single varchar column file using bcp utility (no format file)to a temporary table (## ) the rows are inserted not int the order of the file.Doing the same thing with a regular table the order is maintaind1. Is there a way to ensure that the file will be bulked insert with its order?2. Is it a known Issue ?:w00t:

select statement blocking update statement

Posted: 14 Aug 2013 01:16 PM PDT

Hi Guys,Understand that by default, SELECT statement on a table will block update statement on the table.By setting READ_COMMITTED_SNAPSHOT, update statement (writer) will not block select statement (reader) as the pre-image of the update will be stored in tempdb for select statement to access.However, by setting READ_COMMITTED_SNAPSHOT, will reader (select) still block writer (update)?Any simple sql statement to test this out?thanks

Urgent help with Date format needed please

Posted: 14 Aug 2013 06:59 AM PDT

Dear friends,I have date field in the date time stamp format as shown-Create Date2012-06-21 07:01:03.000I need to display it in the report as -Format as DD-MMM-YYYY, e.g., 21-Sep-2013Need help on this please.Kind RegardsDhananjay

need help transforming row values to a table

Posted: 14 Aug 2013 08:31 AM PDT

my table select name,value from xxtable gives the resultnodename valueDTP02_DateTimePeriodFormatQualifier D8DTP03_AdjudicationorPaymentDate 20130408SVD_LineAdjudicationInformation NULLC003_CompositeMedicalProcedureIdentifier_3 NULLC00301_ProductorServiceIDQualifier HChow do i transform the result set or table columns eg. using tsqlDTP02_DateTimePeriodFormatQualifier | DTP03_AdjudicationorPaymentDate ....... etc... ----------------------------------------------------------------------- D8 20130408

sql server automatically opening a file handle for every database file

Posted: 14 Aug 2013 08:49 AM PDT

Why does sql server automatically open a file handle for every database file when the service first starts up (even before anybody logs in to the sql server)? I want to ask if there's a way to stop it doing that, but if there's a good reason it does so then I probably won't try to stop it.

Script to reset password for SQL 2000

Posted: 14 Aug 2013 09:09 AM PDT

Hi,Does anyone have t-sql script to change password for SQL 2000? I tried the below script but I am getting an error, not exactly sure where I am off. Please advise.ALTER LOGIN 'LoginName' WITH PASSWORD=N'Password' MUST_CHANGEgetting error as below.Server: Msg 170, Level 15, State 1, Line 1Line 1: Incorrect syntax near 'LOGIN'.

increment id based on column value

Posted: 14 Aug 2013 05:36 AM PDT

Hi !I hope that you can show me how to do it avoiding using loop. I need to group records imported from flat file by ID. Column LegacyID is identity column. I need new ID incremented on next value='H'. Thank you.Mark Gorelikcreate table LoadTest (legacyid int not null ,field1 varchar(5) not null, newid int null)insert into LoadTest (legacyid ,field1)SELECT 2, 'H'UNION ALLSELECT 3, 'C'UNION ALLSELECT 4, 'S'UNION ALLSELECT 5, 'O'UNION ALLSELECT 6, 'I'UNION ALLSELECT 7, 'I'UNION ALLSELECT 8, 'I'UNION ALLSELECT 9, 'H'UNION ALLSELECT 10, 'C'UNION ALLSELECT 11, 'S'UNION ALLSELECT 12, 'O'UNION ALLSELECT 13, 'I'UNION ALLSELECT 14, 'I'UNION ALLSELECT 15, 'I'UNION ALLSELECT 16, 'I'UNION ALLSELECT 17, 'I'UNION ALLSELECT 18, 'I'UNION ALLSELECT 19, 'N'UNION ALLSELECT 20, 'H'UNION ALLSELECT 21, 'C'UNION ALLSELECT 22, 'S'UNION ALLSELECT 23, 'O'UNION ALLSELECT 24, 'I'UNION ALLSELECT 25, 'I'SELECT * FROM LoadTest legacyid field1 newid======================================2 H 13 C 14 S 15 O 16 I 17 I 18 I 19 H 210 C 211 S 212 O 213 I 214 I 215 I 216 I 217 I 218 I 219 N 220 H 321 C 322 S 323 O 324 I 325 I 3

Allow developers to install sql express on desktops?

Posted: 14 Aug 2013 01:48 AM PDT

Hi! i'd like to know your thoughts about this:is it ok to allow developers to install sql express on their work pcs?is there any security issue or danger because of having sql instances all over the network that are not administered by the dba team?thanks!

Send email notifcation if condition is failed

Posted: 14 Aug 2013 04:44 AM PDT

Hi Experts,How can i setup send a mail when a condition is not satisfied. Select count(* ) from tablewhere conditions x,y,zif count(*) is < 1 send mail.Thanks in advance

Triggers on Tables

Posted: 14 Aug 2013 12:27 AM PDT

Is there a way to turn a table trigger off in a stored procedure, then turn it back on after it skips that table.We have the trigger in place for a 3rd part to insert(trigger point) into that table and automatically the trigger is fired off to inserts into the the database.

SQL Cluster Migration

Posted: 05 Aug 2013 01:59 AM PDT

Hi there,I have the task of migrating two 2-node SQL 2008 R2 clusters on to new hardware. Currently the plan is to create new clusters from scratch, script all the logins, jobs, linked servers etc. and then just restore all the databases onto it. Finally I will alter the DNS name of the cluster to be the same as the existing one so I don't have to modify all the applications.This will probably be fairly time consuming as there are a large number of databases on the servers.Is this the best way to do it or could someone suggest a easier method?! ....or do I just need to stop whinging and get on with it? ;-)Thanks,Matt

Security Problems after SSRS Domain Migration

Posted: 14 Mar 2013 09:41 PM PDT

Morning all,I recently carried out an SSRS Migration from one domain to another.I used the backup and restore method, and all reports are generating fine and all access for existing users appears to be fine.However, there is one (fairly significant) problem;Some users appear to have been duplicated (seems that a problem with new SIDs being generated / mapped for each domain user affected, and this has resulted in me being unable to edit the security on the site levels/folders where this is a problem.I can neither add, amend or delete users and was advised to delete the first instance of a user to correct this, but it seems this has to be ruled out, due to the fact that even the top level folder contains duplicate users, and an error occurs when I attempt to delete thr user via the site security.The original error was:"Response is not well-Formed XML"The error when I try to delete a user now in one of the affected folders is;"role assignment is not valid. The role assignment is either empty or it specifies a user or group name that is already used in an existing role assignment for the current item. (rsInvalidPolicyDefinition)"I tried amending the ownership and modifiedby entries in the database for one of the specific users to myself, and then deleted the user and policies assigned to him, but it unfortunately never resolved the problem (The user still remains in place with security entries on the site, even if deleted within the database).Has anyone else ever encountered this problem and is there a way of resolving this which doesn't mean having to resort to backing up the original db with the affected users stripped out, in order for a restore to be carried out.A lot of further configuration work and report imports has occurred since this was put in place.Thanks in advance for any responses.

REBUILD 1625 indexes weekly !!??

Posted: 14 Aug 2013 05:03 AM PDT

I just joined this companyand look at some SQL jobs they run on production server.One of them looks really odd.It's a weekly job that rebuilds 1625 indexes.There are about 920 tables so it looks like they rebuild a lot of their indexes.I am just curious if it slows the performance on the serverand why why would they do it so frequently.It's a SQL Server 2008 R2 SP2 databse behind online Financial Application (BST Enterprise).

Log LDF file

Posted: 13 Aug 2013 07:25 PM PDT

I came to know that some records are deleted from Table in SQL SERVER 2008...We want to track it & see what happened & who deleted :w00t:No log backup is taken.. only LDF file is there which is almost 5GB now..please suggest how will i be able to read the LDF file to track the operation done yesterday when records were deleted :w00t:Please help its urgent.. Client need answer :crazy:

VMWare administrator moved my server without telling me

Posted: 09 Jan 2013 01:01 AM PST

Good Morning,How would you be able to determine that the server that houses your SQL Server has been moved (vmotion) by the VMWare administrator?Yesterday the VMWare administrator vmotioned the server that housed my SQL Server. The hardware that he moved the server to was having problems.Users were complaining that they were having connection issues, but I connected fine to the database database. Using SSMS & profiler, I saw that the database working. I could not find anything in the logs, including the Windows operating system logs. The only thing I found was in the SSMS Activity Monitor under the Resource Waits section, the Network I/O - Wait Category had the highest Wait Time.To resolve the issue, the VMWare administrator had to move my server back to the original hardware.We had database administrators, network administrators, and Windows system administrators all looking for the cause of the issue without finding anything for an hour before the VMWare administrator confessed that he moved the server to different hardware that afternoon.Has anyone run into this issue, and is there a way to tell that you have been moved. How would you determine that your server had been moved.Anyone's input on this issue is appreciated & thank you in advance.Mike

Data Flow from Firebird server fails in SSIS with [IM014] Error

Posted: 14 Aug 2013 02:15 AM PDT

HelloI'm wondering if someone out there can help restore my sanity. Here's the scenario:A third-party Firebird server holds data I retrieve on an instant/hourly/daily basis. In a 32bit world all is fine - everything works just dandy. However, like many, our kit is being 'upgraded' to 64 bit (one-way ticket, no option or argument).The Visual Studio install on my new 64bit PC turns out be 32 bit version. No bother, we've installed both the 64 and 32 bit ODBC driver for Firebird and the Connection Test succeeds in both cases.My MS Office install also turns out to be 32 bit, so firing up the 32bit ODBC driver I get a perfect linked-table connection to Firebird and the data is there to play with - all good so far.Scheduled updates of Firebird data to our data warehouse (SQL 2008 R2) are achieved via SSIS packages. The ones designed and run on a 32 bit PC using VS2008 32 bit application all work.Back to my 64 bit PC...Setting up the Data Source / Connection Manager; As the VS2008 install is 32 bit, we assumed the 32 bit ODBC driver would be invoked and it is. The connection string is correct. The Test Connection button provides a friendly 'succeeded' message.Pulling in a ADO NET data source task: My configured ODBC CM is available so it's plugged in. Building the query I can list all the tables on the distant Firebird server. Choosing a table, I can list all the fields in the table. Accepting the query, and clicking the "Preview..." button I get a friendly dialog box listing all the records in the table I just queried - all seems well.And then I run the package; the ADO NET Source task instantly turns red, the package fails and I am gifted the following Debug messages:SSIS package "CheckConn.dtsx" starting.Information: 0x4004300A at Data Flow Task, SSIS.Pipeline: Validation phase is beginning.Error: 0xC0047062 at Data Flow Task, ADO NET Source [31]: System.Data.Odbc.OdbcException: ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode) at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) at System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions) at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.Odbc.OdbcConnection.Open() at Microsoft.SqlServer.Dts.Runtime.ManagedHelper.GetManagedConnection(String assemblyQualifiedName, String connStr, Object transaction) at Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSConnectionManager100.AcquireConnection(Object pTransaction) at Microsoft.SqlServer.Dts.Pipeline.DataReaderSourceAdapter.AcquireConnections(Object transaction) at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostAcquireConnections(IDTSManagedComponentWrapper100 wrapper, Object transaction)Error: 0xC0047017 at Data Flow Task, SSIS.Pipeline: component "ADO NET Source" (31) failed validation and returned error code 0x80131937.Error: 0xC004700C at Data Flow Task, SSIS.Pipeline: One or more component failed validation.Error: 0xC0024107 at Data Flow Task: There were errors during task validation.SSIS package "CheckConn.dtsx" finished: Failure.I note the "IM014: The specified DSN contains an architecture mismatch between the Driver and Application" message. Yet I'm using a 32 bit App with a 32 bit Driver.Can anyone explain why this is happening please? And what can I do to fix this and get it to work please? Apologies that this is a lengthy post, but your insight and wisdom would be very warmly welcomed.RegardsGraham

Sql Server 2008 R2 Partitioning

Posted: 13 Aug 2013 10:33 PM PDT

Hi,I have a Sql Server 2008 R2 instance and in one of my databases I have a table which has >100 million records and we have decided to partition this table as the volumes of data is set to increase dramatically over the next 6 months.Due to certain business rules the "Date" column in the table alone could not be used as the partition key, it had to also include a value which relates to a "BusinessLine".Therefore I created a new [INT] column on the table which will be the [PartitionKey] column and now holds a combination of the data in the [Date] and [BusinessLine] columns. For example, for the "Date" 01/01/2013 and for the "BusinessLine" 1 the value in the [PartitionKey] cell for that row is 201301011.The table already has a Primary Key covering certain columns required for the front end application to search on. The system is highly transactional and I am a little reluctant to just remove the existing Primary Key.So basically my question is...Is it good practise to add the [PartitionKey] column to the existing Primary Key?Thanks in advance.

Do we have any chance to remove a physical file that has data

Posted: 14 Aug 2013 01:34 AM PDT

Hi All,Do we have any chance to remove a physical file that has data... Can any one please suggest !!!

Email notification in job manager

Posted: 13 Aug 2013 11:57 PM PDT

I want to send an email notification in job manager as following instructions but there is no email list to select.http://msdn.microsoft.com/en-us/library/ms191130.aspxHow to add my email address to drop down list?

Can we assign port 1433 to a named instance

Posted: 13 Aug 2013 07:09 PM PDT

Can we assign port 1433 to a named instance ? I know that these 1433 as port number to default instance. Please clarify, Can we allocate port 1433 to named instance..

Linked Servers with service account - Error 18456 state 6

Posted: 13 Aug 2013 09:35 PM PDT

Hi guys,I have a central server and n other servers that are collected on using linked server connections.My original setup (for testing) was:Local login: my usernameRemote user: a SQL Server login (if mixed mode)For a login not defined in the list above: the same SQL Server loginNow I've been given a service account (no password expiry) and was planning to use only this. The steps I've done are:1. Add the user to the central server in an Administrator group.2. Granted this login sysadmin on the central server3. Added the user to a "remote users" group on a remote server4. Granted the login remote the same privileges I granted the SQL Server login (master/msdb read/exec)I tested and I can log on to the central server with the service account, open mstsc & remote to the other server with that login & connect to the remote instance & run the queries I want; it's just not doing it with the Linked Server.My new linked setup attempt is:Local login: service account (in the admin group)Remote user: I have tried both Impersonate & entering the DOMAIN\USER & password for the service account as the Remote User & passwordFor a login not defined in the list above: the same service account (domain\user & pass)Anyone know why it's failing when my the user on the central server has sysadmin & I can remote to the other & run queries fine with mstsc? Thanks for any infoI found this but I'm not sure if it's relevent to me: [url=http://www.sqlservercentral.com/Forums/Topic1222568-146-1.aspx]http://www.sqlservercentral.com/Forums/Topic1222568-146-1.aspx[/url] -- ideally looking to limit the dependency on other teams

Remove unnecessary indexes from Replication

Posted: 13 Aug 2013 07:12 PM PDT

Hi,i'd like to remove some unecessary indexes from my replication:SQL-Versions:Publisher: SQL 2008 StandardDistributor: SQL 2012 StandardSubscriber: SQL 2008OS-Versions:Windows 2008 Standard-Server.I read about some problems, if I just drop an index wich is replicated to an subscriber database. Is there a possibility to delete/drop an index which is no longer used. The index are very big, and it needs a lot of time, if I reorg or rebuild the index.kind regards,Andreas

SQL Server 2012 - Column Store Index

Posted: 09 Mar 2012 09:37 PM PST

Has anyone tried this?Is it really as fast as they say ?Thanks

Wednesday, August 14, 2013

[SQL Server] What do you open a logfile with?

[SQL Server] What do you open a logfile with?


What do you open a logfile with?

Posted: 14 Aug 2013 07:30 AM PDT

I have some errorlogs in C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSWL\LOG, I have tried opening them with notepad, wordpad, microsoft word, and various other things. What can I view these errorlogs with? Help!

Is there a way?

Posted: 14 Aug 2013 07:10 AM PDT

If manually did a sql backup (example, right clicking on the database name, Tasks, Backup) is there any way to capture this so I can either create a sql script or have it capture it for me? I don't know how to look under the covers of the gui to see what this process is doing.... I just want to be able to replicate this exact process, but with a script that I can automate or run automatically.Any suggestions for a newbie?Thanks!

trigger and stored procedure (SQL2008 R2)

Posted: 14 Aug 2013 01:07 AM PDT

Hy there,i have following problem:i have a table A, table B and table C with a trigger (after insert, update).All tables have the same primary key inserted.Of course, when datas are changing in table "auftragkopf " , triggers fires (triggers will select data from inserted and write these datas to another table)Second i have a stored procedure A where every 15 minutes an insert in table A happened and also alldatas from one dataset are selected an written in another table.Now i habe the problem, that when the sgtored procedure is running, they key changes and the job failed.For example:Table A gets a value "1"Table B gets a value "1"Table C gets a value "1"Trigger starts on Table A (and write this new value to another table). At the same time the stored procedure is runningand insert datas and select all datas from table A, tabble B and table C.When a select the table, where datas are inserted from the stored procedure, following datas are inserted:Table A gets a value "1"Table B gets a value "1"Table C gets a value "2"Thats wrong, because all values MUST BE "1".Here is the stored procedure (runs every 15 minute)USE [BD]GO/****** Object: StoredProcedure [dbo].[Collect] Script Date: 08/14/2013 16:00:58 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO-- =============================================-- Author: <Author,,Name>-- Create date: <Create Date,,>-- Description: <Description,,>-- =============================================ALTER PROCEDURE [dbo].[Collect ASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON;if (select count(*) from [vb-srv-db1].rls.dbo.vw_getnewrecords) >0 begin SET XACT_ABORT ON BEGIN TRANSACTION declare @maxint int delete from tbl_NewRecords insert into tbl_NewRecords select int_nummer from [vb-srv-db1].rls.dbo.vw_getnewrecords delete from [vb-srv-db1].rls.dbo.tbl_NewRecords insert into [vb-srv-db1].rls.dbo.tbl_NewRecords select * from tbl_NewRecords select @maxint = max(int_nummer) from auftragkopf If (IDENT_CURRENT('auftragkopf')>@maxint) DBCC CHECKIDENT ('auftragkopf', RESEED,@maxint) insert into auftragkopf (UId, Buchungsdatum, Flags, Flags2, Jahr, Laufnummer, LandesverbandNr, BezirksstelleNr, OrtsstelleNr, Kennung, Orgjahr, Orglaufnr, Auftragsnr, Protokollnr, Patientnr, Fahrzeugnr, Sammelauftnr, Uebernahmenr, Uebernahmedat, EinsatzNr, EinsatzNrZusatz, Klinik, Ecpnummer, Knotenname, Chronologie, Mehrfachtra, Rechnungsdatum, Rechnungsnr, Selbstbehdatum, Selbstbehrechnr, Sammelrechdatum, Sammelrechnr, DatentraegerNr, AbrechnungsNr, FibuueberNr, BearbeitModell, AbrechDatum, AbrechModell, UeberleitModell, OPModell, Fehlerliste, Meldung, Zugriff_art, Zugriff_von, Zugriff_terminal, Rls_updaten) select UId, getdate(), Flags, Flags2, Jahr, Laufnummer, LandesverbandNr, BezirksstelleNr, OrtsstelleNr, Kennung, Orgjahr, Orglaufnr, Auftragsnr, Protokollnr, Patientnr, Fahrzeugnr, Sammelauftnr, Uebernahmenr, Uebernahmedat, EinsatzNr, EinsatzNrZusatz, Klinik, Ecpnummer, Knotenname, Chronologie, Mehrfachtra, Rechnungsdatum, Rechnungsnr, Selbstbehdatum, Selbstbehrechnr, Sammelrechdatum, Sammelrechnr, DatentraegerNr, AbrechnungsNr, FibuueberNr, BearbeitModell, AbrechDatum, AbrechModell, UeberleitModell, OPModell, Fehlerliste, Meldung, Zugriff_art, Zugriff_von, Zugriff_terminal, Rls_updaten from [vb-srv-db1].rls.dbo.auftragkopf where int_nummer in (select int_nummer from rls.dbo.tbl_NewRecords) IF @@ERROR <> 0 GOTO ON_ERROR insert into auftrag (Buchungsdatum, Int_nummer, Melder, Rueckruf1, Interface1, Name, Patientinfo, Rueckruf2, Interface2, Auftraggeber, AuftraggebFg, AuftraggebNr, Rueckruf3, Interface3, Lokalisat, Abholort, Abh_pq, Abh_land, Abh_plz, Abh_ort, Abh_ortkz, Abh_haus, Abh_klasse, Abh_vpnr, Abh_objekt, Abholweg, Abholinfo, Zielort, Zie_pq, Zie_land, Zie_plz, Zie_ort, Zie_ortkz, Zie_haus, Zie_klasse, Zie_vpnr, Zie_objekt, Zielweg, Zielinfo, VerrDiagnose, VerrDiagnoseNr, VerrDiagnoseText, Diagnose, Diagnosenr, Einstufung, Einstkurz, Einsatzart, Einsatzbez, Transpoart, Transpobez, Bemerkung1, Bemerkung2, Bemerkung3, Freitext, Verrdiagcode, Diagnosecode, Einstcode, Einsatzcode, Transpocode, Verscode, VEAart, VEAbez, Kennzeich, Type, Typekurz, Fahrz_art, Statusnummer, Besatz1, Besatz1_nr, Besatz2, Besatz2_nr, Besatz3, Besatz3_nr, Besatz4, Besatz4_nr, Schicht, Schicht_von, Schicht_bis, Dienstart, Aufnahmezeit, Sollzeit, Meldezeit, Alarmzeit, Beginnzeit, Beginnlok, Abholzeit, Abhollok, Abfahrtszeit, Zielzeit, Ziellok, Endezeit, Standortzeit, Einsatz_ab, Einsatz_zi, Zugriff_art, Zugriff_von, Zugriff_terminal, DispoNr, Transportbez, NACACode) select getdate(), 0, Melder, Rueckruf1, Interface1, Name, Patientinfo, Rueckruf2, Interface2, Auftraggeber, AuftraggebFg, AuftraggebNr, Rueckruf3, Interface3, Lokalisat, Abholort, Abh_pq, Abh_land, Abh_plz, Abh_ort, Abh_ortkz, Abh_haus, Abh_klasse, Abh_vpnr, Abh_objekt, Abholweg, Abholinfo, Zielort, Zie_pq, Zie_land, Zie_plz, Zie_ort, Zie_ortkz, Zie_haus, Zie_klasse, Zie_vpnr, Zie_objekt, Zielweg, Zielinfo, VerrDiagnose, VerrDiagnoseNr, VerrDiagnoseText, Diagnose, Diagnosenr, Einstufung, Einstkurz, Einsatzart, Einsatzbez, Transpoart, Transpobez, Bemerkung1, Bemerkung2, Bemerkung3, Freitext, Verrdiagcode, Diagnosecode, Einstcode, Einsatzcode, Transpocode, Verscode, VEAart, VEAbez, Kennzeich, Type, Typekurz, Fahrz_art, Statusnummer, Besatz1, Besatz1_nr, Besatz2, Besatz2_nr, Besatz3, Besatz3_nr, Besatz4, Besatz4_nr, Schicht, Schicht_von, Schicht_bis, Dienstart, Aufnahmezeit, Sollzeit, Meldezeit, Alarmzeit, Beginnzeit, Beginnlok, Abholzeit, Abhollok, Abfahrtszeit, Zielzeit, Ziellok, Endezeit, Standortzeit, Einsatz_ab, Einsatz_zi, Zugriff_art, Zugriff_von, Zugriff_terminal, DispoNr, Transportbez, NACACode from [vb-srv-db1].rls.dbo.auftrag where int_nummer in (select int_nummer from rls.dbo.tbl_NewRecords) IF @@ERROR <> 0 GOTO ON_ERROR insert into auftragnacherf (Buchungsdatum, Int_nummer, Km_start, Km_ende, Km_gefahren, Km_1auftnr, Km_2auftnr, Km_3auftnr, Km_4auftnr, Km_1inland, Km_2inland, Km_3inland, Km_4inland, Km_1ausland, Km_2ausland, Km_3ausland, Km_4ausland, Nachname, Vorname, Geschlecht, Gebdatum, Land, Plz, Ort, Strasse, Ver_nummer, Ver_name, Ver_vornam, Ver_geschl, Ver_gebdat, Ver_land, Ver_strass, Ver_plz, Ver_ort, Versverhaeltnis, Dienstgeb, Dienstplz, Dienstort, Versicher, Versich2, Versich3, VersId, VersId2, VersId3, Versnummer, Selbstbeh, Betragerh, Verrdiag, Verrdiagnr, Verbemerk1, Verbemerk2, Verbemerk3, RE_Nachname, RE_Vorname, RE_Plz, RE_Ort, RE_Strasse, RE_Land, Naca, TABei, TAAuchFuer, PatiAnzahl, InkBetrag, InkNummer, InkText, InkArt, OPBezahlt, Kostenstelle, HerstName, HerstKfz, HerstPlz, HerstOrt, HerstStrasse, VertragspNr, VertragspDVR, VertragspBLZ, VertragspKtoNr, Sammeltransport, Ortspauschale, Selbstbehalt, Uebergabe, Gebuehrenbefreit, Rkmitglied, Gegentransport, IntErhebung, Fernfahrt, Nacherfasst, Chefarztpflicht, Mwst, NichtVerrechenbar, Ruecktransport, Mehrfachtransport, Kostenuebernahme, Revers, AufschlRabatt, AufschlagAusw, RabattAusw, Bearbeitungsgebuehr, Wartezeit, Porto, Mitgliedrabatt, Zugriff_art, Zugriff_von, Zugriff_terminal) select getdate(), 0, Km_start, Km_ende, Km_gefahren, Km_1auftnr, Km_2auftnr, Km_3auftnr, Km_4auftnr, Km_1inland, Km_2inland, Km_3inland, Km_4inland, Km_1ausland, Km_2ausland, Km_3ausland, Km_4ausland, Nachname, Vorname, Geschlecht, Gebdatum, Land, Plz, Ort, Strasse, Ver_nummer, Ver_name, Ver_vornam, Ver_geschl, Ver_gebdat, Ver_land, Ver_strass, Ver_plz, Ver_ort, Versverhaeltnis, Dienstgeb, Dienstplz, Dienstort, Versicher, Versich2, Versich3, VersId, VersId2, VersId3, Versnummer, Selbstbeh, Betragerh, Verrdiag, Verrdiagnr, Verbemerk1, Verbemerk2, Verbemerk3, RE_Nachname, RE_Vorname, RE_Plz, RE_Ort, RE_Strasse, RE_Land, Naca, TABei, TAAuchFuer, PatiAnzahl, InkBetrag, InkNummer, InkText, InkArt, OPBezahlt, Kostenstelle, HerstName, HerstKfz, HerstPlz, HerstOrt, HerstStrasse, VertragspNr, VertragspDVR, VertragspBLZ, VertragspKtoNr, Sammeltransport, Ortspauschale, Selbstbehalt, Uebergabe, Gebuehrenbefreit, Rkmitglied, Gegentransport, IntErhebung, Fernfahrt, Nacherfasst, Chefarztpflicht, Mwst, NichtVerrechenbar, Ruecktransport, Mehrfachtransport, Kostenuebernahme, Revers, AufschlRabatt, AufschlagAusw, RabattAusw, Bearbeitungsgebuehr, Wartezeit, Porto, Mitgliedrabatt, Zugriff_art, Zugriff_von, Zugriff_terminal from [vb-srv-db1].rls.dbo.auftragnacherf where int_nummer in (select int_nummer from rls.dbo.tbl_NewRecords) IF @@ERROR <> 0 GOTO ON_ERROR update auftrag set int_nummer=buchungsnummer where int_nummer=0 IF @@ERROR <> 0 GOTO ON_ERROR update auftragnacherf set int_nummer=buchungsnummer where int_nummer=0 IF @@ERROR <> 0 GOTO ON_ERROR exec [vb-srv-db1].rls.dbo.sp_SetFlags IF @@ERROR <> 0 GOTO ON_ERROR insert into tbl_Log select 7,getdate(),count(*) from rls.dbo.tbl_NewRecords IF @@ERROR <> 0 GOTO ON_ERROR print 'commit' COMMIT TRANSACTION IF @@ERROR <> 0 GOTO ON_ERROR GOTO OK ON_ERROR: IF @@TRANCOUNT > 0 begin ROLLBACK TRANSACTION print 'error' end SET XACT_ABORT ON OK: set nocount off SET XACT_ABORT ONendendHERE IS THE TRIGGER (from table A):USE [DB]GO/****** Object: Trigger [dbo].[Changed_Data_AuftragKopf] Script Date: 08/14/2013 16:04:52 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER TRIGGER [dbo].[Changed_Data_AuftragKopf] ON [dbo].[AuftragKopf] AFTER INSERT,UPDATEAS BEGIN DECLARE @Int_Nummer INT SET @Int_Nummer = 0 SET NOCOUNT ON; SELECT @Int_Nummer = Int_Nummer FROM dbo.AuftragKopf WHERE Int_Nummer = (Select Int_Nummer from inserted) IF (SELECT distinct Int_Nummer FROM dbo.AuftragKopf WHERE Int_Nummer in (select Int_Nummer from dbo.Auftrag_DML) and Int_Nummer = (Select Int_Nummer from inserted)) is null and substring((Select Flags from inserted),3,1)=1 BEGIN INSERT INTO dbo.Auftrag_DML (Int_nummer, DML, ErstellDatum) VALUES(@Int_Nummer , 1 , getdate()) END ELSE BEGIN UPDATE dbo.Auftrag_DML SET DML = 1, ErstellDatum = getdate() WHERE Int_Nummer = @Int_Nummer END --Bereinigen von alten Daten älter als 10 Tagen; bei jeder Datensatzänderung wird geprüftdelete FROM [rls].[dbo].[Auftrag_DML] where DATEDIFF(day, getdate(),erstelldatum) < -10 ENDHow can i avoid that trigger and SP mix datas and whats the reason?Thank you,Chris

Search This Blog