Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2009
    Posts
    93

    Unanswered: declare the scalar variable

    I have the following stored procedure created to find an employee username. I now want to use the parameter @Username in a select statement and save it in a view but it is saying i must declare scalar variable when trying to save the view. If i just run the query in query editor without saving, it runs fine. Any ideas?


    CREATE PROCEDURE dbo.LoginCheck
    /* Parameters needed to obtain data from user*/

    (
    @UserName VARCHAR(50)= Null

    )

    AS
    SELECT * from dbo.EmployeeLogin
    WHERE (dbo.Employeelogin.Uname = @UserName)

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Pronoun trouble

    SELECT * from dbo.EmployeeLogin
    WHERE (Employeelogin.dbo.Uname = @UserName)
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Oct 2009
    Posts
    93
    No luck i'm afraid Brett. Trying to save the query as a view but it keeps asking me to declare etc.

    Anyone got some links to login system tutorials. Have a login form working correctly with usernames/passwords in database but can't get data grid to find records associated with username inputted to work on second form basing on username inputted

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Considered making this a table valued function instead of a sproc?
    Sounds like that's more what you're looking for.

    P.S. never create production stuff with a SELECT *
    George
    Home | Blog

  5. #5
    Join Date
    Oct 2009
    Posts
    93
    Not sure what you mean Gvee. I'm a novice so table valued functions quote is double dutch to me

  6. #6
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Where are you doing this work from SQL Server Management Studio?

    Wghat version of SQL Server are you using?

    Have you posted all of the code, or is this just a snippet?

    Do you know how to create DDL?

    Post the DL from the table
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  7. #7
    Join Date
    Oct 2009
    Posts
    93
    Hi Brett,

    I am using SQL Server 2005, Designing Winform Application through VStudio 2008.

    I have usernames/passwords in sql table. I have the login part working where the user can login by validating against the username/password stored in the login table but i need to bring back the user's information in a grid view etc. on Form 2 based on their employeeid which is referenced in all other tables.

    Login Table
    Username
    Password
    Employeeid

    All Other Tables
    Employeeid
    Details etc.


    My problem is that i somehow need to save the inputted Username/password on Form 1 as variables and somehow pass these to my SQL Statements on Form 2 so the correct records return for that individual only.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •