You are here: Re: general question « MsSQL Server « IT news, forums, messages
Re: general question

Posted by Roy Harvey on 07/26/07 19:35

If I had to choose just one it would have to be SELECT simply because
there are times SET will not do the job.

One more point that I did not see coverd in the article linked by
Jason. It is common to want to retrieve both the @@error and
@@rowcount values resulting from a command. To get both and save them
to @variables (commonly @error and @rowcount) you MUST use SELECT, as
the @@values are destroyed by the first command that retrieves them.

I use SET to assign a constant, or perhaps increment a counter, but
use SELECT when the data comes from a query or is otherwise more
complicated. But I don't pretend that is "best practice", as I don't
believe there is a clear best here.

Roy Harvey
Beacon Falls, CT

On Thu, 26 Jul 2007 10:59:17 -0700, "MikeJ"
<vettes_n_jets@sbcglobal.net> wrote:

>hi...i would like to know best practice when assigning a value to a variable
>example below
>
>set
>or
>select
>
>declare @var1 varchar(25)
>set @var1='abc'
>select @var1='abc'
>
>to me
> set is implicit
> select implies conditions
>
>i see both used all over the place here at my new company....
>so witch is better practice
>
>tks
>MJ
>
>

 

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

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