[dba-SQLServer]Re: Sql Server Stored Procedure Questions ...

Mark Walker mark at sphere.uk.net
Sun Apr 13 15:59:36 CDT 2003


Except the variable needs to start with the '@' symbol like

DECLARE @varMyVariable AS VARCHAR(10)

:)

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of
Francisco H Tapia
Sent: Saturday, 12 April 2003 7:11 a.m.
To: accessd at databaseadvisors.com; dba-SQLServer at databaseadvisors.com
Subject: [dba-SQLServer]Re: Sql Server Stored Procedure Questions ...


as this is more of a sql question, I've forwared to the dba-sqlserver
list...

First, I encourage you to go to microsoft's sql site and download the latest
Books on line commonly known as BOL.  2nd, to declare a variable in sql
server, you use the keyword "Declare" such as

DECLARE varMyVariable AS VARCHAR(10)

in Sql 7 you add values to the varchar by using the keyword SELECT, but in
2000 you can use the keyword SET.

to step through a returned recordset from a sproc (SP) you would use a
cursor, tho I will warn you that they can take a lot of time and are usually
not as efficient as other means (ie, memory, cleanup, etc) , think #Temp
Tables if you really need to step through things, you'll find that things
can be done sooooo much faster this way...  any other questions reguarding
SP's feel free to post to the dba-SqlServer list :D

-Francisco
http://rcm.netfirms.com

On Friday, April 11, 2003 11:36 AM [GMT-8],
Tom Adams <tomadatn at bellsouth.net> wrote:

: I've got a few very basic questions for Sql 7 stored procedures.
: I've gone through all my saved AccessD's twice and can't figure it
: out.  I've left my main reference books at home and have 3 more
: coming as we type.
:
: 1.  How to declare variables in SP.  I con't want to return them,
: just use them further into the SP.
: 2.  How to gen a recordset or SP equvalent and step through it.
:
: Thanks - Tom



More information about the dba-SQLServer mailing list