Re: how do i create a view within a procedure that uses a variable defined in the procedure
From: Hari (hari_prasad_k_at_hotmail.com)
Date: 06/07/04
- Next message: Anith Sen: "Re: how do i create a view within a procedure that uses a variable defined in the procedure"
- Previous message: Michael: "RE: SQL Replace Function for Strings"
- In reply to: Nikhil: "how do i create a view within a procedure that uses a variable defined in the procedure"
- Next in thread: Anith Sen: "Re: how do i create a view within a procedure that uses a variable defined in the procedure"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 7 Jun 2004 14:52:41 +0530
Hi,
Use the dynamic sql to create the view using a variable inside procedure.
The same procedure is given below. Ensure that you drop the view every time,
otherwise
procedure execution will give an error stating that view already exists.
Create procedure cr_view
as
begin
declare @sql nvarchar(1000)
declare @v_name varchar(30)
set @v_name='hari_view'
set @sql = 'create view '+@v_name+ ' as select * from sysobjects'
exec sp_executesql @sql
end
Thanks
Hari
MCDBA
"Nikhil" <anonymous@discussions.microsoft.com> wrote in message
news:4D6D678B-C28B-4300-91DC-6413AD3C3BA9@microsoft.com...
> how do i create a view within a procedure that uses a variable defined in
the procedure
>
> regards
>
> nikhil
- Next message: Anith Sen: "Re: how do i create a view within a procedure that uses a variable defined in the procedure"
- Previous message: Michael: "RE: SQL Replace Function for Strings"
- In reply to: Nikhil: "how do i create a view within a procedure that uses a variable defined in the procedure"
- Next in thread: Anith Sen: "Re: how do i create a view within a procedure that uses a variable defined in the procedure"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|