CREATE VIEW, Seperate One Column In Two Views..

Oct 17, 2007

I am creating a view for the table:
bellus=# select * from host_application_definition;
id | type_value | connection_value | group_value | application_value | host
----+------------+------------------+-------------+-------------------+----


From the table meta_host_types;

id | value | types | name
----+-------+-----------+--------
1 | agm | host-type | Rencid

I would like to seperate value into type_value and connection_value, because it holds both values.

Any tip?

bellus=# d host_application_definition;
Table "public.host_application_definition"
Column | Type | Modifiers
-------------------+---------+--------------------------------------------------------------------------
id | integer | not null default nextval('host_application_definition_id_seq'::regclass)
type_value | integer |
connection_value | integer |
group_value | integer |
application_value | integer |
host | integer |
Indexes:
"host_application_definition_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
"host_application_definition_application_value_fkey" FOREIGN KEY (application_value) REFERENCES appsmarteye(id)
"host_application_definition_connection_value_fkey" FOREIGN KEY (connection_value) REFERENCES meta_host_types(id)
"host_application_definition_group_value_fkey" FOREIGN KEY (group_value) REFERENCES meta_host_grouptypes(id)
"host_application_definition_host_fkey" FOREIGN KEY (host) REFERENCES master_hosts(id)
"host_application_definition_type_value_fkey" FOREIGN KEY (type_value) REFERENCES meta_host_types(id)



d meta_host_types;
Table "public.meta_host_types"
Column | Type | Modifiers
-------------+---------+---------------------------------------------------------------------
id | integer | not null default nextval('meta_types_application_id_seq'::regclass)
application | integer |
value | text |
comments | text |
types | text |
Indexes:
"meta_types_application_pkey" PRIMARY KEY, btree (id)
"meta_host_types_id_key" UNIQUE, btree (id)
"meta_host_types_value_key" UNIQUE, btree (value, application)
"meta_host_types_value_key1" UNIQUE, btree (value)
Foreign-key constraints:
"meta_types_application_application_fkey" FOREIGN KEY (application) REFERENCES appsmarteye(id)

View 3 Replies


ADVERTISEMENT

Create View Using Data In Seperate Severs

Oct 4, 2006

Hello:



I'd like to create a view on server x which references tables on an
entirely seperate server. Is this possible? Is seems
strange to have to copy the tables over just to create a view. In
the view wizard I can't seem to 'browse' to the tables on the other
server.



The code I'm working with would conceptually be something like this:



select server name.database instance.owner.table.field

from server name.database instance.owner.table

where <field name> like 'xxxx%'



or something along those lines.



Any help would be appreciated!



Thanks.

View 8 Replies View Related

How To Create Identity Column In Views

Mar 21, 2006

Hi there,

I'm new to SQL Server please help me, i want to create identity column(AutoNumber) when creating views.

View 6 Replies View Related

Create Multi Column View From Single Column Data

Jan 9, 2008

I have two tables, one a data table, the other a product table. I want to perform a join on the two tables with values distributed into columns based on the value in the month field.

data_table
product_code month value
350 1 10
350 2 20
350 3 30

product_table
product_code profit_center
350 4520

result_view

product_code profit_center mon1 mon2 mon3
350 4520 10 20 30

My current query gives the following result
result_view

product_code profit_center mon1 mon2 mon3
350 4520 10 0 0
350 4520 0 20 0
350 4520 0 0 30

Any direction toward a solution would be appreciated. Am using SS2005.

View 5 Replies View Related

DB Design :: Create Views From 2 Tables One Of Which Is Lookup Table That Will Give Column Names

Aug 5, 2015

I am trying a create views that would join 2 tables:

Table 1: Has all the columns need by a view (
Name: Product
Structure: ID, Attribute 1, Attribute 2, Attribute 3, Attribute 4, Attribute 5 etc
Table 2: Is a lookup table that provides the names of columns
Name: lookupTable
Structure: tableName, ColumnName, columnValue
Values: Product, Attribute1, Color
Product, Attribute2, Size
Product, Attribute3, Flavor
Product, Attribute4, Shape

I want to create a view that looks like

ID, Color, Size, Flavor, Shape

View 4 Replies View Related

Create A Rank Column In A View

Jan 14, 2008

Hi all!

I'm trying to script a view that does a simple query to some tables.
The catch is 2 of the columns are created on run time.
The first column is filled with a calculation with values of other columns. The 2nd column I would like to fill with the ranking of this calculated column

Example: (imagine caculatedcol is Sum(Col1+Col2+Col3)

Col1 Col2 Col3 CalculatedCol Ranking
10 10 10 30 1
9 9 9 27 2
8 8 8 24 3
7 7 7 21 4

How can I get the Ranking column filled based on the calculated column?

I'm desperate.
Thanks for any help.


---
Mário Ramos

View 8 Replies View Related

Create A Column In A View Without Data

Feb 28, 2008

Hey everyone,

I have a view that shows the email address and first name of a Membership table. I need to add a column to this view that doesn't have a corresponding column in the original table that has some default value.

i.e. the view currently shows:

John john@something.com

I need it to say:

John john@something.com EmailBlast

The third column will always have that value.

Anyone have a suggestion?

Thanks in advance!

--J

View 2 Replies View Related

How To Create A View With An Auto Number Column?

Apr 9, 2008

I have a View created from 2 tables. How do I add an autoindex (0,1,2,3,..) to a new column?

View 8 Replies View Related

CREATE VIEW - Script To Automate Column Names?

Mar 14, 2007

Hi,I'm trying to create views on all my existing tables and for that I'dlike to create a script or so.I don't want to specify the '*' for the columns in the create viewstatement. I prefer to specify the column names.I have the column names int sys.columns table but Do not know how tohandle them to have a statement like that:CREATE VIEW myVIEWWITH SCHEMABINDINGASSELECT col1name, col2name, col3name, etc...from sys.columns....?????.....Anyone can help?thx,Chris

View 1 Replies View Related

Create A Seperate Thread For A Winform In Script Task?

Nov 7, 2006

In order to provide runtime, realtime, graphical feedback to ETL operators, I am planning to open a new winform when my packages start, and update the form via polling of events.

It is my understanding that this means I need to create a new thread for the winform from within the script task. Anyone done this via script task yet? Any reason why this couldn't work or shouldn't be done from the script task?

Would I be better off writing the winform app completely seperately and simply call it from an "execute process" task?

Thanks,

Ken

View 3 Replies View Related

Inserting Values From Multiple Tables To Only One Column Of A Seperate Table

Dec 11, 2004

Hi all,

I want to produce some output for Mainframe application. For that I want to insert values from multiple table as source to a single column (huge in size)of a different table (Destination table). There may be same related records in all of the source tables with the primary key. When I export values from the source tables , each related records should be insterted to the destination table's field (multiple entries for each table). Please advise.

Thanks

View 5 Replies View Related

Write A CREATE VIEW Statement That Defines A View Named Invoice Basic That Returns Three Columns

Jul 24, 2012

Write a CREATE VIEW statement that defines a view named Invoice Basic that returns three columns: VendorName, InvoiceNumber, and InvoiceTotal. Then, write a SELECT statement that returns all of the columns in the view, sorted by VendorName, where the first letter of the vendor name is N, O, or P.

This is what I have so far,

CREATE VIEW InvoiceBasic AS
SELECT VendorName, InvoiceNumber, InvoiceTotal
From Vendors JOIN Invoices
ON Vendors.VendorID = Invoices.VendorID

[code]...

View 2 Replies View Related

Permissions To View INFORMATION_SCHEAM Views

Aug 9, 2002

SQL7, sp3

What specific permissions do you need to be able to view information_schema views? I thought public role had permissions to select on these views, but this is not the case? What do I do?

my developers have db_reader, db_writer, and db_ddladmin. They do not have db_owner. If I make them Sysadmin in sql they can view them, but that doens't fit in our security setup we have. THoughts?

Thanks,

View 2 Replies View Related

View That Unions Two Other Views Does Not Work

May 1, 2006

I created a view V1 that uses an outer join with a table and calls a sub-view VS1 (ds_proj_report_date) which uses an inner join) and does an inner join with VS1. I also created another view V2 that uses inner join but does not call the sub-view VS1.

When I run the two views as below it works fine

Select * from V1
Union
Select * from V2


I then created another view V3 of the above union as

Create view V3
As
Select * from V1
Union
Select * from V2

Now when I run select * from V3, I get the following error.
Joined tables cannot be specified in a query containing outer join operators. View or function 'ds_proj_report_date' contains joined tables

View 1 Replies View Related

View That Would Output Data From Two Views

Aug 8, 2007

OK,

I have two data tables where depending on the time line item it is, it needs a different join.

So, it's like this:

Table Credit Card
Table Memo

If Credit Card is VISA, join on column A
If Credit Card is MA, join on column B

So, I created two views. One view has all the info joined on column A. The other view has all the info joined on column B.

How do I create a third view that will output all the data from View A and View B without making it into a cartesian product?

I can't change the table structure due to legacy application/data issues.

Thanks!

View 3 Replies View Related

Problems On Create Proc Includes Granting Create Table Or View Perissinin SP

Aug 4, 2004

Hi All,

I'm trying to create a proc for granting permission for developer, but I tried many times, still couldn't get successful, someone can help me? The original statement is:

Create PROC dbo.GrantPermission
@user1 varchar(50)

as

Grant create table to @user1
go

Grant create view to @user1
go

Grant create Procedure to @user1
Go



Thanks Guys.

View 14 Replies View Related

Sql Views - Embedded View Work-a-rounds

Jul 11, 2007

hi guys,

i've been asked to re-write a sql view. the view itself contains several calls to other views (embedded). is there a way to get around using embedded views. I've written the same query up using temp. tables but obviously temp. tables can't be used in views?

Is there any special things I should be looking for?

View 2 Replies View Related

Does A View Refresh Itself When I Reference It? (was Question On Views)

Feb 24, 2006

guys, ive never worked with Views before so forgive me.
i know how to create one, and that it creates a virtual table in memory, but i've got one small question.

if i create a view:

CREATE view dbo.myView
as
select Distinct FirstName,LastName from SomeTable


When ever i reference that view, such as
Select FirstName,LastName
from myView
where LastName like 'Jo%'

does that View Refresh itself??

in other words does it run each time i Reference it??? or is it static from when i created it.

Wouldnt it be easier just to use a #TempTable or some other Table thats used to hold a few values?

thanks for any help
rik

View 3 Replies View Related

SQL Views - Embedded View Work-a-rounds

Jul 12, 2007

Hi guys,I've been asked to re-write a sql view. The view itself containsseveral calls to other views (embedded). Is there a way to get aroundusing embedded views. I've written the same query up using temp.tables but obviously temp. tables can't be used in views?Is there any special things I should be looking for?

View 2 Replies View Related

Transact SQL :: Combine Two Views Into One Statement Or One View

Oct 15, 2015

I'd like to get results from ZTest_Contract being my result set, and would like to combine the subquery (which gets the Max) into the primary view ZTest_Contract.

CREATE VIEW [dbo].[ZTest_Contract] AS
Select
M.CUSTNMBR,
M.ADRSCode,
M.Contract_number,
M.MaxWSCONTSQ,
M.Equipment_id,

[Code] ......

View 3 Replies View Related

Creating A Single View From 2 Existing Views

Aug 9, 2007

I have 2 views which contain the following fields:
EVENT,
WEEK,
SUBSCRIPTION,
QTY,
GROSS_AMOUNT,
SEASON

The 2 views differ by SEASON. I'm attempting to combine the 2 views in to a single view or table grouping by EVENT, WEEK and SUBSCRIPTION:

EVENT,
WEEK,
SUBSCRIPTION,
Q6 (qty of season 1),
A6 (gross_amount of season 1),
Q7 (qty of season 2),
A7 (gross_amount of season 2)


Below is my select command:

------

SELECT TOP 100 PERCENT
dbo.vw_SEASON06.EVENT,
SUM(dbo.vw_SEASON06.QTY) AS Q6, SUM(dbo.vw_SEASON06.GROSS_AMOUNT) AS A6,
SUM(dbo.vw_SEASON07.QTY) AS Q7, SUM(dbo.vw_SEASON07.GROSS_AMOUNT) AS A7,
dbo.vw_SEASON06.WEEK,
dbo.vw_SEASON06.SUBSCRIPTION

FROM dbo.vw_SEASON06 FULL OUTER JOIN
dbo.vw_SEASON07 ON dbo.vw_SEASON06.WEEK = dbo.vw_SEASON07.WEEK AND
dbo.vw_SEASON06.SUBSCRIPTION= dbo.vw_SEASON07.SUBSCRIPTION AND
dbo.vw_SEASON06.EVENT = dbo.vw_SEASON07.EVENT

GROUP BY
dbo.vw_SEASON06.EVENT,
dbo.vw_SEASON06.WEEK,
dbo.vw_SEASON06.SUBSCRIPTION

ORDER BY
dbo.vw_SEASON06.EVENT

-----

This creates the view but there are some issues. If an 'EVENT' exists in dbo.vw_SEASON07.EVENT and doesn't exist in dbo.vw_SEASON06.EVENT the value of the field 'EVENT' is set to NULL because the 'EVENT' name is returned from dbo.vw_SEASON06.EVENT. The same issue exists for 'SUBSCRIPTIONS' and 'WEEK'.

How can I create a single view/table that will include all the data from these 2 views without the NULL values in EVENT or SUBSCRIPTION?

Any help is appreciated!

View 7 Replies View Related

Im New To Using Views, And This Program They Have Me Working On Is Using Them Quite Heavily..(cant Read From A View)

Oct 11, 2007

This is my first post, so if i have not posted things in the best manner please lemme know how to be more informative,clear, so that i can learn.

So i have made a view with the following command



GO

/****** Object: View [dbo].[AppraisalView_C] Script Date: 10/11/2007 12:10:43 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER VIEW [dbo].[AppraisalView_C]

AS

SELECT a.Counter

,a.DateCreated

,a.DateModified

,a.UserCreated

,a.UserModified

,a.AppraisalDate_C

,a.TypeID_C

,a.Customer_C

,a.Employee_C

,b.Notes_C

,b.Value_C

,b.AppraisalLineItemID_C

,b.AppraisalID_C

FROM dbo.Appraisal_C AS a

INNER JOIN dbo.AppraisalLineItem_C AS b ON a.AppraisalID_C = b.AppraisalID_C



---------------------------------------------------------------------------------------

the program im working on creates the SQL call to read from this view and creates
the following query


SELECT A.[AppraisalDate_C], A.[AppraisalID_C], A.[AppraisalLineItemID_C], A.[Customer_C], A.[Employee_C], A.[Notes_C], A.[TypeID_C], A.[Value_C]

FROM AppraisalView_C A

WHERE [AppraisalView_C].[AppraisalID_C] = 'APP-000006'


but I end up getting the dreaded "Msg 4104, Level 16, State 1, Line 1 The multi-part identifier "AppraisalView_C.AppraisalID_C" could not be bound." error....

I cant change the Query that is called, but i can change the view, what is wrong?

View 4 Replies View Related

Using EM To Create Views

Jun 6, 2000

When I create a view using Enterprise Manager, I can click on the 'Add Table' button to select a table. Is there any way I can tell EM that I want to include a table from another server?

Thanks,

Randy

View 1 Replies View Related

Grant CREATE VIEW, CREATE PROCEDURE ...

Apr 12, 2006

Hi,

I have currently a problem with setting up the permissions for some developers. My configuration looks like this.

DB A is the productive database.

DB B is a kind of "development" database.

Now we have a couple of users call them BOB, DAVID, ...

who are members of the db role db_reader and db_writer for the productive db a but they should be allowed to do nearly everything on db b.

Therefor I added them to the db role db_owner for db b.

For testing purposes I tried to "CREATE" a view TEST as BOB in database B but I received the error message

'Msg 262, Level 14, State 1, Procedure Test, Line 3

CREATE VIEW permission denied in database 'b'.'

I cross checked the permissions on db level and I even granted all available permissions on db level but nevertheless I receive this error message.

What's my mistake?

Of course it worked fine when I give them sysadmin rights but then they have far too much permissions.

Regards,

Stefan

View 8 Replies View Related

Alter View / Create View

Aug 14, 2000

I had given one of our developers create view permissions, but he wants to also modify views that are not owned by him, they are owned by dbo.

I ran a profiler trace and determined that when he tries to modify a view using query designer in SQLem or right clicks in SQLem on the view and goes to properties, it is performing a ALTER VIEW. It does the same for dbo in a trace (an ALTER View). He gets a call failed and a permission error that he doesn't have create view permissions, object is owned by dbo, using both methods.

If it is doing an alter view how can I set permissions for that and why does it give a create view error when its really doing an alter view? Very confusing.

View 1 Replies View Related

View Of All User Objects (Tables, Views) With Their Replication State NEEDED...

Jun 22, 2007

Hi!



There is a view in our replicated SQL-2000 database, that returns all user tables and views with replication state (0 if not included into publication, 1 if included):






Code Snippet

CREATE VIEW [dbo].[ViewREPL_PublishedObjects]

AS

SELECT TOP 100 PERCENT

CASE [xtype]

WHEN 'U' THEN 'Table'

WHEN 'V' THEN 'View'

ELSE NULL END AS [Object Type],

[name] AS [Object Name],

CASE WHEN [replinfo] = 0

THEN 0 ELSE 1

END AS [Replicated]

FROM [sysobjects]

WHERE

[xtype] in ('U', 'V')

AND [status] > 0

ORDER BY

(CASE [xtype]

WHEN 'U' THEN 1

WHEN 'V' THEN 2

ELSE 10

END),

[name]



Now we need to upgrade our database to SQL-2005, but [sysobjects] table have been changed, so neither Replicated state could be determined according on [replinfo] column value, nor User/System object according on [status].



So, I need a view with same functionality, that will work under SQL-2005 and 2008.



Please, help!

View 2 Replies View Related

How To Create Parameterised Views?

Jun 15, 2007

I am using SqlServer2005 and asp.net 2005. I have a large database for which I have to provide reports for it. I need a report that user will specify a date, and the report will be run, from this month & year and I will calculate the first day of the month and the last day of the month and these will serve as the input parameters for a long SELECT query.For my previous reports i've used views . But for this functionality i need  a parameterized view, which i cant create.Please help me how to create a parameterized view.... Thanks in Advance... 

View 3 Replies View Related

Create Views Not Tables

Jun 9, 2004

I want to allow a group of users to create views but not be able to create new tables or stored procedures... how can I do this ??

Thanks, John :eek:

View 1 Replies View Related

Create Views With Union

Sep 17, 2007

Hey

I am very new to database and have a question about views, that I hope someone can help me with, i am sure its simple:

I have to tables for storing different users, I want(for a log in function),to make a view that combine these to tables.

so all names stored in table1 under column customer_name, and all names stored in table2 under column name contact_name will in the view be stored under column username.

What shall a do?

Thanks for all help

View 10 Replies View Related

Using Variables To Create Views

May 8, 2007

I am stuck on creating views using the variables. I keep on getting the 'CREATE VIEW' must be the first statement in a query batch error. I understand that views need to be the first statement, but I have a lot of views that need to reference specific variables - is there any way to do this?

The code I am using is as follows:

DECLARE @view varchar(MAX)
DECLARE @database varchar(30)
SET @database = 'KateTEST3'

--Insert views
SET @view = 'USE ['+@database+']
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON;

CREATE view [dbo].[userssupplier]
as
SELECT *
FROM dbo.Users
WHERE (User_Type = 4.0) OR
(User_Type = 5.2)'
EXEC(@view)





Thanks

View 11 Replies View Related

SQL Server Admin 2014 :: How To Grant User Permission To View Specific Views

Aug 5, 2015

I have a user who needs access to views like(dbo.viewnameabc1,dbo.viewnameabc2 and so on...) dbo.viewnameabc* and anytime the user creates the view he already have the permission to view those views....

View 3 Replies View Related

Create Views In The Order Of Their Dependency

Feb 5, 2007

In SQL 2K...i need to write a script that writes a script that creates all views in the order that they are nested and I am feeling lazy. Does anyone have anything handy?For example if View_BOB says...CREATE VIEW VIEW_BOBASSELECT COL_1 FROM VIEW_JOHNI need the script to generate a script that creates View_JOHN before View_BOB.

View 1 Replies View Related

Can Not Create Views, Tables Etc * URGENT*

Jul 20, 2005

Hi,I am not getting option as 'new view' and 'new table' when I rightclick onviews and tables option in VisualStudio.net IDE server explorersqlservers database to create new objects.Looks like some setup issue in my database.Thanks for your help in advance.RgdsCV

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved