You are here: trouble porting a trivially simple function - with declared variables « MsSQL Server « IT news, forums, messages
trouble porting a trivially simple function - with declared variables

Posted by Ted on 08/04/06 20:21

Here is one such function:

CREATE FUNCTION my_max_market_date () RETURNS datetime
BEGIN
DECLARE @mmmd AS datetime;
SELECT max(h_market_date) INTO @mmmd FROM holdings_tmp;
RETURN @mmmd;
END

One change I had to make, relative to what I had working in MySQL, was
to insert 'AS' between my variable and its type. Without 'AS', MS SQL
insisted in telling me that datetime is not valid for a cursor; and I
am not using a cursor here. The purpose of this function is to
simplify a number of SQL statements that depend on obtaining the most
recent datetime value in column h_market_date in the holdings_tmp
table.

The present problem is that MS SQL doesn't seem to want to allow me to
place that value in my variable '@mmmd'. I could do this easily in
MySQL. Why is MS SQL giving me grief over something that should be so
simple. I have not yet found anything in the documentation for SELECT
that could explain what's wrong here. :-(

Any ideas?

Thanks

Ted

 

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

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