Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi ,
I am trying to pass value from one Sp to another SP USING A Local variable.

SQL
create proc pp
as
declare @aa xml
begin
set @aa= select phone no from table1;
exec stordproc2(@aa)
end


But it is not working. The nested SP is not accepting it. Can you plz tell why ?

Advance Thanks For reply.
Posted
Updated 15-Dec-10 0:51am
v2
Comments
Abdul Quader Mamun 15-Dec-10 6:51am    
Decorate question & spelling check.

1 solution

Thank you for your question.

SQL
create proc pp
as
  declare @aa xml
begin
  set @aa= select phone no from table1;
  SELECT @aa=[phone no] AS PhoneNo FROM table1;
  EXEC stordproc2(@aa)
end



Thanks,
Mamun
 
Share this answer
 
Comments
shikhar gilhotra 15-Dec-10 7:09am    
thx mamun
it worked but can u tell why did u put phone no in brackets [].

Regards.
Abdul Quader Mamun 15-Dec-10 7:14am    
[] bracket is used for fields name others in which space available between name. In your case Phone no. SQL does not read it because space. So for [phone no] has used. Better to not used space.

Thanks!
fjdiewornncalwe 25-Dec-10 18:30pm    
Bang on...
Shikhar: I would encourage you to do this for all field names in your queries. If you get into a habit of writing queries using the square brackets around names, you will automatically not have issues and bugs introduced into code you write because of the space in names, etc.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900