473,395 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Assigning parameters in a function

I am trying to create a function in SQL 2000. Im rusty on function
syntax and need to also assign some variables for use within this
function.

Example:
create function blah (@param1 int)

declare @var1 int, @var2 int

--it doesnt like this method of assigning values to my
variables??????????
select @var1, @var2 = (select name, phone from customer where id =
@param1)

--Then I need to use those variables in this next statement...

DECLARE @Zip int
SELECT @Results = (select zip from table2 where name = @var1 and phone
= @var2)

return @Results

-----------------------------------
Any help would be greatly appreciated at filling in the missing
syntax.
Jul 20 '05 #1
1 1927
> --it doesnt like this method of assigning values to my
variables??????????
select @var1, @var2 = (select name, phone from customer where id =
@param1)
Try:

select @var1= name, @var2 = phone
from customer where id = @param1

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Dave" <fu*****@yahoo.com> wrote in message
news:f5**************************@posting.google.c om... I am trying to create a function in SQL 2000. Im rusty on function
syntax and need to also assign some variables for use within this
function.

Example:
create function blah (@param1 int)

declare @var1 int, @var2 int

--it doesnt like this method of assigning values to my
variables??????????
select @var1, @var2 = (select name, phone from customer where id =
@param1)

--Then I need to use those variables in this next statement...

DECLARE @Zip int
SELECT @Results = (select zip from table2 where name = @var1 and phone
= @var2)

return @Results

-----------------------------------
Any help would be greatly appreciated at filling in the missing
syntax.

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: Dave | last post by:
Hello all, Please consider the code below. It is representative of a problem I am having. foo_t needs to contain a bar_t which is a class without a copy constructor or operator=. It is not...
1
by: Dave | last post by:
I am trying to create a function in SQL 2000. Im rusty on function syntax and need to also assign some variables for use within this function. Example: create function blah (@param1 int) ...
11
by: JohnR | last post by:
I'm trying to find a way to create a variable of a given type at runtime where I won't know the type until it actually executes. For example, dim x as object = "hi" x is declared as an object...
7
by: Ron Goral | last post by:
Hello I am new to creating objects in javascript, so please no flames about my coding style. =) I am trying to create an object that will represent a "div" element as a menu. I have written...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.