Thursday, March 8, 2012

A simple varchar comparison

First, Hi to all I'm new to this forum.
Second, I don't know if standard SQL involves stored procedures, but anyway I'll post my doubt.
I have chessy little procedure to get a password from a login. login is a varchar

CREATE PROCEDURE getPassw
@.login as varchar
AS
SELECT T_Worker.pass
FROM T_Worker
WHERE T_Worker.login = @.login

If I try " exec getPassw 'abc' ", I never get anything. The data exists in the tables. If I do something like

CREATE PROCEDURE getPassw
/*@.login as varchar*/
AS
SELECT T_Worker.pass
FROM T_Worker
WHERE T_Worker.login = 'abc'

The password shows up : '456' .
If I remove the '@.' from the WHERE query, all columns are returned... ?!?!? :confused:
I running the commands on a Microsoft's SQL server. Thank you for your attention. Any help would be seriously apreciated.This post really belongs in the Microsoft SQL (http://www.dbforums.com/f7/) forum.

I think the only problem is that you didn't cut yourself enough rope... You need to make the parameter longer, like:CREATE PROCEDURE getPassw
@.login as varchar(50)
AS

SELECT T_Worker.pass
FROM T_Worker
WHERE T_Worker.login = @.login

RETURN-PatP|||AH!!! Something that simple... But it did work... Sorry not posting this in the right place :D

No comments:

Post a Comment