Saving 1-to-many Records With Sp And Transaction?

Jun 10, 2005

I'm trying to save several records to an SQL Server 2000 database. The records are in a 1:Many relationship; i.e., there is one record that goes into a parent table, and several that go into a child table. I have to do this with stored procedure(s) that constitute one transaction. Can anyone tell me how this might be done?Thanks!

View 2 Replies


ADVERTISEMENT

Saving Some Data Despite A Rollback Transaction Command

Sep 12, 2007



I am working on reformating, cleaning, adding derived elements, etc... on data with no data validity checks on the front-end, source data. Its an incremental process where each month I add new data to the prior months' history. Sometimes the new monthly source data "surprises" me -- different values, different data definitons, etc. than expected.

I deal with these surprises by accumulating the fields/values that are unexpected after converting them to varchar with some explanatory language into a table [program_newdataprobs]

If there are any records in [program_newdataproblem] I rollback the transactions so the prior months' history remains unaltered. The problem is I then "lose" the contents of [program_newdataproblem] which I would like to hand to the source data people to troubleshoot.

I have tried the following:


Begin Transaction tran1

.... code that reformats data here
if (select count(*) from program_newdataproblem)>0

BEGIN



Begin Transaction tran2

select * into #t1 from program_newdataproblem

Commit Transaction tran2

Rollback Transaction tran1

insert into program_newdataproblem
Select * from #t1


END


This bombs because because #t1 no longer exits

Any way I can "keep" the data from program_newdataproblem when I Rollback the other transactions? (without having to store the history in separate tables that I can then access if new data errors occur)

Thanks,




View 3 Replies View Related

Data Flow Task To Delete Records And Then Insert Records In Transaction

Aug 6, 2007

HI,

I have been trying to solve the locking problem from past couple of days. Please help mee!!

Scenario:
--------------
I have a SSIS package in which 2 data flow tasks. 1st data flow task deletes records from a 5 tables and the 2nd data flow task should insert records into 1 of the five tables after the success of 1st data flow task. This scenario runs in Transacation.

The above scenrio in the 2nd data flow task hangs in runtime. It does not complete. with sp_who2 command i could see that there is an intent share lock(LK_M_IS) on the table and the status is SUSPENDED.

I dont know how to come out of this locking. Please help.

Thanks ,
Sunil

View 7 Replies View Related

Access Halta On Saving Records, Restart Server Req

Oct 4, 2007

Running SQL 2005 on a dedicated Dual Xeon 8MB RAM AND 6x 160GB HDDS RAID-5. Front end App Access 2002. I have to main concerns. 1. When users are enter data and saving all of a sudden all users get stuck upon saving and requires to reboot the server to operate again. Th eproblem is that this happens 3 to 5 times a day. Also searching records with one word takes very long time sometimes even minutes, but queries having two or more words come up fast. Also single word queries come up with erratic results, sometimes 200 titles and than a second search comes up with 31,000. *** Can anyone come up with any ideas "off the cuff" on how I canstart to resolve these issues. Can these issues be related?

View 5 Replies View Related

Automating A Query And The Saving Saving Of Subsequent Results

Dec 13, 2007

Hi Guys,

I am trying to automate a basic task using SQL Server 2005 Express.

Currently I have a query script that I run and then save the results as a CSV file. I need to do this on a daily basis and so I am looking to find out how best to go about this. There are a multitude of third party tools that claim to be able to do this - can anyone recommend this or enlighten me of the best way to set up this automation.

All ideas gratefully received!

View 1 Replies View Related

Handling Out-dated Transaction Records

Sep 1, 2006

For performance issue, I believe many program should have a house-keeping procedure to clean up transaction history. Is there any best practice to perform this? Or should it be done simply by moving transaction data from the transaction table into a history table? Any better or consideration that I should be concerned of?

View 1 Replies View Related

Transaction Processing Detail Records

Apr 30, 2007

Hello,



I am fairly new to SQL Server 2005 and was curious if this was possible.



In my VB applications I always used Begin Transaction, Commit and Rollback to process records. I just found out that I can perform the same functionality in a stored procedure.



So the question is, if I have an order record and four line item records is there anyway to pass all that to the stored procedure as a unit. I can pass the order record as individual parameters but it is the four (or however many) detail records that is the reason for my question. How can I pass the detail records at one time? Can I pass these as an array or a dataset or something else or am I just out of luck? SQL Server 2005 has impressed me a few times already with what you can do and I am really hoping this can be accomplished also.



Cheers,

Richard

View 3 Replies View Related

Update Multiple Records In Single Transaction

Feb 26, 2008



Hi All,

I want to know that how we will be able to update multiple rows in single transaction.

e.g If original database is
S_No Data
1 -
2 -
3 -
4 -

After
S_No Data
1 1
2 3
3 6
4 10

View 4 Replies View Related

Handling SQL RollBack Transaction For More Records In A Single Process

Mar 6, 2008

I have over 500 transaction records in a single DB process handling within SQL transaction (Begin, Commit, RollBack and End).
Is there any limitation for the following rollbacktransaction function to handle more records (eg. over 500 records)? Public Shared Sub RollBackTransaction()
Dim transactionObj As Object
Try
transactionObj = SqlTransaction.GetExistingTransaction
If (Not IsNothing(transactionObj)) Then
CType(transactionObj, SqlTransaction).RollBack()
End If

Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub
 
 

View 2 Replies View Related

Problem In Selecting Records That Another User Is Updating Them And His Transaction Not Completed

Jan 31, 2008



hello

I use SQLServer2000 when i begin a transaction and update set of records in a table
till i don't commit or rollback the transaction nobody can not select
previous values of that records and it must wait until i complete the transaction, i have tested it in oracle but it hasn't this limitation
don't you think it is Sqlserver weakness?

thanks

View 9 Replies View Related

SQL Server 2008 :: Making Use Of A Large Transaction File To Delete Records?

Jun 5, 2015

Currently we has a database of size about 300G. Because our backup system failed some time past we were left with a transaction log file which grew to about 160G. However our backups are working again and everything is working fine. My understanding is that now the transaction log file is practically empty but the capacity remains at 160G.

When you delete records the deleted transactions are going to get logged to the transaction file. My understanding is when a backup is done these transactions get discarded out of the transaction file.

could I make use of this relatively large transaction file and start deleting transactions without out actually adding to the transaction file size.

The plan is to delete records from logging tables that are not referenced to by any other table without this increasing the transaction log file.For example over a period of a few weeks we can delete a chunk of records from a table. Then after it has completed a backup we can delete another chunk of records out of this table until we have got the table down to the records that we now need.Will this work?

View 2 Replies View Related

SQL Server 2014 :: Transaction Rollback When Multiple Threads Are Inserting Records Into Table Because Of Trigger

Jun 18, 2014

I have two tables called ECASE and PROJECT

In the ECASE table there is trigger to get the max value of case_id column in ecase based on project and increment one to that case_id value and insert into ecase table .

When we insert a new record to the ECASE table this trigger calls and insert the case_id column value.

When i run with multiple threads , the transaction is rolled back because of trigger . The reason is , on the project table the lock is happening while getting the max value of case_id column based on project.

I need to prevent the deadlock .

View 3 Replies View Related

Error 8525: Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

May 31, 2008

Hi All

I'm getting this when executing the code below. Going from W2K/SQL2k SP4 to XP/SQL2k SP4 over a dial-up link.

If I take away the begin tran and commit it works, but of course, if one statement fails I want a rollback. I'm executing this from a Delphi app, but I get the same from Qry Analyser.

I've tried both with and without the Set XACT . . ., and also tried with Set Implicit_Transactions off.

set XACT_ABORT ON
Begin distributed Tran
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.TRANSACTIONMAIN
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.TRANSACTIONMAIN
set REPFLAG = 0 where REPFLAG = 1 and DONE = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.WBENTRY
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.WBENTRY
set REPFLAG = 0 where REPFLAG = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.FIXED
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.FIXED
set REPFLAG = 0 where REPFLAG = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.ALTCHARGE
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.ALTCHARGE
set REPFLAG = 0 where REPFLAG = 1
update OPENDATASOURCE('SQLOLEDB','Data Source=10.10.10.171;User ID=*****;Password=****').TRANSFERSTN.TSADMIN.TSAUDIT
set REPFLAG = 0 where REPFLAG = 1
update TSADMIN.TSAUDIT
set REPFLAG = 0 where REPFLAG = 1
COMMIT TRAN


It's got me stumped, so any ideas gratefully received.Thx

View 1 Replies View Related

SSIS, Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

Feb 22, 2007

I have a design a SSIS Package for ETL Process. In my package i have to read the data from the tables and then insert into the another table of same structure.

for reading the data i have write the Dynamic TSQL based on some condition and based on that it is using 25 different function to populate the data into different 25 column. Tsql returning correct data and is working fine in Enterprise manager. But in my SSIS package it show me time out ERROR.

I have increase and decrease the time to catch the error but it is still there i have tried to set 0 for commandout Properties.

if i'm using the 0 for commandtime out then i'm getting the Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.

and

Failed to open a fastload rowset for "[dbo].[P@@#$%$%%%]". Check that the object exists in the database.

Please help me it's very urgent.

View 3 Replies View Related

Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

Feb 6, 2007

I am getting this error  :Distributed transaction completed. Either enlist this session in a new
transaction or the NULL transaction. Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code. Exception Details:
System.Data.OleDb.OleDbException: Distributed transaction completed. Either
enlist this session in a new transaction or the NULL transaction.have anybody idea?!

View 1 Replies View Related

Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction.

Dec 22, 2006

i have a sequence container in my my sequence container i have a script task for drop the existing tables. This seq. container connected to another seq. container. all these are in for each loop container when i run the package it's work fine for 1st looop but it gives me error for second execution.

Message is like this:

Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.

View 8 Replies View Related

Distributed Transaction Completed. Either Enlist This Session In A New Transaction Or The NULL Transaction. (HELP)

Jan 8, 2008

Hi,

i am getting this error "Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.".

my transations have been done using LINKED SERVER. when i manually call the store procedure from Server 1 it works but when i call it through Service broker it dosen't work and gives me this error.



Thanks in advance.


View 2 Replies View Related

DB Engine :: Deleting 1 Million Records From Transaction Table Of 10 Million Data On 24/7 Environment

Jun 12, 2015

I have a requirement to delete 1 Million records from a table having 10 Million data and it's being queried on 24/7 basis (don't have a downtime). how can I achieve that?

View 13 Replies View Related

SQL 2012 :: Query To Make Single Records From Multiple Records Based On Different Fields Of Different Records?

Mar 20, 2014

writing the query for the following, I need to collapse the continuity. If the termdate for an ID is one day less than the effdate of the next id (for the same ID) i need to collapse the records. See below example .....how should i write the query which will give me the desired output. i.e., get min(effdate) and max(termdate) if termdate is one day less than the effdate of next record.

ID effdate termdate
556868 1999-01-01 1999-06-30
556868 1999-07-01 1999-10-31
556869 2002-10-01 2004-01-31
556872 1999-02-01 2000-08-31
556872 2000-11-01 2004-01-31
556872 2004-02-01 2004-02-29

output should be ......

ID effdate termdate
556868 1999-01-01 1999-10-31
556869 2002-10-01 2004-01-31
556872 1999-02-01 2000-08-31
556872 2000-11-01 2004-02-29

View 0 Replies View Related

SQL Server Admin 2014 :: Restore Lost Transaction From Transaction Log File

Jun 10, 2015

I have Full database backup upto previous day and transaction logfile of Today transaction. my database has crashed. I have restored previous day's Full backup. I have faced difficulty to restore today's transaction from today's transaction log. What are the steps to restore full database back and one day's transaction log file. Note: there is no differential database backup and transaction backup.

View 8 Replies View Related

I Need Away To Show The Pending Transaction From Transaction Replication In A User Friendly Format.

Jul 11, 2007



I want to list out the pending transaction for transaction replication by publication.



Help needed.

View 1 Replies View Related

TRANSACTIONS In SSIS (error: The ROLLBACK TRANSACTION Request Has No Corresponding BEGIN TRANSACTION.

Nov 14, 2006

I'm receiving the below error when trying to implement Execute SQL Task.

"The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION." This error also happens on COMMIT as well and there is a preceding Execute SQL Task with BEGIN TRANSACTION tranname WITH MARK 'tran'

I know I can change the transaction option property from "supported" to "required" however I want to mark the transaction. I was copying the way Import/Export Wizard does it however I'm unable to figure out why it works and why mine doesn't work.

Anyone know of the reason?

View 1 Replies View Related

Analysis :: Find Amount Distribution Across Different Transaction Types Under Spend Transaction

Jul 27, 2015

I created a Calculated measure in cube something like this : ([TransType].[TransTypeHierarchy].[TransTypeCategoryParent].&[SPEND],[Measures].[Transaction Amount]). To get only spend transactions. Now, I want to slice this measure with same hierarchy to find the amount distribution across different transaction types under spend transaction. But this query behaving like the measure doesn't have relation with measure.

you can think this as below query:
WITH
MEMBER SPEND AS ([TransType].[TransTypeHierarchy].[TransTypeCategoryParent].&[SPEND],[Measures].[Transaction Amount])
SELECT NON EMPTY {SPEND} ON 0
,NON EMPTY ([TransType].[TransTypeHierarchy].[TransTypeCategoryParent]) ON 1
FROM [CUBE]

View 6 Replies View Related

How Do I Make Use Of Begin Transaction And Commit Transaction In SSIS.

Jun 1, 2007

Hi



How do I make use of begin transaction and commit transaction in SSIS.

As am not able to commit changes due to certain update commands I want to explicitly write begin and commit statements. but when i make use of begin and commit in OLEDB commnad stage it throws an error as follows:

Hresult:0x80004005

descriptionyntax error or access violation.



its definately not an syntax error as i executed it in sql server. also when i use it in execute sql task out side the dataflow container it doesnt throw any error but still this task doesnt serve my purpose of saving/ commiting update chanages in the database.



Thanks,

Prashant

View 3 Replies View Related

Sql2005:Cannot Use SAVE TRANSACTION Within A Distributed Transaction

Oct 10, 2005

Error returned when trying to commit the transaction to a database that is a replication distributor. (sql2005 ctp16)

View 10 Replies View Related

Problem With SSIS Transaction...Transaction Scope

Jun 1, 2006



Hi,

I am having some problem with SSIS transaction. Eventhought I tried to imitate the concept that Jamie presented at http://www.sqlservercentral.com/columnists/jthomson/transactionsinsqlserver2005integrationservices.asp

. My workflow is as followed

*********************************
For Each ADO.Record in Oracle (transaction=not supported)

If (Certain_Field_Value = 'A')


Lookup Data in SQL DB with values from Oracle (transaction=not supported)

DO Sequence A (Start a Transaction , transaction=required)


INSERT/UPDATE some records in SQLDB(transaction=supported)
Finish Sequence A ( transaction should stop here)
UPDATE Oracle DB ( Execute SQLTask, transaction=not supported)
If (Certain_Field_Value = 'B')


Lookup Data in SQL DB with values from Oracle (transaction=not supported)

DO Sequence B (Start a Transaction , transaction = required)


INSERT/UPDATE some records in SQLDB (transaction=supported)
Finish Sequence A ( transaction should stop here)
UPDATE Oracle DB ( Execute SQLTask, transaction=not supported)
If (Certain_Field_Value = 'C')

------------
------------
End ForEach Loop
*************************************
My requirements are that I want separate transaction for each Sequence A, B, C, etc... If Sequence A transaction fails, the other should still be continuing with another transaction.
But I am getting an error regarding the OLEDB Error in next Task (e.g in Certain_Field_Value = 'B') "Lookup Data in SQL DB with values from Oracle ", the error message is ".......Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction. ".
What is it that I am doing wrong?
Regards
KyawAM

View 12 Replies View Related

Not Saving

Nov 22, 2006

Please i need to save records using DataSet. I created the connectionstring as a global variable. In th button_Click event i have this :
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim InsAdapter As New SqlDataAdapter
Dim StrInsert As String = "insert into Products(CategoryId,ProductName,ProductCode,ProductPrice,) values(@CategoryId,@ProductName,@ProductCode,@ProductPrice)"
Dim ObjComm As New SqlCommand(StrInsert, ObjConn)
ObjComm.Parameters.Add("@CategoryId", SqlDbType.Int).Value = drpCategory.SelectedValue
ObjComm.Parameters.Add("@ProductName", SqlDbType.NVarChar, 30).Value = txtName.Text
ObjComm.Parameters.Add("@ProductCode", SqlDbType.NVarChar, 10).Value = txtCode.Text
ObjComm.Parameters.Add("@ProductPrice", SqlDbType.Int).Value = txtPrice.Text
InsAdapter.InsertCommand = ObjComm
End Sub
But on clicking the button, the record is never saved. Please help

View 4 Replies View Related

Saving To SQL

Nov 29, 2007

I am currently migrating my application from Access to SQL. It looks like it's working good but one thing I cannot understand is why when I have created a varchar(40) field and after I insert a field that is less then 40 characters long, the rest of the string is filled with the leading spaces. I have also create an nchar(40) that did not solve it ether. For example: the text is "Hello World". The text is 11 characters long but the data saved to the table is: "Hello Wolrd" + 29 spaces. Am I doing something wrong?Thanks for your help in advance. 

View 6 Replies View Related

DTS Not Saving

Dec 5, 2007

When I open a DTS package, save it as a bas file, make changes, close the package and save it when prompted, where are my changes saved?

The answer appears to be nowhere. When I reopen the package it's back to it's original setup. When I check the bas file it's as it was when I originally saved it.

Any ideas? Like where my mornings work is gone?

View 3 Replies View Related

Saving Changes

Feb 27, 2008

We have a table with 3.5 million records in it. We have been forced to add two fields and set indexes on those fields. But when we try to save the changes it times out. When we try to generate a change script it also times out. Is this a memeory issue? Any ideas on whats causing this or how to fix it woudl be greatly appriciated.

View 4 Replies View Related

Saving Changes

Nov 20, 2007

Hi, all.This might be a silly question... but I am very new to programming inSQL so please bear with me :)So. I'm using MS SQL Server 2005 Management Studio Express. I have atable that was created via an existing .sql file. Included were abunch of stored procedures. I went in to re-format these procedures.(They were written in haste by another programmer. It is my task to goback and improve their readabilities.) However, I am having difficultyfiguring out how to save the changes to these stored procedures. Thusfar, I have been individually saving each stored procedure in itsown .sql file. This is obviously not the way to go... but it's atemporary solution (so as not to lose the changes I have made todozens of procedures).Can someone please explain to me how I commit these changes to thedatabase?Thanks,Allie

View 1 Replies View Related

Saving Changes In MDX

Feb 22, 2007

Hi,

I have written a report in Reporting Services 2005 which gets its data from a cube.

I want to edit the mdx generated by the Mdx builder in RS 2005, so I click on the "design mode" button to do this.

However, when i make the changes, i cannot save it. How can I do this?

Thanks,

Ashleys.

View 1 Replies View Related

Saving

Feb 1, 2007

Good day

Using vb 2005 express I have my grid veiw on the form and a icon to click to save my work.

But is there a passage of code I can write to pop up a message box to remind me to save my work when I close my form. Similar to ms office forms when you close they ask you if you want to save any changes.

Thanks

Rob

View 3 Replies View Related







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