dbTalk Databases Forums  

query on procedure

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss query on procedure in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
meendar
 
Posts: n/a

Default query on procedure - 05-23-2007 , 01:06 AM






Hi,

Please see the below procedure.



create procedure a1
as
begin

create table #table1
{
empid int;
empname varchar
}
insert into #table1 select empid,empname from employee where
empcode='50'

select e.* from employee e, #table1 as t1 where e.empid=t1.empid and
e.empname=t1.empname; /* query1 */

end




In location query1,empid , empname in #table1 substitutes all the
values at the time, i need to substitute each value individually in
location query1.

Is there any way to do this?


Reply With Quote
  #2  
Old   
Ed Murphy
 
Posts: n/a

Default Re: query on procedure - 05-23-2007 , 02:29 PM






meendar wrote:

Quote:
create procedure a1
I trust your production code will have meaningful procedure names.

Quote:
create table #table1
{
empid int;
empname varchar
}
Should be

empid int,
empname varchar(30) -- or whatever

Quote:
insert into #table1 select empid,empname from employee where
empcode='50'

select e.* from employee e, #table1 as t1 where e.empid=t1.empid and
e.empname=t1.empname; /* query1 */
Why are you doing this, instead of simply

select * -- you should really have an explicit list of fields
from employee
where empcode = '50'

Does the 'employee' table really have both empcode and empid? If
so, then are they both enforced as unique?

Quote:
In location query1,empid , empname in #table1 substitutes all the
values at the time, i need to substitute each value individually in
location query1.

Is there any way to do this?
I don't understand what you mean. Please provide an example of what
it does now, and of what you want it to do instead.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.