You are here: Trying to do REALLY simple procedure and loop in SQL Server « MsSQL Server « IT news, forums, messages
Trying to do REALLY simple procedure and loop in SQL Server

Posted by dba_222 on 08/16/06 00:35

Dear experts,

Again, sorry to bother you again with such a seemingly dumb question,
but I'm having some really mysterious results here.

ie.

Create procedure the_test
As


Begin

Select CustomerID
>From dbo.customers

-----------------------------*/
Server: Msg 170, Level 15, State 1, Procedure the_test, Line 8
Line 8: Incorrect syntax near 'customers'.

Just WHAT is the syntax please?????


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

Then, this started as trying to write a procedure with a cursor.
Open cursor, loop, print, end loop. End of story.

This actually goes into an infinite loop!!!
Can anyone tell me what is wrong here?




Create procedure test2
As

Declare all_cust cursor for
Select customerid,
Companyname,
ContactName
>From customers


Declare
@Customerid varchar(5),
@Companyname varchar(40),
@ContactName varchar(30)



Begin

Select count(*)
>From customers


Open all_cust

Fetch all_cust
Into @customerid,
@Companyname,
@ContactName


While @@fetch_status = 0

Print @customerid


Fetch all_cust
Into @customerid,
@Companyname,
@ContactName

End /* while */


Close all_cust

Deallocate all_cust





Believe it or not, I'm just copying simple programs off the web,
including the Microsoft website, with slight modifications!!!!!!
Crazy!!!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация