Re: "EXEC" in SQL Server 2000 Views
From: Kalen Delaney (replies_at_public_newsgroups.com)
Date: 01/19/05
- Next message: Tracey_sydney: "RE: controlling lock order in transactions"
- Previous message: Ben Amada: "Re: Trying to avoid nested cursor"
- In reply to: Sue: ""EXEC" in SQL Server 2000 Views"
- Next in thread: Sue: "Re: "EXEC" in SQL Server 2000 Views"
- Reply: Sue: "Re: "EXEC" in SQL Server 2000 Views"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 19 Jan 2005 15:31:28 -0800
Hi Sue
You misunderstood something, somewhere. It is NOT possible to include an
EXEC as part of a view definition, in ANY version.
You say you cannot issue the SELECT against the view, but you haven't told
us why not. Do you get an error message? What does it say?
You can issue a view against remote tables:
CREATE VIEW dbo.Test
AS
SELECT a.Incident_no, a.Description,
b.Person_ID AS Reportedbyid, c.Name as Reportedby
FROM LinkedServerName...a
INNER JOIN LinkedServerName...b
... etc.
-- HTH ---------------- Kalen Delaney SQL Server MVP www.SolidQualityLearning.com "Sue" <Sue@discussions.microsoft.com> wrote in message news:5A64E47D-F208-4428-9BA7-9097EF968D84@microsoft.com... > From a View in my SQL Server 2000 db I need to either EXEC a pass-through > query (to an Access 97 db) or EXEC a stored procedure which itself > executes > the pass-through query (via the OPENQUERY command and a Linked Server). > > I understand that it is possible to include an EXEC statement in a View in > SQL Server 2000 where it wasn't in SQL 7. I can CREATE the following View: > > CREATE VIEW dbo.Test > AS > SELECT * FROM openquery(LinkedServerName, > 'SELECT a.Incident_no, > a.Description, > b.Person_ID AS Reportedbyid, > c.Name as Reportedby > FROM (a > INNER JOIN b > ON a.Incident_no = b.Incident_No) > INNER JOIN c > ON c.Person_id = b.Person_id > WHERE (b.Involvement_Type = "REPTBY" > AND a.Completed = 0) > ') > > The View creates OK but then I cannot issue a SELECT statement against it > in > Query Analyzer. I have put the pass-through query in a stored procedure > and > tried to create the View as follows: > > CREATE VIEW dbo.Test > AS > EXEC Test_SP > > but this doesn't work. > > Does anyone have any idea how I can create this View to execute the > pass-through query or the stored procedure? > > Thanks for your assistance, > > Sue >
- Next message: Tracey_sydney: "RE: controlling lock order in transactions"
- Previous message: Ben Amada: "Re: Trying to avoid nested cursor"
- In reply to: Sue: ""EXEC" in SQL Server 2000 Views"
- Next in thread: Sue: "Re: "EXEC" in SQL Server 2000 Views"
- Reply: Sue: "Re: "EXEC" in SQL Server 2000 Views"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|