Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
modulopedia
Starting Member
1 Post |
Posted - 2011-06-19 : 08:39:17
|
New to SQL and especially Stored Procedures.Have VB.NET code:Public Function GetTwitterID(ByVal Username As String) As Long Dim sqlcmd As New SqlClient.SqlCommand sqlcmd.CommandText = "EXEC GetTweetID " & Username sqlcmd.Connection = SQLCon Return sqlcmd.ExecuteNonQuery End FunctionAND SP:ALTER PROCEDURE [dbo].[GetTweetID] /* ( @parameter1 int = 5, @parameter2 datatype OUTPUT ) */ @Username as nvarchar(50)AS declare @TwitterID bigint SET NOCOUNT ON SELECT @TwitterID = TwitterID from Tweeters WHERE Twitter_Name = @Username RETURN @TwitterIDHave tested the SP and it works but can't get @TwitterID to return.Any ideas? |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2011-06-20 : 14:00:14
|
the reason your posted code is not returning @twitterID is because RETURN only returns the datatype INT.Be One with the OptimizerTG |
 |
|
abbikhan
Starting Member
26 Posts |
Posted - 2011-06-22 : 02:36:33
|
i hope this is what you want....alter PROCEDURE [dbo].[GetTweetID] (@Username varchar(50),@TwitterID bigint OUTPUT)AS set @TwitterID=(SELECT TwitterID from Tweeters WHERE Twitter_Name = @Username)RETURN @TwitterID |
 |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2011-06-22 : 08:50:08
|
Nope that still won't work for the reason I gave above. There are two ways to get a BIGINT value out from a stored procedure. SELECT as a result set and/or OUTPUT parameter.Be One with the OptimizerTG |
 |
|
|
|
|