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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Variable in a function

Author  Topic 

Babli
Yak Posting Veteran

53 Posts

Posted - 2007-01-22 : 03:39:14
I want to declare a varibale inside my function but I am getting an error if I do the following way.

CREATE FUNCTION GetString(@inputUrl VARCHAR(300))
RETURNS VARCHAR(100)
as
Declare @tmp varchar

How should i declare a variable within a function.

Thanks in advance,
Babli

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-01-22 : 03:41:06
[code]CREATE FUNCTION GetString(@inputUrl VARCHAR(300))
RETURNS VARCHAR(100)
as
begin
declare @tmp varchar
. . . .
end
[/code]


KH

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-22 : 03:41:29
CREATE FUNCTION GetString(@inputUrl VARCHAR(300))
RETURNS VARCHAR(100)
as
begin
Declare @tmp varchar
return @tmp
end


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-22 : 03:41:53



Peter Larsson
Helsingborg, Sweden
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-01-22 : 03:43:53
quote:
Originally posted by Peso




Peter Larsson
Helsingborg, Sweden





i am slightly faster as i did not type in the return @tmp statement


KH

Go to Top of Page

Babli
Yak Posting Veteran

53 Posts

Posted - 2007-01-22 : 03:44:18
How silly of me to have missed Begin and End

quote:
Originally posted by Peso




Peter Larsson
Helsingborg, Sweden

Go to Top of Page
   

- Advertisement -