G'day everyoneThat's a space between the ticks.It's all part of a longer script but seeing as the failure occurs online 1if exists (select * from dbo.sysobjects where id =object_id(N'[dbo].[config]') and OBJECTPROPERTY(id, N'IsUserTable') =1)drop table [dbo].[config]GOThat's three lines only. Does it matter that they're in Unicode?Any ideas?Kind regards,Bruce M. AxtensSoftware EngineerStrapper Technologies
Me saying " has any body come across such error would be underestimating".
Well I am getting a very peculiar and unique error "Line 1: Incorrect syntax near 'Actions'."
Explaining you the scene is the following Stored Proc.
This stored proc is execute from a VB code in the .net application as like: - {Try Connection.Init_Variables() cn.ConnectionString = Connection.gstrConnection ResDb.ConnectionString = Connection.gresConnection cn.Open() With sqlCmd .Connection = cn .CommandText = "DSP_Get_Required" .CommandType = CommandType.StoredProcedure
On Execution I get the subjected Error "Line 1: Incorrect syntax near 'Actions'." Any Ideas from your all experience to get away from this error will be helpful. Look forward to read somebody soon.
Stored Proc:- {SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS OFF GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE ID = OBJECT_ID(N'dbo.DSP_Get_Required_ActionS') AND OBJECTPROPERTY(id, N'ISPROCEDURE') = 1) DROP PROCEDURE dbo.DSP_Get_Required_ActionS GO
CREATE PROCEDURE DSP_Get_Required_ActionS @ActionID INT OUTPUT, @PersonID INT OUTPUT, @ReturnMessage Varchar(1000) OUTPUT, @Exists BIT OUTPUT, @Days INT OUTPUT, @StartDate DATETIME OUTPUT, @EndDate DATETIME OUTPUT, @OutCome VARCHAR(20) OUTPUT, @Evaluate INT OUTPUT, @DbName VARCHAR(100) OUTPUT AS
SET NOCOUNT ON
--DECLARE @PopulateSQL AS NVarchar(4000)
DECLARE @Rule_ID AS NUMERIC(9) DECLARE @Curr_ActionSubType AS VARCHAR(20) DECLARE @Eval_SubType AS VARCHAR(20) -- DECLARE @OutCome AS VARCHAR(20) -- DECLARE @Evaluate AS INT -- DECLARE @Days AS INT DECLARE @Message AS VARCHAR(1000) DECLARE @Mandatory AS BIT
-- This is the variable used to interpret the Precedant subtype DECLARE @Prec_Subtype AS VARCHAR(20)
-- DECLARE @Exists AS BIT --this is supposed to be the deceision maker variable to be used within the precedant check.
DECLARE @Precedant_SubTypes_Cnt AS INT --This is the variable used to recordcount the Precedant Subtypes to be checked DECLARE @Counter AS INT -- Counter used to loop through the Table of precedant Subtypes. DECLARE @ROWCOUNT AS INT -- Temporary ROWCOUNT
SET @Counter = 1
--Process to retrive @Curr_ActionSubType Variable CREATE TABLE #Curr_ActionSubType(ActionSubType VARCHAR(100)) EXEC ('INSERT INTO #Curr_ActionSubType SELECT SubType FROM '+ @DbName +'.resadm.action WHERE '+@DbName+'.resadm.action.Actionid = '+ @ActionID+' AND ' +@DbName+'.resadm.action.status =''A''')
SET @Curr_ActionSubType = (Select ActionSubType from #Curr_ActionSubType) DROP TABLE #Curr_ActionSubType
--Process to retrive @StartDate Variable CREATE TABLE #StartDate(StartDate DATETIME) EXEC('INSERT INTO #StartDate SELECT CONVERT(DATETIME, '+@DbName+'.Resadm.Action.DateofAction + '' ''+ '+@DbName+'.Resadm.Action.TimeOfAction) FROM '+@DbName+'.resadm.action WHERE '+@DbName+'.resadm.action.Actionid = '+ @ActionID +' AND '+@DbName+'.resadm.action.status =''A''' )
SET @StartDate = (Select StartDate from #StartDate) DROP TABLE #StartDate
SET @Rule_ID = (SELECT Rule_ID FROM Rules WHERE Curr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BY RULE_ID) SET @Eval_SubType = (SELECT Evaluate_Subtype FROM Rules WHERE Curr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BY Evaluate_Subtype) SET @OutCome = (SELECT OutCome FROM Rules WHERE Curr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BY OutCome) SET @Evaluate = (SELECT Evaluate FROM Rules WHERE Curr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BY Evaluate) SET @Days = (SELECT Days FROM Rules WHERE Curr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BY Days) SET @Message = (SELECT Message FROM Rules WHERE Curr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BY Message) SET @Mandatory = (SELECT Optional_Mandatory_Precedant FROM Rules WHERE Curr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BY Optional_Mandatory_Precedant)
-- create the temporary table for the Subtypes to be evaluated CREATE TABLE #Preceding_SubTypes_Details ( SubTypes_LIST_ID INT IDENTITY (1, 1) NOT NULL, RULE_ID NUMERIC(9), SubType VARCHAR(20), )
-- insert the current subtype that needs to be evaluated. INSERT INTO #Preceding_SubTypes_Details SELECT Rule_ID, Prec_Subtype FROM Rules_Details WHERE Rule_ID = @Rule_ID
-- create the History table for Reference --sk/* Modified to accomodatethe need ot dynamic database name to retrive from the different Resman databases CREATE TABLE #dsHistory ( ActionID INT, PersonID INT, ActionTypeID VARCHAR(1), DateofAction DATETIME, Status VARCHAR(1), Subtype VARCHAR(6), ActionTypeName VARCHAR(30), ActionSubtypeID VARCHAR(6), EffectCandidateCurrentState VARCHAR(10), TaxCode VARCHAR(6) ) EXEC ('INSERT INTO #dsHistory SELECT '+@DbName+'.Resadm.Action.ActionID, ' + @DbName+'.Resadm.Action.PersonID, '+@DbName+'.Resadm.Action.ActionTypeID, ' + 'CONVERT(DATETIME, '+@DbName+'.Resadm.Action.DateofAction + '' ''+ '+@DbName+'.Resadm.Action.TimeOfAction)DateofAction, ' + @DbName+'.Resadm.Action.Status, '+@DbName+'.Resadm.Action.Subtype, ' + @DbName+'.ResAdm.Action_Types.ActionTypeName, '+@DbName+'.Resadm.Action_subtypes.ActionSubtypeID, ' + @DbName+'.Resadm.Action_subtypes.EffectCandidateCurrentState, '+@DbName+'.Resadm.Person.TaxCode ' + ' FROM '+@DbName+'.Resadm.Action ' + ' INNER JOIN '+@DbName+'.ResAdm.Action_Types WITH(NOLOCK) ' + ' ON '+@DbName+'.ResAdm.Action_Types.ActionTypeID = '+@DbName+'.Resadm.Action.ActionTypeID ' + ' INNER JOIN '+@DbName+'.ResAdm.Action_SubTypes WITH(NOLOCK) ' + ' ON '+@DbName+'.Resadm.Action.subtype = '+@DbName+'.ResAdm.Action_SubTypes.actionsubtypeid ' + ' INNER JOIN '+@DbName+'.Resadm.Person WITH(NOLOCK) ' + ' ON '+@DbName+'.Resadm.Person.PersonID = '+@DbName+'.Resadm.Action.PersonID ' + ' WHERE '+@DbName+'.Resadm.Action.actionID <> CONVERT(VARCHAR,'+@ActionID+')' + ' AND '+@DbName+'.Resadm.Action.PersonID = CONVERT(VARCHAR,'+@PersonID+')' + ' AND '+@DbName+'.Resadm.Action.Status =''A'' ' + 'AND (CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofAction +'' ''+ '+@DbName+'.Resadm.Action.TimeOfAction) > ' + ' ISNULL(( SELECT MAX(CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofAction + '' ''+ ' + @DbName+'.Resadm.Action.TimeOfAction)) ' + ' FROM '+@DbName+'.Resadm.Action ' + ' WHERE ('+@DbName+'.Resadm.Action.PersonID = CONVERT(VARCHAR,'+@PersonID+')) AND ' + ' ('+@DbName+'.Resadm.Action.Subtype =''ZERO'') ' + ' AND ('+@DbName+'.Resadm.Action.Status=''A'')),0)) ' + ' ORDER BY CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofAction + '' ''+ '+@DbName+'.Resadm.Action.TimeOfAction )DESC, ActionID DESC')
--sk*/ SET @EndDate = (SELECT ISNULL((SELECT DateOfAction FROM #dsHistory WHERE SubType = @Eval_SubType), getdate()))
-- set the rowcount to retrieve the number of check to be carried out
SET @Precedant_SubTypes_Cnt = (SELECT COUNT(*) FROM #Preceding_SubTypes_Details)
WHILE @Counter <= @Precedant_SubTypes_Cnt BEGIN SET @Prec_Subtype = (SELECT SubType from #Preceding_SubTypes_Details WHERE SubTypes_LIST_ID = @Counter)
SET @ROWCOUNT = (SELECT COUNT(*) FROM #dsHistory WHERE Subtype = @Prec_Subtype)
IF @ROWCOUNT > 0 BEGIN SET @Exists = 1 END
IF @ROWCOUNT = 0 BEGIN IF @Mandatory = 1 BEGIN SET @Message = @Message + ' ' + @Prec_Subtype + ' Is Missing; ' SET @Counter = @Precedant_SubTypes_Cnt SET @Exists = 0 END ELSE IF @Mandatory = 0 BEGIN SET @Message = @Message + ' ' + @Prec_Subtype + ' Is Missing; ' SET @Exists = @Exists END END
SET @Counter = @Counter+1 END
IF @Exists = 0 BEGIN EXEC( ' UPDATE '+@DbName+'.Resadm.Action ' + ' SET '+@DbName+'.Resadm.Action.Status = ''I'' ' + ' WHERE '+@DbName+'.Resadm.Action.ActionID = '+@ActionID+' SET @ReturnMessage = '+@Message ) END ELSE IF @Exists = 1 BEGIN SET @ReturnMessage = @Message END
IF @Rule_ID = Null BEGIN SET @ReturnMessage = 'Validation Rule Not Present' END -- Select 'Exist value : ', @Exists, 'Return message is : ', @ReturnMessage DROP TABLE #Preceding_SubTypes_Details DROP TABLE #dshistory
GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO}
Hi,I'm getting the above error when i try to fill a Dataset through adataAdapter.I presume it is to do with the sql statement. Below is the relevantcode:string strPntUnitID = patientCodeLbl.Text;string strPntFName = fNameLbl.Text;string strPntLName = lNameLbl.Text;// Create DataAdapter & DatasetSqlDataAdapter daRelateDocToPnt = new SqlDataAdapter("SELECT patientNo,doctorNo FROM tblPatient" +"WHERE (pntUnitID = '"+ strPntUnitID +"') AND (pntFName = '"+strPntFName +"')"+"AND (pntLName = '"+ strPntLName +"')", conn);DataSet dsDocNoToPnt = new DataSet();// Create command builder, automatically generates the update commandsSqlCommandBuilder pntCmd = new SqlCommandBuilder(daRelateDocToPnt);// Set the MissingSchemaAction property to AddWithKey because Fill willnot cause primary// key & unique key information to be retrieved unless AddWithKey isspecified.daRelateDocToPnt.MissingSchemaAction = MissingSchemaAction.AddWithKey;// Use dataAdapter to fill DataSetdaRelateDocToPnt.Fill(dsDocNoToPnt, "Patient");// place intDocNo into the dataset schemadsDocNoToPnt.Tables["Patient"].Rows[0]["doctorNo"] = "intDocNo";// Update The DatabasedaRelateDocToPnt.Update(dsDocNoToPnt, "Patient");Can anyone spot the problem?Thanks
Hello All,Me saying " has any body come across such error would beunderestimating".Well I am getting a very peculiar and unique error "Line 1: Incorrectsyntax near 'Actions'."Explaining you the scene is the following Stored Proc.This stored proc is execute from a VB code in the .net application aslike: -{TryConnection.Init_Variables()cn.ConnectionString = Connection.gstrConnectionResDb.ConnectionString = Connection.gresConnectioncn.Open()With sqlCmd..Connection = cn..CommandText = "DSP_Get_Required".CommandType = CommandType.StoredProcedure..Parameters.Add("@ActionId", SqlDbType.Int, 9).Value = ActionID..Parameters("@ActionId").Direction = ParameterDirection.InputOutput..Parameters.Add("@PersonID", SqlDbType.Int, 9).Value = PersonID..Parameters("@PersonID").Direction = ParameterDirection.InputOutput..Parameters.Add("@ReturnMessage", SqlDbType.VarChar, 1000).Value =ReturnMessage.ToString..Parameters("@ReturnMessage").Direction =ParameterDirection.InputOutput..Parameters.Add("@Exists", SqlDbType.Bit, 1).Value = Exists..Parameters("@Exists").Direction = ParameterDirection.InputOutput..Parameters.Add("@Days", SqlDbType.Int, 9).Value = 0..Parameters("@Days").Direction = ParameterDirection.InputOutput..Parameters.Add("@StartDate", SqlDbType.DateTime).Value = Now()..Parameters("@StartDate").Direction = ParameterDirection.InputOutput..Parameters.Add("@EndDate", SqlDbType.DateTime).Value = Now()..Parameters("@EndDate").Direction = ParameterDirection.InputOutput..Parameters.Add("@OutCome", SqlDbType.VarChar, 20).Value = "Stop"..Parameters("@OutCome").Direction = ParameterDirection.InputOutput..Parameters.Add("@Evaluate", SqlDbType.Int, 9).Value = 0..Parameters("@Evaluate").Direction = ParameterDirection.InputOutput..Parameters.Add("@DbName", SqlDbType.VarChar, 100).Value =ResDb.Database.ToString..Parameters("@DbName").Direction = ParameterDirection.InputOutput..ExecuteReader(CommandBehavior.Default)}On Execution I get the subjected Error "Line 1: Incorrect syntax near'Actions'."Any Ideas from your all experience to get away from this error will behelpful. Look forward to read somebody soon.Stored Proc:-{SET QUOTED_IDENTIFIER OFFGOSET ANSI_NULLS OFFGOIF EXISTS (SELECT * FROM dbo.sysobjects WHERE ID =OBJECT_ID(N'dbo.DSP_Get_Required_ActionS') AND OBJECTPROPERTY(id,N'ISPROCEDURE') = 1)DROP PROCEDURE dbo.DSP_Get_Required_ActionSGOCREATE PROCEDURE DSP_Get_Required_ActionS@ActionID INT OUTPUT,@PersonID INT OUTPUT,@ReturnMessage Varchar(1000) OUTPUT,@Exists BIT OUTPUT,@Days INT OUTPUT,@StartDate DATETIME OUTPUT,@EndDate DATETIME OUTPUT,@OutCome VARCHAR(20) OUTPUT,@Evaluate INT OUTPUT,@DbName VARCHAR(100) OUTPUTASSET NOCOUNT ON--DECLARE @PopulateSQL AS NVarchar(4000)DECLARE @Rule_ID AS NUMERIC(9)DECLARE @Curr_ActionSubType AS VARCHAR(20)DECLARE @Eval_SubType AS VARCHAR(20)-- DECLARE @OutCome AS VARCHAR(20)-- DECLARE @Evaluate AS INT-- DECLARE @Days AS INTDECLARE @Message AS VARCHAR(1000)DECLARE @Mandatory AS BIT-- This is the variable used to interpret the Precedant subtypeDECLARE @Prec_Subtype AS VARCHAR(20)-- DECLARE @Exists AS BIT --this is supposed to be the deceision makervariable to be used within the precedant check.DECLARE @Precedant_SubTypes_Cnt AS INT--This is the variable used torecordcount the Precedant Subtypes to be checkedDECLARE @Counter AS INT -- Counter used to loop through the Table ofprecedant Subtypes.DECLARE @ROWCOUNT AS INT -- Temporary ROWCOUNTSET @Counter = 1--Process to retrive @Curr_ActionSubType VariableCREATE TABLE #Curr_ActionSubType(ActionSubType VARCHAR(100))EXEC ('INSERT INTO #Curr_ActionSubType SELECT SubType FROM '+ @DbName+'.resadm.action WHERE '+@DbName+'.resadm.action.Actionid = '+@ActionID+' AND ' +@DbName+'.resadm.action.status =''A''')SET @Curr_ActionSubType = (Select ActionSubType from#Curr_ActionSubType)DROP TABLE #Curr_ActionSubType--Process to retrive @StartDate VariableCREATE TABLE #StartDate(StartDate DATETIME)EXEC('INSERT INTO #StartDate SELECT CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofAction + '' ''+'+@DbName+'.Resadm.Action.TimeOfAction)FROM '+@DbName+'.resadm.actionWHERE '+@DbName+'.resadm.action.Actionid = '+ @ActionID +' AND'+@DbName+'.resadm.action.status =''A''')SET @StartDate = (Select StartDate from #StartDate)DROP TABLE #StartDateSET @Rule_ID = (SELECT Rule_ID FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY RULE_ID)SET @Eval_SubType = (SELECT Evaluate_Subtype FROM Rules WHERECurr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BYEvaluate_Subtype)SET @OutCome = (SELECT OutCome FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY OutCome)SET @Evaluate = (SELECT Evaluate FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY Evaluate)SET @Days = (SELECT Days FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY Days)SET @Message = (SELECT Message FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY Message)SET @Mandatory = (SELECT Optional_Mandatory_Precedant FROM Rules WHERECurr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BYOptional_Mandatory_Precedant)-- create the temporary table for the Subtypes to be evaluatedCREATE TABLE #Preceding_SubTypes_Details(SubTypes_LIST_ID INT IDENTITY (1, 1) NOT NULL,RULE_ID NUMERIC(9),SubType VARCHAR(20),)-- insert the current subtype that needs to be evaluated.INSERT INTO #Preceding_SubTypes_DetailsSELECT Rule_ID, Prec_SubtypeFROM Rules_DetailsWHERE Rule_ID = @Rule_ID-- create the History table for Reference--sk/*Modified to accomodatethe need ot dynamic database name toretrive from the different Resman databasesCREATE TABLE #dsHistory ( ActionID INT,PersonID INT,ActionTypeID VARCHAR(1),DateofAction DATETIME,Status VARCHAR(1),Subtype VARCHAR(6),ActionTypeName VARCHAR(30),ActionSubtypeID VARCHAR(6),EffectCandidateCurrentState VARCHAR(10),TaxCode VARCHAR(6))EXEC ('INSERT INTO #dsHistory SELECT'+@DbName+'.Resadm.Action.ActionID, '+ @DbName+'.Resadm.Action.PersonID,'+@DbName+'.Resadm.Action.ActionTypeID, '+ 'CONVERT(DATETIME, '+@DbName+'.Resadm.Action.DateofAction + '' ''+'+@DbName+'.Resadm.Action.TimeOfAction)DateofActio n, '+ @DbName+'.Resadm.Action.Status, '+@DbName+'.Resadm.Action.Subtype, '+ @DbName+'.ResAdm.Action_Types.ActionTypeName,'+@DbName+'.Resadm.Action_subtypes.ActionSubtypeID , '+ @DbName+'.Resadm.Action_subtypes.EffectCandidateCu rrentState,'+@DbName+'.Resadm.Person.TaxCode '+ ' FROM '+@DbName+'.Resadm.Action '+ ' INNER JOIN '+@DbName+'.ResAdm.Action_Types WITH(NOLOCK) '+ ' ON '+@DbName+'.ResAdm.Action_Types.ActionTypeID ='+@DbName+'.Resadm.Action.ActionTypeID '+ ' INNER JOIN '+@DbName+'.ResAdm.Action_SubTypes WITH(NOLOCK) '+ ' ON '+@DbName+'.Resadm.Action.subtype ='+@DbName+'.ResAdm.Action_SubTypes.actionsubtypeid '+ ' INNER JOIN '+@DbName+'.Resadm.Person WITH(NOLOCK) '+ ' ON '+@DbName+'.Resadm.Person.PersonID ='+@DbName+'.Resadm.Action.PersonID '+ ' WHERE '+@DbName+'.Resadm.Action.actionID <>CONVERT(VARCHAR,'+@ActionID+')'+ ' AND '+@DbName+'.Resadm.Action.PersonID =CONVERT(VARCHAR,'+@PersonID+')'+ ' AND '+@DbName+'.Resadm.Action.Status =''A'' '+ 'AND (CONVERT(DATETIME,'+@DbName+'.Resadm.Action.Dateof Action +''''+ '+@DbName+'.Resadm.Action.TimeOfAction) > '+ ' ISNULL(( SELECTMAX(CONVERT(DATETIME,'+@DbName+'.Resadm.Action.Dat eofAction + '' ''+ '+ @DbName+'.Resadm.Action.TimeOfAction)) '+ ' FROM '+@DbName+'.Resadm.Action '+ ' WHERE ('+@DbName+'.Resadm.Action.PersonID =CONVERT(VARCHAR,'+@PersonID+')) AND '+ ' ('+@DbName+'.Resadm.Action.Subtype =''ZERO'') '+ ' AND ('+@DbName+'.Resadm.Action.Status=''A'')),0)) '+ ' ORDER BY CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofA ction +'' ''+ '+@DbName+'.Resadm.Action.TimeOfAction )DESC, ActionID DESC')--sk*/SET @EndDate = (SELECT ISNULL((SELECT DateOfActionFROM #dsHistoryWHERE SubType = @Eval_SubType), getdate()))-- set the rowcount to retrieve the number of check to be carried outSET @Precedant_SubTypes_Cnt = (SELECT COUNT(*) FROM#Preceding_SubTypes_Details)WHILE @Counter <= @Precedant_SubTypes_CntBEGINSET @Prec_Subtype = (SELECT SubType from #Preceding_SubTypes_DetailsWHERE SubTypes_LIST_ID = @Counter)SET @ROWCOUNT = (SELECT COUNT(*) FROM #dsHistory WHERE Subtype =@Prec_Subtype)IF @ROWCOUNT > 0BEGINSET @Exists = 1ENDIF @ROWCOUNT = 0BEGINIF @Mandatory = 1BEGINSET @Message = @Message + ' ' + @Prec_Subtype + ' Is Missing; 'SET @Counter = @Precedant_SubTypes_CntSET @Exists = 0ENDELSE IF @Mandatory = 0BEGINSET @Message = @Message + ' ' + @Prec_Subtype + ' Is Missing; 'SET @Exists = @ExistsENDENDSET @Counter = @Counter+1ENDIF @Exists = 0BEGINEXEC(' UPDATE '+@DbName+'.Resadm.Action '+ ' SET '+@DbName+'.Resadm.Action.Status = ''I'' '+ ' WHERE '+@DbName+'.Resadm.Action.ActionID = '+@ActionID+' SET@ReturnMessage = '+@Message)ENDELSEIF @Exists = 1BEGINSET @ReturnMessage = @MessageENDIF @Rule_ID = NullBEGINSET @ReturnMessage = 'Validation Rule Not Present'END-- Select 'Exist value : ', @Exists, 'Return message is : ',@ReturnMessageDROP TABLE #Preceding_SubTypes_DetailsDROP TABLE #dshistoryGOSET QUOTED_IDENTIFIER OFFGOSET ANSI_NULLS ONGO}
I have a similar problem as mentioned in the first mail of this chain. I am getting Line 202:Incorrect syntax near 'end'" while I try to execute the procedure from my VC++ code using
<SQL Code> CREATE PROCEDURE PABX_sp_MyPABX_ShowExtWatch @FromDate DATETIME, @ToDate DATETIME, @PortalID INT = 1, @UserID INT AS SELECT PABX_Ext_Watch.ExtNo As ExtNo, COUNT(*) AS Calls, SUM(PABX_Calls.Rate) AS NetAmt FROM PABX_Ext_Watch INNER JOIN PABX_Calls ON PABX_Ext_Watch.ExtNo = PABX_Calls.ExtNo INNER JOIN PABX_PortalUsers ON PABX_Ext_Watch.PortalUserID = PABX_PortalUsers.PortalUserID AND PABX_Calls.PortalID = PABX_PortalUsers.PortalID WHERE PABX_Calls.sTime >= CONVERT(DATETIME, @FromDate, 102) AND PABX_Calls.eTime <= CONVERT(DATETIME, @ToDate, 102) AND PABX_PortalUsers.uID = @UserID AND PABX_PortalUsers.PortalID = @PortalID GROUP BY PABX_Ext_Watch.ExtNo GO </SQL Code>
However if I execute this stored procedure in asp.net I get the following error, despite the stored procedure executed successfully in query analyzer:
Line 1: Incorrect Syntax Near ......
When I check the sql profiler the stored procedure is been executed in this way:
I couldn't figure it out though sql server management console and query analyzer showed no signs of errors. I sense that the sql is not being executed correctly with letters as "N" in the sql profiler.
I am trying to prepare a login page.My code first controls if user exists in database with GetUser stored procedure then if he/she exists getting the roles assigned to that user with GetUserRoles procedure but I am taking this error Line 1: Incorrect syntax near 'GetUserRoles'.
GetUserRoles Procedure:
SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO ALTER Procedure GetUserRoles ( @UserName char(10), @Roles char(10) Output ) As Select @Roles=RoleID From UserRoles Where UserID=@UserName GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO
--------------- Line 1: Incorrect syntax near '='.
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.SqlClient.SqlException: Line 1: Incorrect syntax near '='.
Source Error:
Line 40: Dim adpt As New SqlDataAdapter("SELECT * FROM SMS_student_class_master WHERE" & _ Line 41: "stud_id=" & sid, con) Line 42: adpt.Fill(ds, "SMS_student_class_master") Line 43: txt.Text = ds.Tables.Item("roll_no").ToString Line 44: con.Close()
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
This is the error it gives me for my code and then it calls out line 102. Line 102 is my buildDD(sql, ddlPernames) When I comment out this line the error goes away, but what I don't get is this is the same way I build all of my dropdown boxes and they all work but this one. Could it not like something in my sql select statement. thanksPrivate Sub DDLUIC_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DDLUIC.SelectedIndexChanged Dim taskforceID As Byte = ddlTaskForce.SelectedValueDim uic As String = DDLUIC.SelectedValue sql = "select sidstrNAME_IND from CMS.dbo.tblSIDPERS where sidstrSSN_SM in (Select Case u.strSSN from tblAssignedPersonnel as u " _ & "where u.bitPresent = 1 and u.intUICID in (select intUICID from tblUIC where intTaskForceID = " & taskforceID & " and strUIC = '" & uic & "'))"ddlPerNames.Items.Add(New ListItem("", "0")) buildDD(sql, ddlPerNames)
Here is a Database script I wrote: I can't figure out what the problem is when I declare my primary Keys in the second and third table. Thanks in Advance
Errors:
Msg 156, Level 15, State 1, Line 19
Incorrect syntax near the keyword 'IDENTITY'.
Msg 156, Level 15, State 1, Line 29
Incorrect syntax near the keyword 'IDENTITY'.
CREATE DATABASE GoGreen
Go
USE GoGreen
Create TABLE Student
(StudentID INT NOT NULL IDENTITY PRIMARY KEY, <---no Error here
DrivePassCode char(3) NOT NULL,
LName varchar(50) NOT NULL,
FName varchar(50) NOT NULL,
Address1 varchar(50) NOT NULL,
Address2 varchar(50) NULL,
City varchar(50) NOT NULL,
PostalCode varchar(20) NOT NULL,
PhoneNumber varchar(50) NOT NULL,
Email varchar(50) NOT NULL,
Smoker char(2) NOT NULL,
NearestCityOrTown varchar(50) NOT NULL,
PaymentType varchar(20) NOT NULL,)
CREATE TABLE CoordinatedRideShare
(RideID INT NOT NULL, IDENTITY PRIMARY KEY, <---Error #1
StudentID INT NOT NULL REFERENCES Student(StudentID)
[ON DELETE {CASCADE}]
[ON UPDATE {CASCADE}],
M-W ARRIVAL TIME smalldatetime NOT NULL,
M-W DEPART TIME smalldatetime NOT NULL,
T-TH ARRIVAL TIME smalldatetime NOT NULL,
T-TH DEPART TIME smalldatetime NOT NULL,)
CREATE TABLE MeetingLocation
(LocationID INT NOT NULL, IDENTITY PRIMARY KEY AUTONUMBER, <---Error#2
RideID INT NOT NULL REFERENCES Coordinated RideShare(RideID)
Hello, Can anybody help me with this error , System.Data.SqlClient.SqlException. "Line 1: Incorrect Syntax near :'m' ."
I have a textbox named DESCRIPTION and am trying to insert the values entered by user in this textbox.
It works well if a user types " I am unable to " but it throws this error when a user types " I'm unable to "...because of I'm .. How do i fix this?
My Query:
strSQL = "Insert into ABC(DESCRIPTION) values('" & strDescription & "')"
When i try below query in query analyser , am getting this error .... Error 1: [Line 1: Incorrect syntax near 'm'.] Error 2: [ Unclosed quotation mark before the character string '.]
update ABC set DESCRIPTION = 'I'm unable' WHERE ABC_ID = '142'
Hi, for some AP issue, the file I upload must be without the line feed/carriage return in the last line. for example:
original fixed-length file (exported from SSIS) line NO DATA 1 AA123456 50 60 2 BB123456 30 40 3 CC123456 80 90 4 <-- with line feed/carriage return in the last line
The file format that AP request. The file only has 3 records, so it should end in the third line. line NO DATA 1 AA123456 50 60 2 BB123456 30 40 3 CC123456 80 90
Should I use script component to do it ? I am new for VB . Anyone would help me ?
I need the Trend line for the following data in Line chart they are the following data. The following are the graph are my output and i need the trend line for these Key_gap value.
This is the link [URL] ....
I need the same trend line for the Bar-Chart in SSRS 2005.
I hope I'm posting this in the correct forum (forgive me if I'm not) since I'm not sure if this is an issue with inserting an item into a db or the processing of what I get out of it. I wrote a basic commenting system in which someone my post a comment about something written on the site. I wanted to keep it very simple, but I at least want the ability for a user to have newlines in their comment without having to hardcode a <br /> or something like that. Is there a way for me to detect a newline if someone, for example, is going to their next paragraph? Let me know if you need a better explanation. Thanks in advance!
We have a line graph which plots the actual data points (x,y), everything is working fine with this graph. Now we need to add a trend line to this existing graph after going thro. the articles we came to know that there is no direct option in SSRS to draw a trend line. So we need to calculate the trend values ourselves which we need to plot as atrend line. This trend line is similar to the trend line which comes in Excel chart, do anyone know how to calculate the trend values from the actual data points. We got through several formulas, but were not clear, have anyone tried out exactly the same, if so please help us out by providing an example to calculate the trend values.
I have a line graph which shows positive and negative values. Is it possible to have the line one color when its negative and another when its positive?
from dbo.ALM_USERS ALM, dbo.PeopleViewPV, dbo.corp_emp_ids AD, dbo.ALM_USERS ACE
where cast(ALM.USR_login as int)= PV.EmployeeID -- PV and ALM.USR_login = CAST(AD.employeeid AS varchar)---AD and ALM.USR_login = ACE.chdata ----ACE AND ALM.USR_login NOT IN ('BTGWC1', 'DMADMIN', 'IFILL', 'TESTUSER', 'WTDEV06', 'XELOPERATOR', 'XELSELFREG', 'XELSYSADM') AND ALM.USR_STATUS = 'Disabled')
ID                      Customer              Type                 TypeNUm 100                     Tiger                    Item                   T100  100                      Tiger                    Item                   T200 100                     Tiger                    Item                   T300 100                     Tiger                    Shiper                  SAAA 100                      Tiger                   PO                      POAAA 200                      Panera                 GL                  WE 200                      Panera                 PO                  POBBB
The reftypes are not always the same, what I need is to get it in this form
ID                      Customer              Type             TypeNUm 100                     Tiger                    Item                   T100,T200, T300 100                     Tiger                    Shiper                  SAAA 100                      Tiger                   PO                      POAAA 200                      Panera                 GL                     WE 200                      Panera                 PO                    POBBB
I'm sure I am not undestanding some basic concept here but the following formula always produces an invalid token error at the '-' sign. In this example, I'm trying to subtract out a specific month from the total (this is a simplified example, my actual formula needs to compute a % change over time using lag...)
This produces the invalid token error (it always errors at the '-' in the equation)
with member [Measures].[MyCalcMeasure] as [Measures].[MyBaseMeasure]-([Date Submitted].[Date Submitted YQMD].[month].&[2008]&[1],[Measures].[MyBaseMeasure]) select [Measures].[MyCalcMeasure] on columns, [MyDim].[MyHierarchy].[Level1].members on rows from MyCube
But this works
with member [Measures].[MyCalcMeasure] as [Measures].[MyBaseMeasure] select [Measures].[MyCalcMeasure] on columns, [MyDim].[MyHierarchy].[Level1].members on rows from MyCube
As does this
with member [Measures].[MyCalcMeasure] as ([Date Submitted].[Date Submitted YQMD].[month].&[2008]&[1],[Measures].[MyBaseMeasure]) select [Measures].[MyCalcMeasure] on columns, [MyDim].[MyHierarchy].[Level1].members on rows from MyCube
Hi If i use this code i cant get the data showed, it show nothing."SELECT COUNT(DogImageDate) AS Amount, DogImageDate, DogImageID FROM EnggaardImages WHERE DogImageDate NOT LIKE (SELECT TOP 1 DogImageDate FROM EnggaardImages ORDER BY DogImageDate DESC;) GROUP BY DogImageDate ORDER BY DogImageDate DESC;" But if i use this code i get data showed"SELECT COUNT(DogImageDate) AS Amount, DogImageDate, DogImageID FROM EnggaardImages GROUP BY DogImageDate ORDER BY DogImageDate DESC;" Then i get Images(6)Images(1)Images(1) But i dont want the first to be showed, therefor i use the Select TOP 1, so i get a look like this Images(1)Images(1) But i cant get it to work.
Hello all Trying to delete some data from a SSCE (2005) DB produces the exception: SqlCeException There was an error parsing the query. [ Token line number = 1,Token line offset = 43,Token in error = C] Here is the code I am using
I'm trying to insert some values into an SQL Compact database on a WM6 device but there is something apparently wrong with my SQL statement...
The program is going to allow users to schedule an SMS message to be sent at a certain date and time. I'm using a database to keep track of the scheduled SMS messages. The database has 3 rows: phone number, message, and the date/time to be sent.
I'm guessing it doesn't like how I am trying to get the data from the different text boxes and the DateTimePicker to go inside the SQL command. Does anyone have any ideas on how to fix my SQL command or how to get data from a textbox and DateTimePicker to be inserted into a database a different way?
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)
What I am trying to create a query to check, If recDT is not value or null, then will use value from SELECT top 1 recDtim FROM Serv. Otherwise, will use the value from recDT. I have tried the below query but it doesn't work. The error says, Incorrect syntax near the keyword 'SELECT'.Incorrect syntax near the keyword 'else'.1 SELECT 2 case when recDT='' then SELECT top 1 recDtim FROM Serv else recDT end 3 FROM abc 4 Anyone can help? Thanks a lot.