top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to create a view and a stored procedure using "CREATE VIEW/PROCEDURE" statements ?

+4 votes
411 views
How to create a view and a stored procedure using "CREATE VIEW/PROCEDURE" statements ?
posted Feb 2, 2014 by Mona Sharma

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

CREATE PROCEDURE [dbo].[testProcedure]
-- Add the parameters for the stored procedure here
@ID AS VARCHAR
AS
BEGIN

DECLARE @var AS INT

SELECT 
    @vart = COUNT (*) 
FROM 
    dbo.testTable
WHERE 
    ID = @ID 

END

--CREATING VIEW

CREATE VIEW Customers
AS
--Select from local member table.
SELECT *
FROM CompanyData.dbo.Customers_33
UNION ALL
--Select from member table on Server2.
SELECT *
FROM Server2.CompanyData.dbo.Customers_66
UNION ALL
--Select from mmeber table on Server3.
SELECT *
FROM Server3.CompanyData.dbo.Customers_99;

answer Feb 2, 2014 by Neeraj Pandey
Similar Questions
+2 votes

Can a Stored Procedure call itself or a Recursive Stored Procedure? How many levels of SP nesting is possible?

...