Showing posts with label username. Show all posts
Showing posts with label username. Show all posts

Wednesday, March 28, 2012

Query works - sproc fails

I have a query that works fine but fails as a sproc.

QUERY:

SELECT UserName, ProfileId, FirstName, LastName

FROM dbo.CustomProfile JOIN dbo.aspnet_Users

ON dbo.CustomProfile.UserId = dbo.aspnet_Users.UserId

WHERE UserName = 'Brown'

SPROC:

set ANSI_NULLS ON

set QUOTED_IDENTIFIER ON

GO

ALTER PROCEDURE [dbo].[GetProfileId]

@.UserName nvarchar

AS

SELECT UserName, ProfileId, FirstName, LastName

FROM dbo.CustomProfile JOIN dbo.aspnet_Users

ON dbo.CustomProfile.UserId = dbo.aspnet_Users.UserId

WHERE UserName = @.UserName

The query returns results. In SQL Server Management Studio when I execute the sproc and enter the value Brown the sproc returns no values; i.e. 0

Set a size to the parameter. That might help.

|||

kerchunk!

That did it. Thanks!

Monday, February 20, 2012

Query strings that dont start with a letter

I have a table in Sql Server 2000 called Users. The field in question here is "Username". I need to create a query that returns "Usernames" that starts with anything other than letters from the alphabet. For example: numerics, -, !, # and so on...

Does anyone know how to do this?

Thanks alot!Hi DrEaMON,
1.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_la-lz_115x.asp
LIKE statement syntax

2.
select UserName
from Users
where UserName like '[^A-Z]%'|||Thank you! That's exactly what I needed.

You learn something new every day huh!?!