473,386 Members | 1,835 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Create View ?

27
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
Jan 10 '08 #1
9 1351
OuTCasT
374 256MB
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
Expand|Select|Wrap|Line Numbers
  1. CREATE VIEW view_name AS
  2. SELECT column_name(s)
  3. FROM table_name
  4. WHERE condition
  5.  
Jan 10 '08 #2
adz1809
27
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:

Expand|Select|Wrap|Line Numbers
  1. OpenDatabaseOrder()
  2.  
  3.     cquery = "CREATE VIEW VIEW_OFW_New_Prog_Award_Detail" & vbcrlf
  4.     cquery = cquery & "AS" & vbcrlf
  5.     cquery = cquery & "SELECT " & vbcrlf
  6.     cquery = cquery & "OFW_New_Programme_Awards.AwardID AS AwardID, " & vbcrlf
  7.     cquery = cquery & "OFW_New_Programme_Awards.ProgrammeID AS ProgrammeID," & vbcrlf
  8.     cquery = cquery & "OFW_New_Programme_Awards.PointsValue AS PointsValue,"  & vbcrlf
  9.     cquery = cquery & "OFW_New_Awards.Status AS Status, " & vbcrlf
  10.     cquery = cquery & "OFW_New_Awards.Category AS OFCategory," & vbcrlf
  11.     cquery = cquery & "OFW_New_Awards.Title AS Title, " & vbcrlf
  12.     cquery = cquery & "OFW_New_Awards.UnitQuantity AS UnitQuantity, " & vbcrlf
  13.     cquery = cquery & "OFW_New_Awards.MultiUnitQuantity AS MultiUnitQuantity," & vbcrlf
  14.     cquery = cquery & "OFW_New_Awards.Description AS Description, " & vbcrlf
  15.     cquery = cquery & "OFW_New_Awards.SupplierID AS SupplierID," & vbcrlf
  16.     cquery = cquery & "OFW_New_Awards.IsVoucher AS IsVoucher, " & vbcrlf
  17.     cquery = cquery & "OFW_New_Awards.HasSize AS HasSize, " & vbcrlf
  18.     cquery = cquery & "OFW_New_Categories.*" & vbcrlf
  19.     cquery = cquery & "FROM OFW_New_Awards INNER JOIN" & vbcrlf
  20.     cquery = cquery & "OFW_New_Programme_Awards ON OFW_New_Awards.ID = OFW_New_Programme_Awards.AwardID INNER JOIN" & vbcrlf
  21.     cquery = cquery & "OFW_New_Categories ON OFW_New_Awards.Category = OFW_New_Categories.Categoryy" & vbcrlf
  22.  
  23.     sysDatabase.execute(cquery)
  24.  
  25.     CloseDatabaseOrder()
It fails
Jan 10 '08 #3
OuTCasT
374 256MB
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:

Expand|Select|Wrap|Line Numbers
  1. OpenDatabaseOrder()
  2.  
  3.     cquery = "CREATE VIEW VIEW_OFW_New_Prog_Award_Detail" & vbcrlf
  4.     cquery = cquery & "AS" & vbcrlf
  5.     cquery = cquery & "SELECT " & vbcrlf
  6.     cquery = cquery & "OFW_New_Programme_Awards.AwardID AS AwardID, " & vbcrlf
  7.     cquery = cquery & "OFW_New_Programme_Awards.ProgrammeID AS ProgrammeID," & vbcrlf
  8.     cquery = cquery & "OFW_New_Programme_Awards.PointsValue AS PointsValue,"  & vbcrlf
  9.     cquery = cquery & "OFW_New_Awards.Status AS Status, " & vbcrlf
  10.     cquery = cquery & "OFW_New_Awards.Category AS OFCategory," & vbcrlf
  11.     cquery = cquery & "OFW_New_Awards.Title AS Title, " & vbcrlf
  12.     cquery = cquery & "OFW_New_Awards.UnitQuantity AS UnitQuantity, " & vbcrlf
  13.     cquery = cquery & "OFW_New_Awards.MultiUnitQuantity AS MultiUnitQuantity," & vbcrlf
  14.     cquery = cquery & "OFW_New_Awards.Description AS Description, " & vbcrlf
  15.     cquery = cquery & "OFW_New_Awards.SupplierID AS SupplierID," & vbcrlf
  16.     cquery = cquery & "OFW_New_Awards.IsVoucher AS IsVoucher, " & vbcrlf
  17.     cquery = cquery & "OFW_New_Awards.HasSize AS HasSize, " & vbcrlf
  18.     cquery = cquery & "OFW_New_Categories.*" & vbcrlf
  19.     cquery = cquery & "FROM OFW_New_Awards INNER JOIN" & vbcrlf
  20.     cquery = cquery & "OFW_New_Programme_Awards ON OFW_New_Awards.ID = OFW_New_Programme_Awards.AwardID INNER JOIN" & vbcrlf
  21.     cquery = cquery & "OFW_New_Categories ON OFW_New_Awards.Category = OFW_New_Categories.Categoryy" & vbcrlf
  22.  
  23.     sysDatabase.execute(cquery)
  24.  
  25.     CloseDatabaseOrder()
It fails
why do u use cquery ???
Jan 10 '08 #4
adz1809
27
It is used a variable to hold the SQL syntax, which is then past into:

sysDatabase.execute(cquery)
Jan 10 '08 #5
OuTCasT
374 256MB
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?
Jan 10 '08 #6
adz1809
27
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.
Jan 10 '08 #7
debasisdas
8,127 Expert 4TB
Why are you using vbcrLf in every concatination.
Jan 10 '08 #8
adz1809
27
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.
Jan 10 '08 #9
adz1809
27
Just to let you know, this is all sorted, this is the final code:

Expand|Select|Wrap|Line Numbers
  1. dim cquery
  2.  
  3.     OpenDatabaseOrder()
  4.  
  5.     cquery = "CREATE VIEW VIEW_OFW_New_Prog_Award_Detail" & vbcrlf
  6.     cquery = cquery & "AS" & vbcrlf
  7.     cquery = cquery & "SELECT " & vbcrlf
  8.     cquery = cquery & "OFW_New_Programme_Awards.AwardID AS AwardID, " & vbcrlf
  9.     cquery = cquery & "OFW_New_Programme_Awards.ProgrammeID AS ProgrammeID," & vbcrlf
  10.     cquery = cquery & "OFW_New_Programme_Awards.PointsValue AS PointsValue,"  & vbcrlf
  11.     cquery = cquery & "OFW_New_Awards.Status AS Status, " & vbcrlf
  12.     cquery = cquery & "OFW_New_Awards.Category AS OFCategory," & vbcrlf
  13.     cquery = cquery & "OFW_New_Awards.Title AS Title, " & vbcrlf
  14.     cquery = cquery & "OFW_New_Awards.UnitQuantity AS UnitQuantity, " & vbcrlf
  15.     cquery = cquery & "OFW_New_Awards.MultiUnitQuantity AS MultiUnitQuantity," & vbcrlf
  16.     cquery = cquery & "OFW_New_Awards.Description AS Description, " & vbcrlf
  17.     cquery = cquery & "OFW_New_Awards.SupplierID AS SupplierID," & vbcrlf
  18.     cquery = cquery & "OFW_New_Awards.IsVoucher AS IsVoucher, " & vbcrlf
  19.     cquery = cquery & "OFW_New_Awards.HasSize AS HasSize, " & vbcrlf
  20.     cquery = cquery & "OFW_New_Categories.*" & vbcrlf
  21.     cquery = cquery & "FROM OFW_New_Awards INNER JOIN" & vbcrlf
  22.     cquery = cquery & "OFW_New_Programme_Awards ON OFW_New_Awards.ID = OFW_New_Programme_Awards.AwardID INNER JOIN" & vbcrlf
  23.     cquery = cquery & "OFW_New_Categories ON OFW_New_Awards.Category = OFW_New_Categories.Category" & vbcrlf
  24.  
  25.     sysDatabase.execute(cquery)
  26.  
  27.     CloseDatabaseOrder()
Jan 10 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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...
3
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:
7
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 ...
4
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...
10
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...
2
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...
2
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...
2
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. ...
4
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...
7
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",...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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...
0
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
0
BarryA
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...
0
marktang
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,...
0
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...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.