Showing posts with label syntax. Show all posts
Showing posts with label syntax. Show all posts

Friday, March 30, 2012

I get "Line 1: Incorrect syntax near ')'." when using SqlClient ExecuteScalar

Hi Marc,

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

ExecuteNonQuery method.

can you guide me about solving this issue?

Regards,

Anni

Anni wrote:

Hi Marc,

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

ExecuteNonQuery method.

can you guide me about solving this issue?

Regards,

Anni

Hi Anni,

There must be sth wrong in your procedure. Pls paste the whole procedure here and you'll get your answer.

|||Yes, this is just a sql syntax error. Usually it is best to get the sql and try to run it from query analyzer (or SQL Server Management Studio) until you get the syntax correct.

Monday, March 12, 2012

i am trying to move from Access db to Sql.s

hello

i am trying to move from Access db to Sql.s

could you please what is rwong in the sql.s syntax:

Access SP:-

PARAMETERS [@.Date_M_Y] DateTime, [@.BIZID] Long;
SELECT SUM(MINUTE(Time_)) AS MM, SUM(HOUR(Time_)) AS HH, COUNT(Date_) AS SHIFTS, SUM(Money_Sum) AS MONEY_TOTAL, AVG(Money_Sum) AS AVG_MONEY_PER_SHIFT
FROM TblTimeSum
WHERE MONTH(Date_)=MONTH([@.Date_M_Y]) And YEAR(Date_)=YEAR([@.Date_M_Y]) And BIZID=[@.BIZID];

-- SQL.S-

CREATE PROCEDURE SP_SUM

@.Date_M_Y smalldatetime,

@.BIZID int

AS

BEGIN

SELECT SUM(MINUTE(Time_)) AS MM, SUM(HOUR(Time_)) AS HH, COUNT(Date_) AS SHIFTS, SUM(Money_Sum) AS MONEY_TOTAL, AVG(Money_Sum) AS AVG_MONEY_PER_SHIFT

FROM TblTimeSum

WHERE MONTH(Date_)=MONTH([@.Date_M_Y]) And YEAR(Date_)=YEAR([@.Date_M_Y]) And BIZID=[@.BIZID]

END

GO

thanks

I don't believe that T-SQL has a Minute function. Try using the DATEPART function in place of the MINUTE function.

See: http://msdn2.microsoft.com/en-us/library/ms174420.aspx

|||

I think that this has been answered in the Transact-SQL forum.

Often, the quality of the responses received is related to our ability to ‘bounce’ ideas off of each other. In the future, to make it easier for us to offer you assistance, and to prevent folks from wasting time on already answered questions, please don't post to multiple newsgroups. Choose the one that best fits your question and post there. Only post to another newsgroup if you get no answer in a day or two (or if you accidentally posted to the wrong newsgroup –and you indicate that you've already posted elsewhere).

|||

Arnie Rowland wrote:

I think that this has been answered in the Transact-SQL forum.

Often, the quality of the responses received is related to our ability to ‘bounce’ ideas off of each other. In the future, to make it easier for us to offer you assistance, and to prevent folks from wasting time on already answered questions, please don't post to multiple newsgroups. Choose the one that best fits your question and post there. Only post to another newsgroup if you get no answer in a day or two (or if you accidentally posted to the wrong newsgroup –and you indicate that you've already posted elsewhere).

Yes this is very tasteful, welcoming, and polite. It directly answers the original question and promotes deep thought. A good example of the quality found within. If each of us posted this rude comment, the world would be a better place to live but I guess that's how MVP status is obtained.

Let's pass the love forward.

Very nice Arnie. Keep it up.

|||

Yes the date and time functions need to be acheived through a CONVERT() format.

Adamus

Friday, March 9, 2012

I am getting Line 202:Incorrect syntax near 'end'"

Hi Marc,

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

ExecuteNonQuery method.

can you guide me about solving this issue?

Regards,

Anni

Anni wrote:

Hi Marc,

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

ExecuteNonQuery method.

can you guide me about solving this issue?

Regards,

Anni

Hi Anni,

There must be sth wrong in your procedure. Pls paste the whole procedure here and you'll get your answer.

|||Yes, this is just a sql syntax error. Usually it is best to get the sql and try to run it from query analyzer (or SQL Server Management Studio) until you get the syntax correct.