Sql Server Transaction Syntax Help

Jul 23, 2005

Hi,

I have an issue with my query.

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

INSERT INTO AG_Individual_Product
(
Product_cost,
Product_weight,
Product_description,
Product_name,
User_ID,
Auth_Logic_Id,
Product_size
)
VALUES (
@prodCost,
@prodWeight,
@prodDesc,
@prodName,
@userId,
@auth_Logic_id,
@prodSize
)



declare @prod_idint
select @prod_id = Scope_identity()

-- add to pic table
declare @pic_id_outint
exec spAG_Add_Picture @pic_filename,
@prodName, @pic_id = @pic_id_outoutput

declare @prod_pic_outint
-- add to product_pic table
exec spAG_Add_Product_Picture @pic_id_out,
@prod_id, @prod_pic_id = @prod_pic_out output

-- add to product_pic_in_exhib
exec spAG_Add_Product_Picture_in_Exhibition @prod_pic_out,
@exhib_id, @prod_id

select @prod_id

SELECT @intErrorCode = @@ERROR
IF (@intErrorCode <> 0) GOTO PROBLEM
COMMIT TRAN

PROBLEM:
IF (@intErrorCode <> 0) BEGIN
ROLLBACK TRAN
END

View 1 Replies


ADVERTISEMENT

Full-Text Search Gets Syntax Error And Kills The Transaction

Oct 26, 2006

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

/*Some other logic would be here*/

Commit Transaction

View 1 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

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

Transaction Scope - 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&a

May 15, 2008

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.

View 1 Replies View Related

Incorrect Syntax Near The Keyword CONVERT When The Syntax Is Correct - Why?

May 20, 2008

Why does the following call to a stored procedure get me this error:


Msg 156, Level 15, State 1, Line 1

Incorrect syntax near the keyword 'CONVERT'.




Code Snippet

EXECUTE OpenInvoiceItemSP_RAM CONVERT(DATETIME,'01-01-2008'), CONVERT(DATETIME,'04/30/2008') , 1,'81350'




The stored procedure accepts two datetime parameters, followed by an INT and a varchar(10) in that order.

I can't find anything wrong in the syntax for CONVERT or any nearby items.


Help me please. Thank you.

View 7 Replies View Related

Incorrect Syntax When There Appears To Be No Syntax Errors.

Dec 14, 2003

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

strProjectName = CType(e.Item.FindControl("txtProjectName"), TextBox).Text
txtProjectDescription = CType(e.Item.FindControl("txtProjDesc"), TextBox).Text
strProjectState = CType(e.Item.FindControl("txtStatus"), TextBox).Text
intEstDuration = CType(e.Item.FindControl("txtDuration"), TextBox).Text
dtmCreationDate = CType(e.Item.FindControl("txtCreation"),TextBox).Text
strCreatedBy = CType(e.Item.FindControl("txtCreatedBy"),TextBox).Text
strProjectLead = CType(e.Item.FindControl("txtLead"),TextBox).Text
dtmEstCompletionDate = CType(e.Item.FindControl("txtComDate"),TextBox).Text
intProjectID = CType(e.Item.FindControl("lblProjectID"), Label).Text

Dim strSQL As String
strSQL = "Update tblProject " _
& "Set strProjectName = @strProjectName, " _
& "txtProjectDescription = @txtProjectDescription, " _
& "strProjectState = @strProjectState, " _
& "intEstDuration = @intEstDuration, " _
& "dtmCreationDate = @dtmCreationDate, " _
& "strCreatedBy = @strCreatedBy, " _
& "strProjectLead = @strProjectLead, " _
& "dtmEstCompletionDate = @dtmEstCompletionDate, " _
& "WHERE intProjectID = @intProjectID"

Dim myConnection As New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("connectionstring"))
Dim cmdSQL As New SqlCommand(strSQL, myConnection)

cmdSQL.Parameters.Add(new SqlParameter("@strProjectName", SqlDbType.NVarChar, 40))
cmdSQL.Parameters("@strProjectName").Value = strProjectName
cmdSQL.Parameters.Add(new SqlParameter("@txtProjectDescription", SqlDbType.NVarChar, 30))
cmdSQL.Parameters("@txtProjectDescription").Value = txtProjectDescription
cmdSQL.Parameters.Add(new SqlParameter("@strProjectState", SqlDbType.NVarChar, 30))
cmdSQL.Parameters("@strProjectState").Value = strProjectState
cmdSQL.Parameters.Add(new SqlParameter("@intEstDuration", SqlDbType.NVarChar, 60))
cmdSQL.Parameters("@intEstDuration").Value = intEstDuration
cmdSQL.Parameters.Add(new SqlParameter("@dtmCreationDate", SqlDbType.NVarChar, 15))
cmdSQL.Parameters("@dtmCreationDate").Value = dtmCreationDate
cmdSQL.Parameters.Add(new SqlParameter("@strCreatedBy", SqlDbType.NVarChar, 10))
cmdSQL.Parameters("@strCreatedBy").Value = strCreatedBy
cmdSQL.Parameters.Add(new SqlParameter("@strProjectLead", SqlDbType.NVarChar, 15))
cmdSQL.Parameters("@strProjectLead").Value = strProjectLead
cmdSQL.Parameters.Add(new SqlParameter("@dtmEstCompletionDate", SqlDbType.NVarChar, 24))
cmdSQL.Parameters("@dtmEstCompletionDate").Value = dtmEstCompletionDate
cmdSQL.Parameters.Add(new SqlParameter("@intProjectID", SqlDbType.NChar, 5))
cmdSQL.Parameters("@intProjectID").Value = intProjectID

myConnection.Open()
cmdSQL.ExecuteNonQuery
myConnection.Close()

MasterList.EditItemIndex = -1
BindMasterList()


End Sub

Thankyou in advance.

View 3 Replies View Related

Which Is Faster? Conditional Within JOIN Syntax Or WHERE Syntax?

Mar 31, 2008

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?

Thanks!

View 4 Replies View Related

Converting Rrom Access Syntax To Sql Syntax

Sep 23, 2007


Ok I am tying to convert access syntax to Sql syntax to put it in a stored procedure or view..
Here is the part that I need to convert:

SELECT [2007_hours].proj_name, [2007_hours].task_name, [2007_hours].Employee,
IIf(Mid([task_name],1,3)='PTO','PTO_Holiday',
IIf(Mid([task_name],1,7)='Holiday','PTO_Holiday',
IIf(Mid([proj_name],1,9) In ('9900-2831','9900-2788'),'II Internal',
IIf(Mid([proj_name],1,9)='9900-2787','Sales',
IIf(Mid([proj_name],1,9)='9910-2799','Sales',
IIf(Mid([proj_name],1,9)='9920-2791','Sales',

)
)
)
)
) 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.






Your input will be appreciated

Thank you

View 5 Replies View Related

T-SQL (SS2K8) :: OPENQUERY Syntax To Insert Into Server Table From Oracle Linked Server

Aug 28, 2014

I was trying to figure out what the OPENQUERY Syntax is to Insert into SQL Server Table from Oracle Linked Server.

View 7 Replies View Related

Is There Any Syntax Like This In SQL Server ?

Oct 6, 2004

Query :

select * from Item1 a (NOLOCK, Index(ItemIn1))
join Item2 b (NOLOCK, Index(ItemData1))

Please explain the above nolock etc after the alias in the given query. What it does ?

Sam.

View 8 Replies View Related

SQL Server Syntax Parsing

Feb 23, 2008

Hi All,

In SQL Studio, there is a really handy option to parse your query prior to running it (that little green tick button next to Execute).

I dont suppose there is a similar thing that can be used on the command line at all is there??

Cheers
-
Karym6

View 2 Replies View Related

Server Query Syntax Help

Nov 5, 2006

Hi,

Following is my one of the field of Server table and it s data (SQL Server 2000 Desktop Ver.)

WORK_DESC
G/B SHADE
VALVE R/C
R/C
R/C ISU IND
CP FLANGE R/C
R/C
FAB. KICK LINE
COAT R/C LINE
R/C

To get the specific data of this WORK_DESC from table, I used following query which results fine.

SELECT RpoMstId, RPO_No, Start_Date, WORK_DESC
FROM T_RPO_Master
WHERE (WORK_DESC = N'R/C')

Which results:

R/C
R/C
R/C

What would be the syntax if I need to represent the data that has ‘R/C’ prefix or suffix in the data field? (anywhere in the data column)

With kind regards,
Ashfaque

View 7 Replies View Related

Access To SQL Server 7 Syntax Help

May 7, 2004

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

View 7 Replies View Related

Syntax Error In Sql Server

Apr 25, 2008

hi anybody know what is meaning of "Syntax error converting datetime from character string" is data entry problem, tq

View 5 Replies View Related

CF / SQL Server Syntax Error HELP

Jul 20, 2005

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

View 2 Replies View Related

SQL Server ASP Syntax Error

Jul 20, 2005

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.

View 1 Replies View Related

ADO 2.7 With Sql Server Using Oracle Syntax

Nov 12, 2006

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.

Thanks in advance,
Michael

View 1 Replies View Related

How SQL Server Do Syntax Check?

Aug 23, 2007

declare @b nvarchar(1)
set @b = '1'


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.

View 5 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

Create Table Syntax SQL In SQL Server 7

Jul 18, 2007

Hi guys,

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.

View 2 Replies View Related

SQL Server Line 1: Incorrect Syntax Near &#39;-&#39;.

Mar 30, 2000

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

StrEmail=request.form("email")
StrName=request.form("name")
StrIssue=request.form("issue")

Set objConn = Server.CreateObject("ADODB.Connection")
Set rs = server.createobject("ADODB.Recordset")

objConn.open "Driver={SQL server};Server=document;DSN=SQL;Database=issues;UI D=steu;PWD;"

sql = "Insert into issue-log2 (name,email,issue) values('" & _
strName & "','" & _
strEmail & "','" & _
StrIssue & "')"

objConn.execute sql
%>


Steu

View 2 Replies View Related

Incorrect Syntax After Server Up For A Few Days

Sep 28, 2006

Dear All,

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

End If

rs2.Close()

sqlstmt = "update EMAILTABLE set " & _
" MAIL_STATUS = " & MAIL_STATUS & "," & _
" MAIL_ERRMSG = null" & _
" where EMAIL = " & MAIL_ADD

cn.Execute(sqlstmt)

rs.MoveNext()

End While

rs.Close()
cn.Close()

Catch e As Exception
EventLog1.WriteEntry("Exception: " & e.ToString)
End Try

End Sub
----------------------------------------------------------------------

View 3 Replies View Related

SQL Server 2012 :: Syntax On A Join

Oct 23, 2015

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

[code]...

View 9 Replies View Related

Select Syntax Execution In Server Behind..

Apr 21, 2008

Hi All,

I need some help from u..

I wanted to know the exact flow behind SQL Server when we fire

SELECT select_list

[ FROM table_source ]

[ON Join_Condition]

[ WHERE search_condition ]

[ GROUP BY group_by_expression ]

[ HAVING search_condition ]

[ ORDER BY order_expression [ ASC | DESC ] ]

what is exact execution process mean which get first strike to server and then what followed then..

T.I.A

View 3 Replies View Related

Oracle - To - SQL Server Syntax Questions

Aug 17, 2005

DESCRIBE in Oracle = ? in SQL SERVER?

Does anyone have a matrix of Oracle to SQL Server common commands?

I am having trouble accessing my company's hosted SQL Server manuals.

TIA

JEJ

View 2 Replies View Related

Correct Syntax For This Select In SQL Server?

Jun 22, 2007

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

View 4 Replies View Related







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