Results 1 to 28 of 28

Thread: Stored Procedures, msSQL

Threaded View

  1. #1

    Thread Starter
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547

    Stored Procedures, msSQL

    I figured I'd start a new thread for this
    Ok, these things are frustrating the hell outa me! grrr...

    ok, why would this not work
    Code:
    CREATE PROCEDURE sp_getTableWhere 
    	
    	@vTable varchar(20),
    	@vcharValue1 varchar(20),
    	@vcharValue2 varchar(20)
    AS
    
    	SELECT * FROM @vTable
    	WHERE @vcharValue1 = @vcharValue2
    Sais I need to declare @vTable

    What im trying to do is select all records from a certain table by Value 1 and Value 2 where
    Value1 is the Column, and Value 2 is the matching value for that column.



    Problem #2)
    I wrote this simple function to see if a user exists
    Code:
    CREATE PROCEDURE sp_isValidLogin 
    
    	@charUsername varchar(50),
    	@charPHash varchar(50)
    
    	AS
    	if(DATALENGTH(@charUsername) = 0 AND DATALENGTH(@charPHash) = 0)
    		RETURN 0
    
    		if exists(SELECT * FROM tblUser
    	
    			WHERE @charUsername = charUsername
    	
    		 AND
    	
    			@charPHash = charPHash)
    			return 1
    		else
    			return 0
    GO
    When you call a return, does it terminate the stored procedure like a javascript or c++ statement would? Because it keeps giving me this message if @charUsername and @charHash are empty

    [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot use empty object or column names. Use a single space if necessary.
    If i do pass in the value, and it does exist... SQL sais: Missing Default Property. What, huh? I thought returning 0 or 1 is enough?

    Arghhhhh... i hate when things dont work
    Last edited by invitro; Aug 29th, 2004 at 05:19 PM.
    ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet?

Posting Permissions

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



Click Here to Expand Forum to Full Width