Posted on: 11/9/2012 7:42:55 PM | Views : 440

Greetings community,
This is beginner's question, so don't be hard on me if it's something basic. I'm still learning.
I made simple function that's supposed to get me user's ID when I pass it user name. It's like this
ALTER FUNCTION [dbo].[fGetUserIDByName](@UserName [nvarchar]) RETURNS [int] AS BEGIN DECLARE @Result int; SELECT @Result = ID from dbo.Users WHERE UserName =@ UserName; RETURN @Result END It works of course, because user name and ID are unique values, but I don't really understand how. I declared result as single integer value. If I did the same thing inside .NET app, I'd get error, because this select statement actually returns collection of integers.
So how SQL server worked around this, and what would happen, if I asked user's nickname, or city, or anything el ...

Go to the complete details ...