Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Why this script doesnt work?

Author  Topic 

raulbolanos
Starting Member

6 Posts

Posted - 2009-06-15 : 07:28:20
Hi guys,

I am very new in this subject.

I want to run a simple procedure in MySQL Query Browser (or SQLyog) but I cannot make it work, I get immediately an 1064 Error. How should I start my script? What about this.

Use rauldb;
IF (select AVG(count) as hola from tiempo) > 1
BEGIN
PRINT 'uhm'
END
ELSE
PRINT 'ohh'

Did I something wrong?

best regards,
Rail

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-06-15 : 07:41:12
Are you using MYSQL?

This is a forum for Microsoft SQL server. You should try DBForums (http://www.dbforums.com/) they've got a good section for MySql.

It's not that we don't want to help, you'll just get better help there.

All the best,


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-15 : 07:42:59
IF (select AVG(count) as hola from tiempo) > 1
BEGIN
PRINT 'uhm'
END
ELSE
PRINT 'ohh'


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-06-15 : 07:45:26
Hi Peso,

Why the change (remove the AS)? is that MySQL syntax? The following code works on my 2005 box:

DECLARE @foo TABLE (
[count] INT
)

INSERT @foo SELECT 1 UNION SELECT 3 UNION SELECT 15

IF (select AVG(count) as hola from @foo) > 1
BEGIN
PRINT 'uhm'
END
ELSE
PRINT 'ohh'

-- well it runs anyway. I'd never use a Keyword (COUNT) like that.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-15 : 08:31:24
Yes, the code runs but there is no need to alias the aggregated value.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -