Select getting table fields or setting variables? 
Author Message
 Select getting table fields or setting variables?

In SQL, the select statement will get table fields, but I have just
found out, it will also set the value of a
variable within a stored procedure.
This seems very confusing.
How do I know what it is doing, and how do I make it do one or the
other.

I have ....
CREATE PROCEDURE sp_GetNextRegNum

AS
Select  Reg,Reg_Number_id as RegID
FROM
Reg_Number


'-------
I want to get the reg number of the first record, and then delete that
record, once I have retrieved the
reg nbr.

Also,
What is a good book for SQL, I have several, but they cover they basics,
like select selecting
table fields names, not setting the values of variables and complex if
then statments.

Thank  You for your help,
Laurence Nuttall -UCLA



Sat, 08 Jun 2002 03:00:00 GMT
 Select getting table fields or setting variables?


Or..


Is the variable setting form of the statement.

Whereas,

SELECT RegId
or
SELECT sasmnasmd REGId
or
SELECT ajdaksljd AS RegID

Is the select form.

--
Tony Rogerson SQL Server MVP
Torver Computer Consultants Ltd
www.sql-server.co.uk (UK User group, code library, FAQ etc..)


Quote:
> In SQL, the select statement will get table fields, but I have just
> found out, it will also set the value of a
> variable within a stored procedure.
> This seems very confusing.
> How do I know what it is doing, and how do I make it do one or the
> other.

> I have ....
> CREATE PROCEDURE sp_GetNextRegNum


> AS
> Select  Reg,Reg_Number_id as RegID
> FROM
> Reg_Number


> '-------
> I want to get the reg number of the first record, and then delete that
> record, once I have retrieved the
> reg nbr.

> Also,
> What is a good book for SQL, I have several, but they cover they basics,
> like select selecting
> table fields names, not setting the values of variables and complex if
> then statments.

> Thank  You for your help,
> Laurence Nuttall -UCLA



Sun, 09 Jun 2002 03:00:00 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Set a variable to equal a select statement containing variables

2. Help to set local variable equal to value of field in result set

3. Getting value of Timestamp field into host language variable

4. Getting lengths of variable fields

5. Storing Select result set into a variable ??

6. difference between SET and SELECT with variables

7. Use SET or SELECT to assign values to variables

8. Setting local variables on SELECT returns

9. SQL - how to set variable in multi-select?

10. Triggers: Set 2 variables with 1 single select statement

11. selecting recordsets and setting variables

12. Setting Multiple variables from 1 select statement


 
Powered by phpBB® Forum Software