05. juli 2001 - 09:49Der er
7 kommentarer og 1 løsning
ALTER VIEW
Hejsa
Jeg prøver at oprette en stored procedure som kan ændre et view, til at reflektere et udsnit af en tabel, på baggrund af en parameter som sendes med til SP\'en. Men det wærker ik, og jeg ved ikke lige hvor jeg skal starte. Jeg har gjort følgende:
CREATE PROCEDURE [dbo].[_jcact] @customer varchar(30) AS
ALTER VIEW Cust_EXCEL_OUTPUT_View AS SELECT dbo.Vagtliste_Table.* FROM dbo.Vagtliste_Table WHERE Customer = @customer
GO
Kan nogen se om jeg grundlæggende har misforstået nogen, eller det evt er en mindre syntaks/semantisk fejl? Den siger Incorrect Syntax near keyword \'View\'
I very much doubt what your doing will work. Doesnt seem logical at all...
Your procedure is trying to create a view which is using user varaiables and I am not sure that is possible, system variables yes! The varaiable in the SP your creating isnt available in the VIEW once it screated, is it?
hehe, i was actually about to rephraze my q, i can see your point. Part of the problem is that i\'m not quite sure what i\'m trying to do :) I\'m only in my first month of SQL server, so experimenting on the many different possible approches is what i do most.
This is what i have thought up so far, but i\'m not sure it is possible.
- Go to a webpage and enter a customer name - Fire a stored proc via asp, that alters the customer view to reflect the selected customer - Fire a stored procedure that exports this view to an excel that the user can pick up in a folder.
oki-doke, i think i will rest my case until i actually know what my problem is. I will keep the question open for a while to see if anyone else has any ideas. Thaaanx so far :)
Tja, for mig ser det også lidt \"sjovt\" ud. Hvorfor vil du have en WHERE-clause på dit VIEW? Jeg ville sætte den på den eller de SELECT\'s der anvender VIEW\'et således (evt. i en STP som nedenfor):
CREATE PROCEDURE stpExcelOutput @Customer VARCHAR(30) AS SELECT * FROM Cust_EXCEL_OUTPUT_View WHERE Customer = @Customer
hi suendh, As jeschrper says himself, he doesnt really know what he is trying to do, if he did then it would be easier to make some suggestions. I understand that he wants the data in Excel, so I would assume that Excel would accept an SQL statement built up from ASP. IE just a simple SQL> SELECT * FROM Cust_EXCEL_OUTPUT_View WHERE Customer = \'John Smith\'
He could also have a SP to bcp the result into a file for Excel to read.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.