Home All Groups Group Topic Archive Search About
Author
18 Feb 2006 11:31 AM
juokaz
No ideas?

juokaz wrote:
Show quote
> *Bad thing - it's excercie, i have only this piece of code, and in > excercise it is said that to complete you mustnt have mssql > knowledge... * -- juokaz ------------------------------------------------------------------------ Posted via http://www.codecomments.com ------------------------------------------------------------------------

Author
18 Feb 2006 2:11 PM
Tibor Karaszi
Exactly what is it that you want from us? The code executes fine, as already have been posted here,
provided you declare the @UserID variable first. Here is proof:

DECLARE @UserID int
SET @UserID = @@ROWCOUNT

Execute above against SQL Server and you will see no errors.

But if you ask if there is a "mistake", we can't answer that. Is it a mistake to drink petrol? Well,
it is possible. And since we know about the semantics (we all know a bit about the human physiology)
we can say that it is probably it is a mistake. But you have provided us with no semantics at all.
So all we can say that it is possible to execute the code with no errors. You have also been given
proof of it.

Show quote
"juokaz" <juokaz.23f***@mail.codecomments.com> wrote in message
news:juokaz.23fh1o@mail.codecomments.com...
>
> No ideas?
>
> juokaz wrote:
>> *Bad thing - it's excercie, i have only this piece of code, and in
>> excercise it is said that to complete you mustnt have mssql
>> knowledge... *
>
>
>
> --
> juokaz
> ------------------------------------------------------------------------
> Posted via http://www.codecomments.com
> ------------------------------------------------------------------------
>
Author
25 Feb 2006 11:08 PM
elonas
maybe some one could tell then, what this code would actually do? whats
the result?
what troubles such code could cause?

thanks.
Author
26 Feb 2006 3:23 AM
Roger Wolter[MSFT]
The problem here is that this is totally valid from a SQL syntax perspective
but if you assume that the @userid is supposed to contain the ID of a user,
it doesn't make sense.  The writer of the code probably intends to use the
@userid variable to identify a user which means you would need to put an
integer that corresponds to the ID of a database user and instead he is
putting the number of rows returned by the previous SQL statement into the
variable.  You should probably tell your professor that the question is
pretty bad because there's not enough information there to say whether the
statement is correct or not.  If the next statement is SELECT * FROM
sys.sysusers where uid = @UserID then this results won't make a lot of sense
but if the next statement is IF @UserID = 0 RETURN then it will work even
though the choice of variable name doesn't make a lot of sense.  Also, the
people in this group are generally taking time out from their full-time jobs
to help people out with real database problems so it's probably not fair to
ask them to do you homework for you.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

<elo***@gmail.com> wrote in message
Show quote
news:1140908893.084133.246620@z34g2000cwc.googlegroups.com...
> maybe some one could tell then, what this code would actually do? whats
> the result?
> what troubles such code could cause?
>
> thanks.
>

AddThis Social Bookmark Button