1. I have 1 stored proc which have execution calls to multiple stored
procs within it.
2. I want to wrap that main stored proc in the transaction and rollback
if there are errors execution calls to other stored procs. I don't
believe my code is accounting for errors occuring in the execution
statement to other stored proc.
3. Is there an easy way to do this without creating tranaction on each
stored proc and returning the error code? How do I make this happen?
Below is the code.
Thanks
:D
ALTER procedure spAG_Add_Product
@prodCostmoney,
@prodWeightdecimal,
@prodDescnvarchar(100),
@prodNamenvarchar(50),
@prodSizenvarchar(100),
@pic_filenamenvarchar(50),
@userIdint,
@exhib_idint
AS
declare @auth_Logic_idint
declare @intErrorCodeint
BEGIN TRAN
SELECT @auth_Logic_id= AG_Auth_Logic.Auth_Logic_ID FROM
AG_Auth_Logic
INNER JOIN AG_Base_Active_State ON AG_Auth_Logic.Base_Active_State_ID
= AG_Base_Active_State.Base_Active_State_ID
WHERE AG_Auth_Logic.Action_Description LIKE N'%category%'
AND AG_Base_Active_State.Is_Alive = 1
I am having problems with syntax errors being generated from the search clause of a full-text search. When the syntax error is raised, the batch and transaction are stopped. Placing the search within a SQL Try/Catch allows the batch to continue, but the transaction is uncommitable.
I need to trap and handle the full-text search syntax error then control the commit or rollback of the transaction based on other transactions.
Below is a simplified version of the type of logic I am working with. The XACT_STATE goes to -1 because of the syntax error generated by the full-text search. This forces a rollback of the whole transaction.
Declare @sSearch NVarChar(50) /* @sSearch is passed by a web page and could come back empty or with an invalid Full-Text search clause*/
Begin Transaction Begin Try Print XACT_STATE() Select * /*The table 'KnowledgeBase' is a table with a populated Full-Text Search*/ From Containstable(KnowledgeBase,*,@sSearch) End Try Begin Catch Print XACT_STATE() Print 'Number- ' + Convert(VarChar,ERROR_NUMBER()) + ', ' + 'Severity- ' + Convert(VarChar,ERROR_SEVERITY()) + ', ' + 'State- ' + Convert(VarChar,ERROR_STATE()) + ', ' + 'Message- "' + ERROR_MESSAGE() + '"' End Catch
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.
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
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.
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?!
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.
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.
Hello, I've a problem with a software developed in C# with the framework 2.0. This is the error I receive : The operation could not be performed because OLE DB provider "SQLNCLI" for linked server "XXX_LINKED_SERVER" was unable to begin a distributed transaction. OLE DB provider "SQLNCLI" for linked server "XXX_LINKED_SERVER" returned message "No transaction is active.". If I try directly to restart the process, it works fine. Is there someone who can help me ? This is the process 1. In C# --> Call of a Query : select from the linked server (db in sql 2005) and insert into a table SQL 2005 2. In the C# --> using (TransactionScope scope = new TransactionScope()) and insert in a table in SQL 2005 which is link server Thank in advance.
I keep receiving the following error whenever I try and call this function to update my database.
The code was working before, all I added was an extra field to update.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'WHERE'
Public Sub MasterList_Update(sender As Object, e As DataListCommandEventArgs)
Dim strProjectName, txtProjectDescription, intProjectID, strProjectState as String Dim intEstDuration, dtmCreationDate, strCreatedBy, strProjectLead, dtmEstCompletionDate as String
Dim myConnection As New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("connectionstring")) Dim cmdSQL As New SqlCommand(strSQL, myConnection)
Forgive the noob question, but i'm still learning SQL everyday and was wondering which of the following is faster? I'm just gonna post parts of the SELECT statement that i've made changes to:
INNER JOIN Facilities f ON e.Facility = f.FacilityID AND f.Name = @FacilityName
OR
WHERE f.Name = @FacilityName
My question is whether or not the query runs faster if i put the condition within the JOIN line as opposed to putting in the WHERE line? Both ways seems to return the same results but the time difference between methods is staggering? Putting the condition within the JOIN line makes the query run about 3 times faster?
Again, forgive my lack of understanding, but could someone agree or disagree and give me the cliff-notes version of why or why not?
) ) ) ) ) AS timeType, Sum([2007_hours].Hours) AS SumOfHours from................
how can you convert it to sql syntax
I need to have a nested If statment which I can't do in sql (in sql I have to have select and from Together for example ( I can't do this in sql): select ID, FName, LName if(SUBSTRING(FirstName, 1, 4)= 'Mike') Begin Replace(FirstNam,'Mike','MikeTest') if(SUBSTRING(LastName, 1, 4)= 'Kong') Begin Replace(LastNam,'Kong,'KongTest') if(SUBSTRING(Address, 1, 4)= '1245') Begin ......... End End
end
Case Statement might be the solution but i could not do it.
This runs in Access, but SQL Server 7 complains that BETWEEN is unrecognized. Can anyone help me? thanks
SELECT yearId, IIf(Date() BETWEEN [qrtOneStart] AND [qrtOneEnd],1, IIf(Date() BETWEEN [qrtTwoStart] AND [qrtTwoEnd], 2, IIf(Date() BETWEEN [qrtThreeStart] AND [qrtThreeEnd], 3, 4))) AS CurrentQrt, yearName FROM tblYear
I am not sure why this is producing a SQL Server related error, but w/ohaving an instance of SQL Server on my machine to verify anything further,can you all help me with this?<!--- validate() ---><cffunction name="validate" access="remote" returnType="numeric"><cfargument name="username" required="yes" type="string" /><cfargument name="password" required="yes" type="string" /><cfquery name="validate" datasource="#request.dsn#">SELECT userIDFROM UserWHERE username = '#UCase(username)#'AND password = '#UCase(password)#'</cfquery><cfif validate.RecordCount EQ 0><cfquery name="log" datasource="#request.dsn#">UPDATE UserSET lastLoggedIn = #createOdbcDate(now())#WHERE userId = #validate.userID#</cfquery><cfreturn validate.userID /><cfelse><cfreturn 0 /></cfif></cffunction>Sorry that's all I can honestly provide, other than the error being on theline with <cfif validate.RecordCount>Phil
Hi,I'm new to ASP and have stumbled across what appears to be a commonproblem, but after trying several solutions from other posts I've hadno luck. My SQL SELECT statement is fine elsewhere (e.g. in ACCESS),but when executed from ASP I get this syntax error:Error Type:Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrectsyntax near '16'./forecast/test.asp, line 27(line 27 is where the date is in the HAVING part of the statement)Here is the Statement:----------------------SELECT dbo_ForecastIn.DataTime AS E_Time, dbo_ForecastInData.DataTimeAS FD_Time, dbo_ForecastInData.WindFarmPower AS ForecastPower FROMdbo_ForecastIn INNER JOIN dbo_ForecastInData ON dbo_ForecastIn.DataID= dbo_ForecastInData.DataID GROUP BY dbo_ForecastIn.DataTime,dbo_ForecastInData.DataTime, dbo_ForecastInData.WindFarmPower HAVINGdbo_ForecastIn.DataTime = #06/02/2004 16:00:00# ORDER BYdbo_ForecastIn.DataTime, dbo_ForecastInData.DataTime;Here is the code:-----------------SQLStmt = "SELECT dbo_ForecastIn.DataTime AS E_Time,dbo_ForecastInData.DataTime AS FD_Time,dbo_ForecastInData.WindFarmPower AS ForecastPower "SQLStmt = SQLStmt & "FROM dbo_ForecastIn INNER JOINdbo_ForecastInData ON dbo_ForecastIn.DataID =dbo_ForecastInData.DataID "SQLStmt = SQLStmt & "GROUP BY dbo_ForecastIn.DataTime,dbo_ForecastInData.DataTime, dbo_ForecastInData.WindFarmPower "SQLStmt = SQLStmt & "HAVING dbo_ForecastIn.DataTime = #06/02/200416:00:00# "SQLStmt = SQLStmt & "ORDER BY dbo_ForecastIn.DataTime,dbo_ForecastInData.DataTime;"response.write(SQLStmt)Set RS = Connection.Execute(SQLStmt)Hope one of you geniuses can sort me out.Thanks.
Hi, I've been tasked with investigating how we can migrate from oracle to sql server. I have successfully converted a typical schema with 97% success using SSMA and have a query regarding ADO and oracle syntax.
I have heard that the SQL server provider can interpret oracle syntax into its own syntax, but i am unable to find any reference/examples on the web. Is this possible? and if so could any kind soul please post some links.
if(@b='1') begin select * into #example from example select * from #example drop table #example end else begin select * into #example from example select * from #example drop table #example end With syntax check, I always get "'#example already exist'" But why? Just because of two "select into temp table" operation? I am confused. Thank you.
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.
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]
I need to pass some SQL to someone else who will run it on their database. I have got the SQL for SQL Server 2000 but they are running SQL Server 7. Apparently the below MSSQL 2000 script doesn't work;
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[tableName]( [id] [int] IDENTITY(1,1) NOT NULL, [ArticleID] [int] NULL, [Heading] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [BodyContent] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [WrittenDate] [datetime] NULL, CONSTRAINT [tableName] PRIMARY KEY CLUSTERED ( [id] ASC ) )
What is the equivalent of the above in for SQL Server 7? I don't have access to it via SQL Server Manager so have to run the script.
I am confused. Any help you can provide, to resolve this error, would be very appreciated...... Thanks in advance!!
I am getting this error message......
Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '-'. /formstoday/issue_log-preview.asp, line 76
The code for line 76 is thus...... objConn.execute sql
Here is the code gor the asp page........ <% Dim StrEmail Dim StrName Dim StrIssue
My VB.Net application connects to MSSQL. It is always running fine for a few days, but encounters "incorrect syntax" as following unless the server is restarted.
---- Exception occurred System.Runtime.InteropServices.COMException (0x80040E14): Line 1: incorrect syntax near 'CDO'. at ADODB.ConnectionClass.Execute (String CommandText, Object& RecordsAffected, Int32 Options) ----
There are a few applications in the server. If certain service is stopped, my program continues to run. So I am sure that the MSSQL connections have been taken up, which causes the error. How to prove it? And is there any way to reserve some DB connections to a particular application only?
Thanks for any hint!
I attach my codes below. Anything wrong with the way that I handled the ADODB?
------------------------------------------------------------ Public Sub SendAllEmails() Try Dim cn As ADODB.Connection = openConn() Dim rs As ADODB._Recordset Dim rs2 As ADODB._Recordset sqlstmt = "select * FROM EMAILTABLE" rs = cn.Execute(sqlstmt)
While Not rs.EOF
Dim MAIL_ADD_USED As String = rs.Fields("MAIL_ADD_USED").Value.ToString
sqlstmt = "select * from NAMETABLE where EMAIL = '" & MAIL_ADD & "'" rs2 = cn.Execute(sqlstmt)
If Not rs2.EOF And ErrMsg = "" Then
ErrMsg = SendMail(MAIL_ADD, REPORT_TITLE)
If Not ErrMsg Is Nothing And ErrMsg.Equals("Success") Then MAIL_DATE_SENT = Now.ToString MAIL_STATUS = "S"
'wait to make sure the email is sent System.Threading.Thread.Sleep(1000 * 30) Else MAIL_STATUS = "F" End If
What is wrong with my syntax?I want to return the value of the AchiveYear Value based on records in theCall that match.
SELECT DATEPART(yyyy,Call_Date) AS ArchiverYear FROM tblCall INNER JOIN PrismDataArchive.dbo.ArchiveDriver AS Arch ON tblCall.DATEPART(yyyy,Call_Date) = Arch.ArchiveYear
This (demo) statement is fine in Access, and so far as I can see, shouldbe OK in SQL Server.But Enterprise Manager barfs at the final bracket. Can anyone helpplease?select sum(field1) as sum1, sum(field2) as sum2 from(SELECT * from test where id < 3unionSELECT * from test where id 2)In fact, I can reduce it to :-select * from(SELECT * from test)with the same effect - clearly I just need telling :-)cheers,Jim--Jima Yorkshire polymoth