Monday, February 20, 2012

MSSQL Mistake

I have piece of code- SET @.UserID = @.@.ROWCOUNT and it's said that there is m
istake, where it is?"juokaz" <juokaz.23brpu@.mail.codecomments.com> wrote in message
news:juokaz.23brpu@.mail.codecomments.com...
> I have piece of code- SET @.UserID = @.@.ROWCOUNT and it's said that there
> is mistake, where it is?
>
> --
> juokaz
> ---
> Posted via http://www.codecomments.com
> ---
This is valid SQL.
What's the error message?|||declare @.UserID uniqueidentifier
SET @.UserID = @.@.ROWCOUNT
SELECT @.UserID
this will throw an error yes, assuming your @.UserID is an int this
should work
What I do not understand is how userid and rowcount have anything in
common?
maybe you are looking for one of these 4?
select user_id(),suser_sid(),suser_sname(),user
_name()
http://sqlservercode.blogspot.com/|||I have only this piece of code and its said that there is mistake, it's exce
rcise, so i dont have full code.
quote:
Originally posted by SQL
declare @.UserID uniqueidentifier
SET @.UserID = @.@.ROWCOUNT
SELECT @.UserID
this will throw an error yes, assuming your @.UserID is an int this
should work
What I do not understand is how userid and rowcount have anything in
common?
maybe you are looking for one of these 4?
select user_id(),suser_sid(),suser_sname(),user
_name()
http://sqlservercode.blogspot.com/

|||Unless you provide more SQL code we can only say that this is valid SQL
so far.
HTH, Jens Suessmeyer.|||Just as one of the posters mentioned before - the only flaw is the assignmen
t
of an integer value to the variable of an incompatible data type
(uniqueidentifier).
Is that it? Then, change the declaration of UserID and use a compatible data
type (any numeric type or a character type).
ML
http://milambda.blogspot.com/|||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...
quote:
Originally posted by ML
Just as one of the posters mentioned before - the only flaw is the assignmen
t
of an integer value to the variable of an incompatible data type
(uniqueidentifier).
Is that it? Then, change the declaration of UserID and use a compatible data
type (any numeric type or a character type).
ML
http://milambda.blogspot.com/

|||No ideas?
quote:
Originally posted by juokaz
Bad thing - it's excercie, i have only this piece of code, and in excercise it is said t
hat to complete you mustnt have mssql knowledge...

|||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 mistak
e to drink petrol? Well,
it is possible. And since we know about the semantics (we all know a bit abo
ut the human physiology)
we can say that it is probably it is a mistake. But you have provided us wit
h no semantics at all.
So all we can say that it is possible to execute the code with no errors. Yo
u have also been given
proof of it.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"juokaz" <juokaz.23fh1o@.mail.codecomments.com> wrote in message
news:juokaz.23fh1o@.mail.codecomments.com...
> No ideas?
> juokaz wrote:
>
> --
> juokaz
> ---
> Posted via http://www.codecomments.com
> ---
>|||maybe some one could tell then, what this code would actually do? whats
the result?
what troubles such code could cause?
thanks.

No comments:

Post a Comment