If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > A simple varchar comparison

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-05, 12:01
xErath xErath is offline
Registered User
 
Join Date: Jan 2005
Posts: 3
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... ?!?!?
I running the commands on a Microsoft's SQL server. Thank you for your attention. Any help would be seriously apreciated.

Last edited by xErath; 01-05-05 at 12:04.
Reply With Quote
  #2 (permalink)  
Old 01-05-05, 13:44
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
This post really belongs in the Microsoft SQL forum.

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

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

RETURN
-PatP
Reply With Quote
  #3 (permalink)  
Old 01-05-05, 15:13
xErath xErath is offline
Registered User
 
Join Date: Jan 2005
Posts: 3
AH!!! Something that simple... But it did work... Sorry not posting this in the right place
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On