.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Post New Web Links

Msg 156, Level 15, State 1, Line 7 Incorrect syntax near the keyword 'FROM'.

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :
 

I am a student taking SQL classes and am having this error message with this SQL Script:

 

SELECT c.State, i.itemType,
        Cast(Year(o.orderDate) as Varchar) + N'-' +
        Cast((Month(o.orderDate) -1) / 3 + 1 as Varchar)
            as YearQuarter,
        Round((od.quantity * od.price)*(1-od.discount)
            as Sales
FROM Consumers c, Orders o, OrderLines od, inventory i
WHERE c.ConsumerId = o.ConsumerID and
        od.orderID = o.orderID and
        i.inventoryID = od.inventoryID;

 

any idea from that on what I am doing wrong? I'm thinking it's something simple.





View Complete Post


More Related Resource Links

Another ERROR Message Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'COLUMN'

  

Ok, I would like to ask you this if I may,

On another database I created a table named FICTION

and the table looks like this:

CREATE TABLE FICTION
 (BOOK_CODE CHAR(4) PRIMARY KEY,
 TITLE CHAR(40),
 PUBLISHER_CODE CHAR(3),
 PRICE DECIMAL(4,2) );

Now I am trying to change the data type in TITLE to CHAR(50)

ALTER

 

TABLE FICTION

MODIFY

 

COLUMN TITLE

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

  

Hi,

Recently received a trace file from customer of sql server which shows some errors in SQL statement but the front-end application is working fine.

I see SET FMTONLY ON and SET FMTONLYOFF and an additional WHERE clause. The statement looks like:

SET FMTONLY ON SELECT PLANCODE.SYSCODE, PLANCODE.CODE, PLANCODE.NAAM

Msg 102, Level 15, State 1, Line 12 INCORRECT SYNTAX NEAR ')'

  
CREATE Table Item(
ItemID    numeric(18,2)  PRIMARY KEY,
VendorID   numeric(18,0)  NOT NULL,
ItemDescription  Char(50)   NULL,
PurchaseDate  DateTime   NOT NULL,
ItemCost   numeric(18,2)  NOT NULL,
ItemPrice   numeric(18,2)  NOT NULL,
 CONSTRAINT Item_FK FOREIGN KEY (VendorID)
  REFERENCES Vendor(VendorID)
  ON DELETE CASADE
  
);      <<<<HERE IS THE ERROR

Msg 102, Level 15, State 1, Line 2 Incorrect syntax near 'MODIFY'

  
OK, TRYING TO UPDATE [MODIFY] AN EXISTING TABLE NONAPPLIANCE

HERE IS MY STATEMENT:

ALTER TABLE NONAPPLIANCE
MODIFY DESCRIPTION CHAR(30);

IT IS GIVING ME AN ERROR:

Msg 102, Level 15, State 1, Line 2 Incorrect syntax near 'MODIFY'.

WHAT AM I DOING WRONG?

Msg 102, Level 15, State 1, Line 1 ,Incorrect syntax near '='

  

i am getting the error Msg 102, Level 15, State 1, Line 1 ,Incorrect syntax near '=' when i executing the query :-

insert

into author values(Ano=3,Author='Bannu',Addr='Delhi',Book='Hum-Tum')

Msg 50000, Level 16, State 1, Line 34

  

Hi,

I get the following error:

Msg 50000, Level 16, State 1, Line 34
An error occurred in the Microsoft .NET Framework while trying to load assembly id 65669. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:
System.IO.FileLoadException: Could not load file or assembly 'capsqlextensions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An error relating to security occurred. (Exception from HRESULT: 0x8013150A)
System.IO.FileLoadException:
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Ass

Msg 10301, Level 16, State 1, Line 1

  
Hi, I am trying to register Excel that should be located at: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 in order to: CREATE ASSEMBLY Excel FROM 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Office.Interop.Excel.dll' But there is no: 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Office.Interop.Excel.dll' Where could I find that? Regards, Jos

LINQ to SQL "Incorrect syntax near the keyword 'WHERE'"

  

I am having a problem that creeps up over and over when using LINQ to SQL.  I am getting the error: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'WHERE'.

Now I have done a great deal of digging, and the only cause I can seem to find is when users are overriding the Equals() or GetHasCode() methods of the generated classes.  I am not overriding either.  I am getting this error on two different project with two different databases.  I have tried everything every post I have found suggests.  I have even scrapped my dbml file and re-created, all to no avail.

Anyone have any thoughts?  They would be greatly appreciated!


Thanks,
Ryan Sakry
Program Manager
Retail Information Technology Enterprises
1-888-267-RITE
rsakry@rite.us
http://www.rite.us

Line 1: Incorrect syntax near ','. Unclosed quotation mark before the character ...

  

Can someone please review my code and see where I can be missing information. I get the following error:

Line 1: Incorrect syntax near ','. Unclosed quotation mark before the character string ' )'. at System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQuer yTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNo nQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at _Default.SaveToDatabase(String SavePath) in C:\Inetpub\wwwroot\Webfile1\Default.aspx.vb:line 78


Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub
    Protected Sub Submit1_Click(ByVal sender

Msg 137, Level 15, State 2, Procedure AddCMEXperience, Line 49 Must declare the scalar variable "@Re

  

Hi folks, can someone please help me with this error?

Msg 102, Level 15, State 1, Procedure AddCMEXperience, Line 15
Incorrect syntax near ','.


Msg 137, Level 15, State 2, Procedure AddCMEXperience, Line 49
Must declare the scalar variable "@ReasonLeft".


Here is the Stored Procedure that is in question here

USE [ResponsedDatabase]
GO
/****** Object:  StoredProcedure [dbo].[AddNewEmployer]    Script Date: 10/03/2010 14:24:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[AddCMEXperience]
(
    @MemberID bigint,
    @EmployerID bigint,
    @DateStarted smalldatetime,
    @IsContinuing bit,
    @DateLeft smalldatetime,
    @PositionStarted nvarchar(50),
    @PositionLeft nvarchar(50),
    @StartingSalary nvarchar(20),
    @EndingSalary nvarchar(20),
    @TimeWorked float,
    @JobResponsibilities text,
    @ReasonLeft, nvarchar(200)
)

AS

INSERT CMExperience
(
    MemberID,
    EmployerID,
 &nbs

Incorrect syntax near the keyword 'where'

  

When I use the sqldatasource select paremeters like that:

<asp:SqlDataSource ID="dtsrcHotAreaLabor" runat="server"
        ConnectionString="<%$ ConnectionStrings:ContentMiningConnectionString %>"
        SelectCommand="SELECT * FROM [HotAreaLabors] ORDER BY [Date] where [UserAlias]=@UserAlias"
         UpdateCommand="UPDATE [HotAreaLabors] set [Date]=@Date,[LaborType]=@LaborType,[Comments]=@Comments where [lid]=@lid and [UserAlias]=@UserAlias"
         
        DeleteCommand="DELETE FROM [HotAreaLabors] WHERE [lid]=@lid and [UserAlias]=@UserAlias"
        onselecting="dtsrcHotAreaLabor_Selecting">
         <SelectParameters>
         <asp:Parameter  Type="String" Name="UserAlias"/>
         </SelectParameters>
         <UpdateParameters>
         <asp:Parameter

Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value when using JO

  

I am having a bit of time with a lab I am doing for school when I write the query this way there is no problems, it does what I want it to do. (I have tried to edit this to give the right formatting but it just is not working)

 

select

 employeeName
from

 employee
where

 employeeInitials in


(select

 employeeInitials
from

 service
where

 propertyId in


(select

 propertyID
from

 property
where

 propertyState = 'NY'

));

 

however, when I am answering the question to do that same query but using join instead of a sub I get an error.

 

select

 employeeName
from

 employee as

 emp join

 service as

 srv
on

 emp.employeeName = 

Msg 8152, Level 16, State 14, Procedure HAM_User_Productive_Time, Line 20 String or binary data woul

  

I have this procedure and table architecture - My ultimate moto is to check the User Start time and user end time and if user is logged in into 2 pcs at once then capturing the min start time and max end time . If user start time is greater than users previous end time then creating a new entry into table.

Alter

 

Procedure dbo.HAM_User_Productive_Time

As

BEGIN

Declare

 

@Min Datetime

Index Rebuild failing with sql error msg 8966, level 16, state 2, line 20

  

Working with a customer trying to help him re-index his database. Database is a little over a terabyte and I gave him a re-indexing script to run on his SQL Server 2005 Enterprise server.

FYI
It had been recommended by a 3rd party load testing company that all of our re-indexing be done in "offline" mode so the re-indexing was done in offline mode for this customer.

The first reindex attempt stopped with a "severe" error message in the "query window" when sql reached the largest table in the system, which I found out contains about 29 milliion rows. The previous indexes had been successfully rebuilt or reorganized based on the percentage of fragmentation.

I asked for the sql error logs and found the "severe" error message written to the log around the time of a "sql server restart". I asked the customer and he admitted to restarting sql server. I suspected that the reindex script had not completed but could not be sure.

I decided to approach it next by rebuilding the index on the huge table only. He called me the next day and told me the rebuild had failed. He sent me the error logs and he also informed me he had killed the index query after it had been running for over 24 hours.

I found some IO errors in the sql error logs referring to "15 seconds" had been exceeded a

Msg 10011, Level 16, State 1, Line 1

  
I received the error Msg 10011, Level 16, State 1, Line 1 when i try to add server role like sysadmin a login. kindly help
Omojuwa Raymond

Msg 10011, Level 16, State 1, Line 1

  
I received the error Msg 10011, Level 16, State 1, Line 1 when i try to add server role like sysadmin a login. kindly help
Omojuwa Raymond

Incorrect syntax near 'GO' error while running a sql script ?

  

I am using Visual Studio 2008

I have one Database A

now i want to create Database B just like Database A

I generated a script of Database A

and created fresh Database B

Now, when i try to run the generated script against Database B, i get this error, why ? how to fix it ?

sql error



For your information:

I have checked in my script it is:

SET ANSI_NULLS ON
GO

and i have also tried to save the sql script in notepad as: ANSI, UTF-8 and UNICODE

and then i copied from txt file to query but still doesn't work and getting the same error


and these are the option that i selected/used while creating my script:

s



Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend