Hi,
How do I change this statement into a create view :
SELECT dbo.OFW_New_Programme_Awards.AwardID AS AwardID, dbo.OFW_New_Programme_Awards.ProgrammeID AS ProgrammeID,
dbo.OFW_New_Programme_Awards.PointsValue AS PointsValue, dbo.OFW_New_Awards.Status AS Status, dbo.OFW_New_Awards.Category AS OFCategory,
dbo.OFW_New_Awards.Title AS Title, dbo.OFW_New_Awards.UnitQuantity AS UnitQuantity, dbo.OFW_New_Awards.MultiUnitQuantity AS MultiUnitQuantity,
dbo.OFW_New_Awards.Description AS Description, dbo.OFW_New_Awards.SupplierID AS SupplierID, dbo.OFW_New_Awards.IsVoucher AS IsVoucher,
dbo.OFW_New_Awards.HasSize AS HasSize, dbo.OFW_New_Categories.*
FROM dbo.OFW_New_Awards INNER JOIN
dbo.OFW_New_Programme_Awards ON dbo.OFW_New_Awards.ID = dbo.OFW_New_Programme_Awards.AwardID INNER JOIN
dbo.OFW_New_Categories ON dbo.OFW_New_Awards.Category = dbo.OFW_New_Categories.Category
Cheers
9 1351
Hi,
How do I change this statement into a create view :
SELECT dbo.OFW_New_Programme_Awards.AwardID AS AwardID, dbo.OFW_New_Programme_Awards.ProgrammeID AS ProgrammeID,
dbo.OFW_New_Programme_Awards.PointsValue AS PointsValue, dbo.OFW_New_Awards.Status AS Status, dbo.OFW_New_Awards.Category AS OFCategory,
dbo.OFW_New_Awards.Title AS Title, dbo.OFW_New_Awards.UnitQuantity AS UnitQuantity, dbo.OFW_New_Awards.MultiUnitQuantity AS MultiUnitQuantity,
dbo.OFW_New_Awards.Description AS Description, dbo.OFW_New_Awards.SupplierID AS SupplierID, dbo.OFW_New_Awards.IsVoucher AS IsVoucher,
dbo.OFW_New_Awards.HasSize AS HasSize, dbo.OFW_New_Categories.*
FROM dbo.OFW_New_Awards INNER JOIN
dbo.OFW_New_Programme_Awards ON dbo.OFW_New_Awards.ID = dbo.OFW_New_Programme_Awards.AwardID INNER JOIN
dbo.OFW_New_Categories ON dbo.OFW_New_Awards.Category = dbo.OFW_New_Categories.Category
Cheers
- CREATE VIEW view_name AS
-
SELECT column_name(s)
-
FROM table_name
-
WHERE condition
-
I have followed this syntax and it keeps failing.
this is the syntax that I have used:
CREATE VIEW VIEW_OFW_New_Prog_Award_Detail_test
AS
SELECT
OFW_New_Programme_Awards.AwardID AS AwardID,
OFW_New_Programme_Awards.ProgrammeID AS ProgrammeID,
OFW_New_Programme_Awards.PointsValue AS PointsValue,
OFW_New_Awards.Status AS Status,
OFW_New_Awards.Category AS OFCategory,
OFW_New_Awards.Title AS Title,
OFW_New_Awards.UnitQuantity AS UnitQuantity,
OFW_New_Awards.MultiUnitQuantity AS MultiUnitQuantity,
OFW_New_Awards.Description AS Description,
OFW_New_Awards.SupplierID AS SupplierID,
OFW_New_Awards.IsVoucher AS IsVoucher,
OFW_New_Awards.HasSize AS HasSize,
OFW_New_Categories.*
FROM OFW_New_Awards INNER JOIN
OFW_New_Programme_Awards ON OFW_New_Awards.ID = OFW_New_Programme_Awards.AwardID INNER JOIN
OFW_New_Categories ON OFW_New_Awards.Category = OFW_New_Categories.Category
It works fine throughSQL query Analyzar, but when but into this code: - OpenDatabaseOrder()
-
-
cquery = "CREATE VIEW VIEW_OFW_New_Prog_Award_Detail" & vbcrlf
-
cquery = cquery & "AS" & vbcrlf
-
cquery = cquery & "SELECT " & vbcrlf
-
cquery = cquery & "OFW_New_Programme_Awards.AwardID AS AwardID, " & vbcrlf
-
cquery = cquery & "OFW_New_Programme_Awards.ProgrammeID AS ProgrammeID," & vbcrlf
-
cquery = cquery & "OFW_New_Programme_Awards.PointsValue AS PointsValue," & vbcrlf
-
cquery = cquery & "OFW_New_Awards.Status AS Status, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.Category AS OFCategory," & vbcrlf
-
cquery = cquery & "OFW_New_Awards.Title AS Title, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.UnitQuantity AS UnitQuantity, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.MultiUnitQuantity AS MultiUnitQuantity," & vbcrlf
-
cquery = cquery & "OFW_New_Awards.Description AS Description, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.SupplierID AS SupplierID," & vbcrlf
-
cquery = cquery & "OFW_New_Awards.IsVoucher AS IsVoucher, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.HasSize AS HasSize, " & vbcrlf
-
cquery = cquery & "OFW_New_Categories.*" & vbcrlf
-
cquery = cquery & "FROM OFW_New_Awards INNER JOIN" & vbcrlf
-
cquery = cquery & "OFW_New_Programme_Awards ON OFW_New_Awards.ID = OFW_New_Programme_Awards.AwardID INNER JOIN" & vbcrlf
-
cquery = cquery & "OFW_New_Categories ON OFW_New_Awards.Category = OFW_New_Categories.Categoryy" & vbcrlf
-
-
sysDatabase.execute(cquery)
-
-
CloseDatabaseOrder()
It fails
I have followed this syntax and it keeps failing.
this is the syntax that I have used:
CREATE VIEW VIEW_OFW_New_Prog_Award_Detail_test
AS
SELECT
OFW_New_Programme_Awards.AwardID AS AwardID,
OFW_New_Programme_Awards.ProgrammeID AS ProgrammeID,
OFW_New_Programme_Awards.PointsValue AS PointsValue,
OFW_New_Awards.Status AS Status,
OFW_New_Awards.Category AS OFCategory,
OFW_New_Awards.Title AS Title,
OFW_New_Awards.UnitQuantity AS UnitQuantity,
OFW_New_Awards.MultiUnitQuantity AS MultiUnitQuantity,
OFW_New_Awards.Description AS Description,
OFW_New_Awards.SupplierID AS SupplierID,
OFW_New_Awards.IsVoucher AS IsVoucher,
OFW_New_Awards.HasSize AS HasSize,
OFW_New_Categories.*
FROM OFW_New_Awards INNER JOIN
OFW_New_Programme_Awards ON OFW_New_Awards.ID = OFW_New_Programme_Awards.AwardID INNER JOIN
OFW_New_Categories ON OFW_New_Awards.Category = OFW_New_Categories.Category
It works fine throughSQL query Analyzar, but when but into this code: - OpenDatabaseOrder()
-
-
cquery = "CREATE VIEW VIEW_OFW_New_Prog_Award_Detail" & vbcrlf
-
cquery = cquery & "AS" & vbcrlf
-
cquery = cquery & "SELECT " & vbcrlf
-
cquery = cquery & "OFW_New_Programme_Awards.AwardID AS AwardID, " & vbcrlf
-
cquery = cquery & "OFW_New_Programme_Awards.ProgrammeID AS ProgrammeID," & vbcrlf
-
cquery = cquery & "OFW_New_Programme_Awards.PointsValue AS PointsValue," & vbcrlf
-
cquery = cquery & "OFW_New_Awards.Status AS Status, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.Category AS OFCategory," & vbcrlf
-
cquery = cquery & "OFW_New_Awards.Title AS Title, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.UnitQuantity AS UnitQuantity, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.MultiUnitQuantity AS MultiUnitQuantity," & vbcrlf
-
cquery = cquery & "OFW_New_Awards.Description AS Description, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.SupplierID AS SupplierID," & vbcrlf
-
cquery = cquery & "OFW_New_Awards.IsVoucher AS IsVoucher, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.HasSize AS HasSize, " & vbcrlf
-
cquery = cquery & "OFW_New_Categories.*" & vbcrlf
-
cquery = cquery & "FROM OFW_New_Awards INNER JOIN" & vbcrlf
-
cquery = cquery & "OFW_New_Programme_Awards ON OFW_New_Awards.ID = OFW_New_Programme_Awards.AwardID INNER JOIN" & vbcrlf
-
cquery = cquery & "OFW_New_Categories ON OFW_New_Awards.Category = OFW_New_Categories.Categoryy" & vbcrlf
-
-
sysDatabase.execute(cquery)
-
-
CloseDatabaseOrder()
It fails
why do u use cquery ???
It is used a variable to hold the SQL syntax, which is then past into:
sysDatabase.execute(cquery)
It is used a variable to hold the SQL syntax, which is then past into:
sysDatabase.execute(cquery)
why do u want to do that ????
are u using vb?
It is part of an vbscript page which requires a view to be dropped then re-created so that it is up-to-date with any changes.
Why are you using vbcrLf in every concatination.
Just so that the code is nice and tidy and arrives in the same format, rather than one long string, it's just a personal thing, it shouldn't affect it.
Just to let you know, this is all sorted, this is the final code: - dim cquery
-
-
OpenDatabaseOrder()
-
-
cquery = "CREATE VIEW VIEW_OFW_New_Prog_Award_Detail" & vbcrlf
-
cquery = cquery & "AS" & vbcrlf
-
cquery = cquery & "SELECT " & vbcrlf
-
cquery = cquery & "OFW_New_Programme_Awards.AwardID AS AwardID, " & vbcrlf
-
cquery = cquery & "OFW_New_Programme_Awards.ProgrammeID AS ProgrammeID," & vbcrlf
-
cquery = cquery & "OFW_New_Programme_Awards.PointsValue AS PointsValue," & vbcrlf
-
cquery = cquery & "OFW_New_Awards.Status AS Status, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.Category AS OFCategory," & vbcrlf
-
cquery = cquery & "OFW_New_Awards.Title AS Title, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.UnitQuantity AS UnitQuantity, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.MultiUnitQuantity AS MultiUnitQuantity," & vbcrlf
-
cquery = cquery & "OFW_New_Awards.Description AS Description, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.SupplierID AS SupplierID," & vbcrlf
-
cquery = cquery & "OFW_New_Awards.IsVoucher AS IsVoucher, " & vbcrlf
-
cquery = cquery & "OFW_New_Awards.HasSize AS HasSize, " & vbcrlf
-
cquery = cquery & "OFW_New_Categories.*" & vbcrlf
-
cquery = cquery & "FROM OFW_New_Awards INNER JOIN" & vbcrlf
-
cquery = cquery & "OFW_New_Programme_Awards ON OFW_New_Awards.ID = OFW_New_Programme_Awards.AwardID INNER JOIN" & vbcrlf
-
cquery = cquery & "OFW_New_Categories ON OFW_New_Awards.Category = OFW_New_Categories.Category" & vbcrlf
-
-
sysDatabase.execute(cquery)
-
-
CloseDatabaseOrder()
Sign in to post your reply or Sign up for a free account.
Similar topics
by: js |
last post by:
I am trying to create a primary key constraint on a view in the
following statement. However, I got an error ORA-00907: missing right
parenthesis. If the CONSTRAINT clause is removed, then the...
|
by: M. Mehta |
last post by:
It seems that you can not create a materialized view if you are using
outer joins...can someone please verify this?
Thanks
M. Mehta
Please follow my example below:
created 2 tables:
|
by: kackson |
last post by:
Hi.
I created a simple view with the following statements:
CREATE VIEW dbo.VIEW1
AS
SELECT dbo.VIEW_ALL.ID,
dbo.VIEW_ALL.Code,
Another.dbo.OTHER_VIEW.Label as SpecialCode
FROM ...
|
by: MD |
last post by:
I am trying to create a dynamic SQL statement to create a view.
I have a stored procedure, which based on the parameters passed calls
different stored procedures. Each of this sub stored procedure...
|
by: Zack Sessions |
last post by:
Has anyone tried to create a SQL7 view using the CREATE VIEW command
and ADO.NET? If so, is there a trick in trapping a SQL error when
trying to create the view? I have a VB.NET app that, amoung...
|
by: Karsten |
last post by:
Hi,
I want to create dynamic reports with C# and MS SQL-Server 2005
Reporting Services.
Since the reporting service uses a data-table or data-view, I want to
create a view dynamically.
How...
|
by: Curtiosity |
last post by:
I have done a create or replace view called creditcard1. If I do a "select * from creditcard1" it retrieves the data just fine. If I try to do a statement where I am listing the column names it...
|
by: Shirley |
last post by:
We are running DB2 on iSeries V5R2.
Using AQUA DATA STUDIO with a connection to our iSeries, I created a
view using SQL and I am trying to create an index on this view using
the code below.
...
|
by: cognosqueen |
last post by:
I need to create a view of a sql table, but change the data types. I know
the syntax below is not correct, and can't figure out if it is wrong or if
you just can't do this. I have only created...
|
by: alessandro menchini |
last post by:
Hello,
First of all: i apologize for my english...i'm still learning...
If i create a view it seems that DB2 manage this view like an
updateable view.
But I need to create a view "read only",...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |