MS Access SQL Syntax Error

Apr 22, 2004

There is a JOIN syntax error in this SQL, but my slow brain cannot figure out where. I tried to join two queries, which had been successful. Problem occurred when I added second left join. Can anyone help?

PARAMETERS pstrFinYear Text ( 255 ), pintAdjMonth Long;

SELECT A.BudgetLineID, A.BudgetLine, B.NumIsDevelopBusinessInternationally, B.NumIsDeeperParticipation, B.NumIsNewExporter, B.NumProjects, C.NumCompanies, A.KMISReportOrder
FROM ( tblkpBudgetLine AS A

LEFT JOIN

[SELECT BudgetLineID, FinancialYear, SUM(IsDevelopBusinessInternationally) AS NumIsDevelopBusinessInternationally, SUM(IsDeeperParticipation) AS NumIsDeeperParticipation, (-1*SUM(AdjustedNewExpMonth=pintAdjMonth)) AS NumIsNewExporter, COUNT(ProjectID) AS NumProjects
FROM qryBoardReport_Actuals
WHERE FinancialYear=pstrFinYear
AND AdjustedProjectStartMonth=pintAdjMonth
GROUP BY BudgetLineID, FinancialYear]. AS B
ON (A.BudgetLineID=B.BudgetLineID) AND (A.FinancialYear=B.BudgetLine)

LEFT JOIN

[SELECT Z.BudgetLineID, Z.FinancialYear, Z.AdjustedProjectStartMonth, COUNT(Z.Company) AS NumCompanies
FROM [SELECT DISTINCT qryBoardReport_Actuals.BudgetLineID AS BudgetLineID, qryBoardReport_Actuals.FinancialYear AS
FinancialYear, qryBoardReport_Actuals.AdjustedProjectStartMonth, qryBoardReport_Actuals.CompanyID as Company
FROM qryBoardReport_Actuals
WHERE FinancialYear=pstrFinYear
AND AdjustedProjectStartMonth=pintAdjMonth
GROUP BY qryBoardReport_Actuals.FinancialYear, qryBoardReport_Actuals.BudgetLineID, qryBoardReport_Actuals.AdjustedProjectStartMonth, qryBoardReport_Actuals.CompanyID]. AS Z
GROUP BY FinancialYear, BudgetLineID, AdjustedProjectStartMonth] as C

ON (A.BudgetLineID=C.BudgetLineID) and (A.FinancialYear=C.FinancialYear))


WHERE A.FinancialYear=pstrFinYear
ORDER BY A.KMISReportOrder;

View 8 Replies


ADVERTISEMENT

Execute SQL Task: Executing The Query Exec (?) Failed With The Following Error: Syntax Error Or Access Violation. Possible F

Jan 23, 2008

Hi,
I'm having an SSIS package which gives the following error when executed :

Error: 0xC002F210 at Create Linked Server, Execute SQL Task: Executing the query "exec (?)" failed with the following error: "Syntax error or access violation". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.Task failed: Create Linked Server

The package has a single Execute SQL task with the properties listed below :

General Properties
Result Set : None

ConnectionType : OLEDB
Connection : Connected to a Local Database (DB1)
SQLSourceType : Direct Input
SQL Statement : exec(?)
IsQueryStorePro : False
BypassPrepare : False

Parameter Mapping Properties

variableName Direction DataType ParameterName

User::AddLinkSql Input Varchar 0


'AddLinkSql' is a global variable of package scope of type string with the value
Exec sp_AddLinkedServer 'Srv1','','SQLOLEDB.1',@DataSrc='localhost',@catalog ='DB1'

When I try to execute the Query task, it fails with the above error. Also, the above the sql statement cannot be parsed and gives error "The query failed to parse. Syntax or access violation"

I would like to add that the above package was migrated from DTS, where it runs without any error, eventhough
it gives the same parse error message.

I would appreciate if anybody can help me out of this issue by suggeting where the problem is.

Thanks in Advance.

View 12 Replies View Related

Error 0: Syntax Error Or Access Violation

Aug 1, 2004

Hi,
I'm writing a stored procedure and when I click on the Check Syntax button its giving me the error in the subject. I'm not really sure whats wrong with this. Here is my Stored Procedure code. Any help wud be appreciated.


CREATE PROC CabsSchedule_Insert
{
@JulianDatesmallint,
@SiteCodesmallint,
@CalendarDaysmallint,
@BillPeriodsmallint,
@WorkDaysmallint,
@CalDayBillRcvd varchar(30),
@Remarksvarchar(50)
}
AS
INSERT INTO CabsSchedule
(JulianDate, SiteCode, CalendarDay, BillPeriod, WorkDay, CalDayBillRcvd, Remarks)
VALUES
(@JulianDate, @SiteCode, @CalendarDay, @BillPeriod, @WorkDay, @CalDayBillRcvd, @Remarks)


Thanks,

View 2 Replies View Related

[Microsoft][ODBC SQL Server Driver]Syntax Error Or Access Violation'

Apr 25, 2003

Where i try to create stored procedure in sql server 2000 using query analyzer i'm getting an error

'[Microsoft][ODBC SQL Server Driver]Syntax error or access violation'

and the same stored procedure if i try after some time without any changes it gets created..

how is wrong?

View 2 Replies View Related

[Microsoft][ODBC SQL Server Driver]Syntax Error Or Access Violation

Apr 17, 2008



Hi guys! I am using SQL 2005 and I wonder why I am encountering the error "[Microsoft][ODBC SQL Server Driver]Syntax error or access violation" everytime I am trying to create stored procedure with temp table and table variable.
See my code below with temp table.


Any thoughts will be appreciated!

CREATE PROCEDURE DBO.SAMPLESP
(@DETAILS AS VARCHAR(8000),
@ID AS VARCHAR(15))


AS

BEGIN TRANSACTION

CREATE TABLE DBO.#TEMPTABLE
{
ASSET VARCHAR(50)
}

DECLARE @INSTINSERT AS NVARCHAR(4000)
SET @INSTINSERT= 'INSERT INTO #TEMPTABLE(ASSET)'
SET @INSTINSERT= @INSTINSERT+ @DETAILS

EXEC sp_ExecuteSQL @INSTINSERT

INSERT INTO InstDetail
(TrackNum, ASSETID)
SELECT @ID, A.ASSE
FROM #TEMPTABLE A

DROP TABLE #TEMPTABLE


IF @@ERROR != 0
BEGIN
ROLLBACK TRANSACTION
RAISERROR('There was an error in here', 11, 1)
RETURN
END
ELSE
COMMIT TRANSACTION

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

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

Convert Access Query To Syntax?

Aug 21, 2013

I am trying to convert a code from access Db to sql code?

II(Left([dbo_ClaimLosstype].[dscr],4)="Liab","D_Liab","D_Property"),

View 4 Replies View Related

Incorrect Syntax Near... Fine In QA Not In Access

Apr 4, 2008

I created a couple of stored procedures. One of them (let's call it SP1) dumps information into a table and then calls another stored procedure (SP2) to put the info in a temp table in crosstab format. SP1 then displays the info from the temp table.

When I execute SP1 from Query Editor, everything works perfectly. No errors are returned and my data is displayed just as expected.

When I try to execute SP1 from MS Access's pass-through query, I get the following error:

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ','.(#102)[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'A'(#102)

I've found that the error occurs when the SP2 is called from within SP1. If it's working fine in Query Editor, shouldn't it work from MS Access? Any insights?

View 2 Replies View Related

Syntax To Access Database On Another Server

Feb 26, 2008

I know how to access different tables on the same server by prefixingthe table with the database name. Is there anyway to prefix theserver name to link two tables across servers? Thanks.

View 2 Replies View Related

Syntax For WHERE Clause For Access Database

Oct 17, 2006

I have used this query statement with a SQL Server 2005 database and need to use something similar with an Access database:

SELECT products.*, Category AS Expr1
FROM products
WHERE (Category = @Category)

When I test this in a table adapter there is no preview due to lack of parameter. I seem to recall that Access uses different syntax in the WHERE filter clause (i.e., not @). Can someone help me out with this?

View 3 Replies View Related

UPDATE Into JOINed Table - Access Vs. SQL Server Syntax

Sep 13, 2007

I am trying to get a SQL statement to work with both Access 2000 and SQL Server 2000.

The statement that works in SQL Server is:

---
UPDATE [myTable2]

SET
[myTable2].[FieldA] = 'Hello',
[myTable2].[FieldB] = 2,
[myTable2].[FieldC] = 'xxx',
[myTable2].[FieldD] = 0

FROM [myTable1] INNER JOIN
(myTable2 INNER JOIN [myTable3]
ON [myTable2].[FieldX]=[myTable2].[FieldY])
ON [myTable1].[FieldZ]=[myTable2].[FieldY]

WHERE ([myTable2].[FieldY]=1)
And ([myTable3].[FieldZ]='xxx');
---


(names have been changed to protect the innocent)


The statement that works in Access is:

---
UPDATE [myTable1] INNER JOIN
(myTable2 INNER JOIN [myTable3]
ON [myTable2].[FieldX]=[myTable2].[FieldY])
ON [myTable1].[FieldZ]=[myTable2].[FieldY]

SET
[myTable2].[FieldA] = 'Hello',
[myTable2].[FieldB] = 2,
[myTable2].[FieldC] = 'xxx',
[myTable2].[FieldD] = 0

WHERE ([myTable2].[FieldY]=1)
And ([myTable3].[FieldZ]='xxx');
---


It seems that neither will accept the other format. Can anyone suggest how I can rearrange the statement so that it works in both?

View 2 Replies View Related

Integration Services :: Correct Syntax To Access A Variable

Sep 30, 2015

I am having trouble finding the correct syntax to access a variable. I have a variable defined in the Variables window: The variable name is formatedDate. The DataType is String.

I am successfully setting the value of the variable in a Execute SQL Task. The SQL is as follows:

SELECT LEFT(CONVERT(VARCHAR, MAX(ReportDate), 120), 10) as formatedDate
from DimReportDates

The Result Set is set to “Single Row” and properly set up. 

No problem so far. I can see with a watch that the variable has the correct value, something like:

‘2015-09-30’

Now, in a subsequent step, a Data Flow Task, I want to access the variable. Actualy it is in the SQL statement of a OLE DB source in the Data Flow… I have the following:

Declare @sDate smalldatetime
SELECT @sDate = xxxxx

I have tried several things substituting xxxxx above, but nothing seems to work. One variation was

 @[User::formatedDate])

 Another was

((DT_WSTR, 10) @[User::formatedDate]).

I think I’m close, but just can’t get it. What is the correct syntax.

View 4 Replies View Related

What Syntax Should I Use To Connect To Access DB (having System Database) Via OPENROWSET?

Aug 9, 2007

MS SQL Server 2005 Express.
I'm trying to connect to Access DB (having System Database) via OPENROWSET.
Everything (client, server and access file) is on local drive.

This works (ODBC):


select *
from openrowset('MSDASQL',
'Driver={Microsoft Access Driver (*.mdb)};Dbq=C:MBK.mdb;SystemDB=C:SECURED.MDW;Uid=me;Pwd=pw;',
'select * from [Mbk]')

This works (Jet.OLEDB):

select *
from opendatasource('Microsoft.Jet.OLEDB.4.0',
'Data Source=C:MBK.mdb;Jet OLEDBystem Database=C:SECURED.MDW;User ID=me;Password=pw;')
...Mbk

This won't work (Jet.OLEDB):

select *
from openrowset('Microsoft.Jet.OLEDB.4.0',
'MS Access;Database=C:MBK.mdb;System Database=C:SECURED.MDW;UID=me;PWD=pw;',
'select * from [Mbk]')

saying ... "Wrong argument".

This won't work (Jet.OLEDB):

select *
from openrowset('Microsoft.Jet.OLEDB.4.0',
'MS Access;Database=C:MBK.mdb;SystemDB=C:SECURED.MDW;UID=me;PWD=pw;',
'select * from [Mbk]')

saying ... "There are no permissions for usage of object C:MBK.mdb". It seems that it simply hasn't found system database file C:SECURED.MDW, cause when I change SystemDB=C:SECURED.MDW to something like BlahBlahBlah=C:SECURED.MDW the same message is shown.

So, what is the right syntax for stating System Database in OPENROWSET query string? And why 'System Database' won't work?

Thank you.

View 1 Replies View Related

ERROR:Syntax Error Converting Datetime From Character String. With Stored Procedure

Jul 12, 2007

Hi All,





i have migrated a DTS package wherein it consists of SQL task.

this has been migrated succesfully. but when i execute the package, i am getting the error with Excute SQL task which consists of Store Procedure excution.



But the SP can executed in the client server. can any body help in this regard.





Thanks in advance,

Anand

View 4 Replies View Related

Getting Server Error Syntax Error Converting The Nvarchar Value 'Sonoma' To A Column Of Data Type Int.

Apr 20, 2007

Hi, all
I'm getting this error at runtime when my page tries to populate a datagrid. Here's the relevant code.
First, the user selects his choice from a dropdownlist, populated with a sqldatasource control on the aspx side:<asp:SqlDataSource ID="sqlDataSourceCompany" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [PayrollCompanyID], [DisplayName] FROM [rsrc_PayrollCompany] ORDER BY [DisplayName]">
</asp:SqlDataSource>
 And the dropdown list's code:<asp:DropDownList ID="ddlPayrollCompany" runat="server" AutoPostBack="True" DataSourceID="sqlDataSourcePayrollCompany"
DataTextField="DisplayName" DataValueField="PayrollCompanyID">
</asp:DropDownList>
Then, I use the selectedindexchanged event to bind the data to the datagrid. Here's that code:
 1 Sub BindData()
2
3 Dim ds As New DataSet
4 Dim sda As SqlClient.SqlDataAdapter
5 Dim strSQL As String
6 Dim strCon As String
7
8 strSQL = "SELECT [SocialSecurityNumber], [Prefix], [FirstName], [LastName], [HireDate], [PayrollCostPercent], " & _
9 "[Phone], [BadgeNumber], [IsSupervisor], [SupervisorID], [IsUser], [IsScout] FROM [rsrc_Personnel] " & _
10 "WHERE ([PayrollCompanyID] = @PayrollCompanyID)"
11
12 strCon = "Data Source=DATASOURCE;Initial Catalog=DATABASE;User ID=USERID;Password=PASSWORD"
13
14 sda = New SqlClient.SqlDataAdapter(strSQL, strCon)
15
16 sda.SelectCommand.Parameters.Add(New SqlClient.SqlParameter("@PayrollCompanyID", Me.ddlPayrollCompany.SelectedItem.ToString()))
17
18 sda.Fill(ds, "rsrc_Personnel")
19
20 dgPersonnel.DataSource = ds.Tables("rsrc_Personnel")
21 dgPersonnel.DataBind()
22
23 End Sub
24

 
I'm assuming my problem lies in line 16 of the above code. I've tried SelectedItemIndex, SelectedItemValue too and get errors for those, as well.
What am I missing?
Thanks for anyone's help!
Cappela07

View 2 Replies View Related

Error 241: Syntax Error Converting Datetime From Character String

Jan 7, 2004

Hi All, can someone help me,
i've created a stored procedure to make a report by calling it from a website.
I get the message error "241: Syntax error converting datetime from character string" all the time, i tryed some converting things but nothig works, probably it is me that isn't working but i hope someone can help me.
The code i use is:


CREATE proc CP_Cashbox @mID varchar,@startdate datetime,@enddate datetime
as
set dateformat dmy
go
declare @startdate as varchar
declare @enddate as varchar

--print "query aan het uitvoeren"

select sum(moneyout) / sum(moneyin)*100 as cashbox
from dbo.total
where machineID = '@mID' and njdate between '@startdate' and '@enddate'
GO



Thanx in front
Cya

View 14 Replies View Related

Snapshot Agent Gives Error: Line38: Syntax Error Near 'tabl'

Oct 1, 2005

Hi all,

View 4 Replies View Related

Alter Table Syntax Error - Anyone Sees The Error?

Nov 24, 2004

Hello,

the following alter table statement:

ALTER TABLE [dbo].[CalCalendar]
ALTER COLUMN [OID] uniqueidentifier NOT NULL PRIMARY KEY NONCLUSTERED

is answered with:

Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'PRIMARY'.

which I consider to be interesting. Anyone has an idea why? I checked documentation but I do not see an error.

Note that:

ALTER TABLE [dbo].[CalCalendar]
ALTER COLUMN [OID] uniqueidentifier NOT NULL

DOES get executed, and

ALTER TABLE [dbo].[CalCalendar]
ALTER COLUMN [OID] uniqueidentifier NOT NULL PRIMARY KEY

produces the same error.

Now, in my understanding this has nothing to do with an index may already exist etc. - the eror indicates a SYNTAX error, before any checking. Makes no sense to me, though, reading the documentation.

So - anyone an idea?

View 4 Replies View Related

[File System Task] Error: An Error Occurred With The Following Error Message: Access To The Path Is Denied

Sep 7, 2007

Hi -

I have an File System Task that copies a file from one directory ot another. When I hard code the target directory (c:dirfile.txt) it works fine. When I change it to a virtual directory (\serverdirfile.txt) I get a security error:

[File System Task] Error: An error occurred with the following error message: "Access to the path '\gracehbtest oS2TMM_Live_Title_000002.xml' is denied.".

Where do I change the security settings?

Thanks - Grace

View 5 Replies View Related

Access Denied Error Message Using Xp_cmdshell To Access Network Share

Jan 14, 2007

When running the following statement in SQL 2005, I get the error message "Access is denied":

exec master.dbo.xp_cmdshell 'TYPE \SERVER-BSHAREFILE.TXT'



The following are true about the network:

The SQL Server is installed on SERVER-A.
SERVER-A and SERVER-B are Windows 2003 servers on the same Windows 2003 domain.
The SQL Server and SQL Server Agent services are running under the domain account SQLSERVICE.
SQLSERVICE is a member of the Domain Admins group.
The Domain Admins group is part of the local Administrators group on SERVER-B.
The SQLSERVICE account has also explicitly been given Full Control to the folder referenced by \SERVER-BSHARE
xp_cmdshell use has been enabled on the SQL Server.


If I run the following command in SQL:

exec master.dbo.xp_cmdshell 'whoami'the following is returned: DOMAINSQLSERVICE
If I change the command to access the c: drive instead of a network drive, it executes successfully.

Can anyone shed some light on why I still cannot access any of the files in this folder using xp_cmdshell?

Tim

View 5 Replies View Related

Integration Services :: Send Mail Task Error - Attempt Was Made To Access Socket In A Way Forbidden By Its Access Permissions

Aug 18, 2015

I have trying to execute the Sendmail task in my development envinorment i face this error..I have given the clear details error message below,Please have a look.

[Send Mail Task] Error: An error occurred with the following error message: "Failure sending mail.  System.Net.WebException: Unable to connect to the remote server  System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions ".Alternatively  i use the  SMTP connection to create the subscription as well,its working properly.

Here we are accessing SMTP connection manager as Virtually.Here in my client network we are using Macafee Anti virus ,We have excluded the Rsconfigration file in the excluded list.I dont know why this problem occures again using Sendmailtask in ssis?

View 2 Replies View Related

SQL Syntax Error

Apr 7, 2007

Hi Guys, I'm hoping somebody can help me with this really frustrating problem that I'm having.......
 I'm developing a peer to peer file sharing application (final year degree project) in which I use a web service & sql database as the management server. For some strange reason, I'm getting an SQL syntax error on some machines but not on others when I call the method to submit a file list to the server (see below for code for the method). Another strange thing is that on different machines, I'm getting a different error. I've seen "incorrect syntax near 'd' ". and also "incorrect syntax near 've' ", while on two other machines it works just fine - It appears that the connection to the webservice and to the database is working just fine on all machines as before this method I have a login which works perfectly and the data is represented in the database.
Does anybody have any pointers or even the slighest idea what can cause an error like this or have seen anything like this before. Hoping to get this sorted pretty soon as the deadline is nearing. All and any help is very much appreciated!!!!
Kevin
public void submitFiles(FileObject[] files, string peerID)
{
foreach (FileObject fo in files)
{ System.Text.StringBuilder submit = new System.Text.StringBuilder("INSERT INTO SharedFiles (FileID, FileName, FileType, FileSize, PeerID) VALUES ('" + fo.guid.ToString() + "', '" + fo.name + "' ,'" + fo.name + "', '" + fo.size + "', '" + peerID + "')");
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(submit.ToString(), con);
try { con.Open();
cmd.ExecuteNonQuery();
 } finally { con.Close(); } 
}
 }

View 2 Replies View Related

SQL Syntax Error

Aug 8, 2007

Hello, I have this sql quiery: sqlcommand2.CommandText = "Select Count(UserIP) From InboundTraffic Where InboundURL Contains('" & SiteDomain(i).ToString & "') and DateTimeReceived > " & Last30Days

 
SiteDomain is placing a string variable such as website.com and Last30Days is a date variable which = now - 30days
Im getting this error "Syntax error (missing operator) in query expression 'InboundURL Contains('website.com') and DateTimeReceived > 7/9/2007 8:20:30 PM'"
 
What am I mising?  THANKS!

View 5 Replies View Related

Syntax Error

Jan 17, 2008

Could someone help me with this error message:
Syntax error converting the varchar value '180 Ways to Walk the Leadership Talk by John Baldoni' to a column of data type int.
Getting error on the Titles.title column.  Tried casting it but it still does not work.  What am I missing? 
CREATE procedure GetRequestInfo@Requestorid int
ASselect distinct requestors.Requestorid, CAST(Titles.title AS VARCHAR(255)), requestors.requestorEmail,Requestors.requestdate, fname, lname, phonenum,StreetAddress1, City, State, Zip,LibraryRequest.ShipDate,LibraryRequest.DueDate,LibraryRequest.ReturnDate,
Cast(DATEPART(m, requestors.requestDate) as Varchar(5)) + '/' +Cast(DATEPART(d, requestors.requestDate) as Varchar(5)) + '/' + Cast(DATEPART(yy, requestors.RequestDate) as Varchar(5)) as 'RequestDate'
from Requestorsjoin Titles on titles.Titleid = requestors.Titleidjoin libraryRequest on LibraryRequest.Titleid = LibraryRequest.Titleidwhere Requestors.requestorid = requestors.requestoridGO

View 2 Replies View Related

Syntax Error In IF ELSE

Apr 17, 2008

Can anyone tell me why I get a syntax error on the THEN and the ELSE?
@Start datetime,@End datetime,@EmailAck bit,@SelectedProcess nvarchar(25)ASBEGINIF @SelectedProcess = 'Monthly' THENUPDATE tblReminderSchedule SETPrintedDate=GETDATE(),[Status]=1FROM  tblReminderSchedule INNER JOIN  tbllOAN ON tblReminderSchedule.lOAN_ID = tbllOAN.lOAN_IDWHERE (tblReminderSchedule.ReminderDate BETWEEN @Start AND @End) AND (dbo.tblReminderSchedule.ReceivedDate IS NULL) AND   (tbllOAN.ReminderByEmail = @EmailAck) AND (tbllOAN.Frequency = 'Monthly')ELSEUPDATE tblReminderSchedule SETPrintedDate=GETDATE(),[Status]=1FROM  tblReminderSchedule INNER JOIN  tbllOAN ON tblReminderSchedule.lOAN_ID = tbllOAN.lOAN_IDWHERE (tblReminderSchedule.ReminderDate BETWEEN @Start AND @End) AND (dbo.tblReminderSchedule.ReceivedDate IS NULL) AND   (tbllOAN.ReminderByEmail = @EmailAck) AND (tbllOAN.Frequency <> 'Monthly')END 

View 4 Replies View Related

Syntax Error

Mar 21, 2004

I am trying to open a table in my DB to check for login ids:

The code I used is below> I will appreciate any help on this matter

<CODE>
Public Function Authorize(ByVal Username As String, ByVal Password As String) As Integer
Dim sql As String
Dim con As New SqlConnection("data source=localhost; initial catalog=Jasist; Integrated Security = SSPI")
sql = "Select * from USER Where User_Name = '" & Username & "' and User_Passwd = '" & Password & "'"
con.Open()
Dim cmd As New SqlCommand(sql, con)
Dim Id1 As Integer
Dim dr As SqlDataReader = cmd.ExecuteReader
If dr.Read Then
Id1 = 1
con.Close()
dr.Close()
Return Id1
Else
con.Close()
dr.Close()
Return 0
End If
End Function
<CODE>



THE ERROR GENERATED WAS->

Server Error in '/Jasist' Application.
--------------------------------------------------------------------------------

Incorrect syntax near the keyword 'USER'.
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: Incorrect syntax near the keyword 'USER'.

Source Error:


Line 19: con.Open()
Line 20: Dim cmd As New SqlCommand(sql, con)
Line 21: Dim Id1 As Integer
Line 22: Dim dr As SqlDataReader = cmd.ExecuteReader
Line 23:


Source File: C:InetpubwwwrootJasistClass1.vb Line: 21



--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

View 2 Replies View Related

Syntax Error

Mar 27, 2001

Hi, hope someone can spend a minute checking out my script error. The following is part of my SQL statement. It has got syntax error near "="
I was hoping the script could run 100 times and print number 1 to 100.

DECLARE @ID int
SET @id = 1
EXEC (' WHILE ' + @id + ' <= 100 ' + ' BEGIN SELECT ' + @id +
' SET ' + @id + ' = ' + @id + ' + 1 ' + ' END ' )

Any input is most welcome.


Richard

View 4 Replies View Related

Need Help With Syntax Error.

Oct 17, 2000

Can anyone tell me what is wrong with the script below?

INSERT INTO #SUBSCRIBERLIST(EMEMBER_GUID,EHBSID)SELECT (M.EMEMBER_GUID,@EHBSID)
FROM EMEMBER M WHERE M.EMEMBER_GUID = @EM_ID1 AND M.MEMBERTYPE <>1

This is the error I am getting.

Server: Msg 170, Level 15, State 1, Line 5
Line 5: Incorrect syntax near ','.


Thanks in advance.

Matt

View 1 Replies View Related

Syntax Error Near '='

Aug 31, 2004

hi
i am getting this error while running SQL query : syntax error near '='

Query is :

SELECT People.People, People.Name,
Sum(([ProjectStatusReport].[Week]), 0, ([ProjectStatusReport].[Week] = #8/27/2004#, 1, 0)) AS Created,
Sum((ProjectStatusReport.Week), 0, (ProjectStatusReport.Week = #8/27/2004#, (ProjectStatusReport.Accomplishments) Or (ProjectStatusReport.Plans), 0, 1, 0)) AS Complete,
People.email FROM Register INNER JOIN SR_Status ON Register.SR_Status = SR_Status.SR_Status
LEFT JOIN ProjectStatusReport ON Register.Register = ProjectStatusReport.Project INNER JOIN StakeHolders
ON Register.Register = StakeHolders.Register INNER JOIN People ON StakeHolders.People = People.People
WHERE SR_Status.Status='Active' AND StakeHolders.Status = 'Yes' GROUP BY People.People, People.Name, People.email
HAVING (Sum(ProjectStatusReport.Week), 0, ((ProjectStatusReport.Week) = #8/27/2004#, 1, 0) > 0))
AND Sum(ProjectStatusReport.Week),0,((ProjectStatusRep ort.Week) = #8/27/2004#,(ProjectStatusReport.Accomplishments) Or (ProjectStatusReport.Plans),0,1,0)>0
ORDER BY People.People

Any help

Regards

View 2 Replies View Related

Syntax Error

Feb 6, 2007

Hi All,

When I run the following portion of my stored procedure, I get the following error message:

Server: Msg 241, Level 16, State 1, Line 1
Syntax error converting datetime from character string.

Here is the script:

set @dttimestr = 'select @dttime = substring(convert(varchar(11),getdate(),120),1,4)+
substring(convert(varchar(11),getdate(),120),5,3)'

EXECUTE sp_executesql @dttimestr, N'@dttime datetime output', @dttime output
print @dttime

Can you please tell me how to fix it?

View 3 Replies View Related

Syntax Error...

Jul 1, 2004

Quick question..

SELECT * FROM Table_1
INTERSECT
SELECT * FROM Table_2
INTERSECT
SELECT * FROM Table_3;

Syntax error in FROM clause, and it highlights the second select.. whats wrong with this statement? does it not like the *'s?

Thx

View 2 Replies View Related

Syntax Error

Sep 14, 2004

I get the following errors with the script below:

I am novice with SQL and have been unable to figure out the syntax just yet. The line for the errors are marked blue

Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'user'.
Server: Msg 170, Level 15, State 1, Line 26
Line 26: Incorrect syntax near '='.
Server: Msg 170, Level 15, State 1, Line 29
Line 29: Incorrect syntax near 'auto_increment'.
Server: Msg 170, Level 15, State 1, Line 44
Line 44: Incorrect syntax near '='.
Server: Msg 170, Level 15, State 1, Line 53
Line 53: Incorrect syntax near '='.

-----------------------------------------------------------

CREATE TABLE admin (
user varchar(100) NOT NULL default,
pass varchar(100) NOT NULL default ''
) TYPE=MyISAM;

INSERT INTO admin VALUES ( 'admin', 'pass456');

CREATE TABLE affiliates (
refid varchar(30) NOT NULL default '',
pass varchar(20) NOT NULL default '',
company varchar(100) NOT NULL default '',
title varchar(5) NOT NULL default '',
firstname varchar(40) NOT NULL default '',
lastname varchar(40) NOT NULL default '',
website varchar(100) NOT NULL default '',
email varchar(100) NOT NULL default '',
payableto varchar(100) NOT NULL default '',
street varchar(100) NOT NULL default '',
town varchar(100) NOT NULL default '',
county varchar(100) NOT NULL default '',
postcode varchar(20) NOT NULL default '',
country varchar(100) NOT NULL default '',
phone varchar(30) NOT NULL default '',
fax varchar(30) NOT NULL default '',
date varchar(40) NOT NULL default ''
) TYPE=MyISAM;

CREATE TABLE banners (
number int(3) NOT NULL auto_increment,
name varchar(50) NOT NULL default '',
image varchar(60) NOT NULL default '',
description varchar(200) NOT NULL default '',
PRIMARY KEY (number)
) TYPE=MyISAM;

CREATE TABLE clickthroughs (
refid varchar(20) default 'none',
date date NOT NULL default '0000-00-00',
time time NOT NULL default '00:00:00',
browser varchar(200) default 'Could Not Find This Data',
ipaddress varchar(50) default 'Could Not Find This Data',
refferalurl varchar(200) default 'none detected (maybe a direct link)',
buy varchar(10) default 'NO'
) TYPE=MyISAM;

CREATE TABLE sales (
refid varchar(20) NOT NULL default '',
date date NOT NULL default '0000-00-00',
time time NOT NULL default '00:00:00',
browser varchar(100) NOT NULL default '',
ipaddress varchar(20) NOT NULL default '',
payment varchar(10) NOT NULL default ''
) TYPE=MyISAM;

HELP!

View 1 Replies View Related







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