You are here: Re: What's wrong in this query ? « MsSQL Server « IT news, forums, messages
Re: What's wrong in this query ?

Posted by Hugo Kornelis on 10/02/99 11:48

On 23 May 2006 20:19:56 -0700, Radu wrote:

>Hi. I have a SP named, for instance, SP1.
>
>I need to execute something like
>
>SELECT Sum([Field1]) FROM SP1 WHERE [SP1].[Field1]='0'
>
>and I get the message:
>
>Server: Msg 208, Level 16, State 3, Line 1
>Invalid object name 'SP1'.
>
>However, SP1 *IS THERE* and runs fine !!!

Hi Alex,

I hope that you are not really trying to sum a character column or
comparing a numeric column to a string constant. And I also hope that
you're not really writing a query to calculate the SUM of lots of
zeroes. <g>

You can only include tables and views in a FROM clause, not stored
procedures.

Try it like this:

CREATE TABLE #temp
(Co1umn1 .....,
....)

INSERT INTO #temp (Column1, ...)
EXECUTE SP1

SELECT whatever
FROM #temp
WHERE Column1 = 0

--
Hugo Kornelis, SQL Server MVP

 

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

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