View / Underlying Column Definition Metadata

Mar 18, 2008

Have many views based on legacy tables that have different table and column names. Want to create a table that shows view table / column and underlying table column, e.g.

CREATE VIEW [dbo].[Branch]
AS
SELECT

divbra_id BranchID,
cmpny_id CompanyID,
divbra_cde BranchCode,
divbra_nme BranchName

FROM MyDatabase.dbo.divbranc

GO

is an existing view. I want to pull out the following metadata:

divbranc divbra_id Branch BranchID
divbranc cmpny_id Branch CompanyID
divbranc divbra_cde Branch BranchCode
divbranc divbra_nme Branch BranchName

Is there anyway to get this from SQL metadata without actually parsing the view SELECT statement in code?

View 7 Replies


ADVERTISEMENT

Fetch Metadata From A Column With An Alias In A View

Aug 2, 2007

Hi!

I have created a view and one of the columns in the view has an alias assigned to it.

I'm able to read the metadata from INFORMATION_SCHEMA.VIEW_COLUMN_USAGE and also lookup
from which table each column in the view orginated from except for the column that has an alias assigned to it.

Is there any other way to lookup a column that has an alias assigned to it?


Thanks alot!

Adam

View 2 Replies View Related

Metadata Definition ?

Apr 5, 2006

Hello, i would like to know if it's possible to generate automatically a word document or an excel document that will contain all the metadata definition, for example containing the source columns names, their datatype, and the destination with their datatypes, so that it would easy to create a data dictionnary .

Thank you in advance.

View 2 Replies View Related

Different Query Plans For View And View Definition Statement

Mar 9, 2006

I compared view query plan with query plan if I run the same statementfrom view definition and get different results. View plan is moreexpensive and runs longer. View contains 4 inner joins, statisticsupdated for all tables. Any ideas?

View 10 Replies View Related

Triggers On Tables Underlying A Partitioned View

Jul 23, 2005

We have a partitioned view with 4 underlying tables. The view and eachof the underlying tables are in seperate databases on the same server.Inserts and deletes on the view work fine. We then add insert anddelete triggers to each of the underlying tables. The triggers modifya different set of tables in the same database as the view (differentthan the underlying table). The problem is those triggers aren't firedwhen inserting or deleteing via the view. Inserting or deleteing theunderlying table directly causes the the triggers to fire, but not whenthe tables are accessed as a result of using the view.Am I missing something? The triggers are 'for insert' and 'fordelete'. No 'instead of' or 'after' triggers.

View 4 Replies View Related

Can A View Be Used To Modify More Than One Underlying Table With A Single Statement In MS SQL?

Mar 20, 2008

What's the answer for this and how ? If it is yes then How ?

View 4 Replies View Related

Permission On View. Is There Way To Avoid Granting Persmission On The Underlying Table?

Jul 13, 2007

I want to grant access on the below view for an end user so that he connect to our SQL server and retrieve data. The view looks like the below


CREATE VIEW DB1.[dbo].[View1]
AS
-- For brevity, I made it as simple statement.
SELECT *
From DB2.dbo.table2
GO

For the above view, it looks like I have to grant select and connect permission for the DB1. [dbo].[View1] as well as DB2.dbo.table2.

1. Is my understanding correct?

2. I want the user to access only DB1. [dbo].[View1] and not the underlying tables. Is there a way to grant access only on the view and execute the statement on a different security context so that the user can€™t access DB2.dbo.table2 directly?

3. When the user uses SQL Server Management Studio to connect to SQL server, he is able to connect and select DB2.dbo.table2 directly. Is there any way to restrict user from viewing and executing select statement on DB2 database from SQL Server Management Studio

Thanks in advance for your help

With regards
Ganesh

View 5 Replies View Related

SQL 2012 :: Allow User To Select Data Through A View But Not Restrict Access To Underlying Table?

Sep 29, 2015

I have two databases DB1 and DB2 DB1 has a source table named 'Source' I have created a login 'Test_user' in DB2 with Public access. I have also created a view named 'Test_view' in DB2 which references data from DB1.dbo.Source

How can I do the following: AS A Test_user

SELECT * FROM DB2.dbo.Test_view --Should work

SELECT * FROM DB1.dbo.Source --Should Not work

View 2 Replies View Related

Transact SQL :: Allow A User To Select Data Through A View But Not Restrict Access To Underlying Table

Sep 29, 2015

I have two databases DB1 and DB2 DB1 has a source table named 'Source' I have created a login 'Test_user' in DB2 with Public access. I have also created a view named 'Test_view' in DB2 which references data from DB1.dbo.Source

How can I do the following: AS A Test_user

SELECT * FROM DB2.dbo.Test_view --Should work

SELECT * FROM DB1.dbo.Source --Should Not work

View 3 Replies View Related

IF Statement In View Definition

Apr 7, 1999

We are trying to create a view that references lengths in both metres and feet.

What we want to do is to create a baselength column which either holds the value of the metres column or calculates the metric value of the feet column if there is no value in the metric column.

We can do all the maths for the calculations etc, it is just putting the IF statement into the view to test the values that we are struggling with.

Any help would be appreciated.

Thanks

View 2 Replies View Related

View Definition From Schema

Mar 12, 2004

I'm using the following to get table/column names:

select so.name, sc.name
from sysobjects so, syscolumns sc
where so.id = sc.id
and so.type = 'U'
order by so.name, sc.colid

What is the equivalent for views?

Thanks

View 4 Replies View Related

Can You Use Cursors Within A View Definition?

May 13, 2008



I want to create a view on the table "workorder" that contains a serial id "woid". Another table, "wo_comment" contains multiple comments for each "woid".

I would like to create a view view_workorder with a column "allcomments" that is basically a concatenation of all the comments within the table "comment".

Table: workorder has columns: woid, startdate (plus many others)
Table: wo_comment has columns: woid, comment, sequence

Desired View: view_workorder has columns: woid, startdate, allcomments

I tried to create a view as follows but get errors concerning the "CURSOR" statement making me wonder if I can use declarations and CURSORS within a view?


create view [workorder_view] as (
Select
w.woid,
w.startdate,
cast( DECLARE @all_comments nvarchar(4000),
@curr_comment nvarchar(256)
DECLARE wo_comment_cur CURSOR
FOR
SELECT woc.Comments
FROM WO_Comment as woc
WHERE woc.woid = w.woid
OPEN wo_comment_cur
FETCH NEXT FROM wo_comment_cur INTO
@curr_comment
WHILE (@@FETCH_STATUS = 0)
BEGIN
Set @all_comments = @all_comments + @curr_comment
FETCH NEXT FROM wo_comment_cur INTO
@curr_comment
END
CLOSE wo_comment_cur;
DEALLOCATE wo_comment_cur;
as nvarchar(80000)) as COMMENTS

from workorder AS w

Thanks for any help you can provide!

View 4 Replies View Related

SQL 2012 :: View Definition Of Objects?

Sep 8, 2014

I want to create a login with some restriction like the following...

1.I will create a login and ll mapped to a particular DB with the Database Role 'db_datarerader' only,
2.We wants to display the all objects under a DB but we don't want to provide the View Definition to that particular Login.
3.If we Deny the View definition option he can't able to see the Objects which are there under the DB.
4.So My Clear Question is we want to display the Object like tables ,Sps...etc and we don't want to allow him to view the definition of those objects....

View 3 Replies View Related

SQL 2012 :: Grant View Definition

Nov 19, 2014

I'd like to find out whether or not people grant VIEW DEFINITION to their developers in UAT and PROD environments. My view is that a developer shouldn't be able to touch a PROD environment at all (we also include UAT as PROD), and any issue in a production environment should be investigated by a DBA and escalated to the dev if necessary.

View 1 Replies View Related

COUNT_BIG() In Indexed View Definition.

Apr 1, 2008

Hi,

When I am trying to create an indexed view using group and COUNT(*), it gave me the following error:

€œMsg 10136, Level 16, State 1, Line 2
Cannot create index on view "AdventureWorks.Sales.vOrders" because it uses the aggregate COUNT. Use COUNT_BIG instead.€?

When I refered the SQL Books Online, I found the following statement: €œIf GROUP BY is present, the VIEW definition must contain COUNT_BIG(*) and must not contain HAVING€?.

Though my question is basic, I am curious to know the difference between COUNT() and COUNT_BIG(). The only difference I knew is COUNT_BIG() returns bigint. If this is the only difference, why can€™t we use COUNT() in indexed view definition and why COUNT_BIG() is allowed?


Regards,
-Aazad.

View 5 Replies View Related

SQL 2012 :: Get View Definition Using Modules With Linebreaks

May 6, 2014

SELECT [DEFINITION]
FROM SYS.SQL_MODULES WHERE [OBJECT_ID] = OBJECT_ID(@OBJECTNAME)

I know I can use SP_HELPTEXT to get linebreaks, The reason I want to use this is I can exclude comments section from SQL_Modules, but cannot exclude the comments section from SP_HELPTEXT.

View 1 Replies View Related

View Definition Includes No Output Columns ...

Jan 18, 2007

hello all,

i am trying to create a view but i keep getting the error 'View definition includes no output columns or no items in the FROM clause.'

below is the select statement that's the basis of my view. the explanation i got from the F1 help of enterprise manager was ...
View definition includes no output columns or no items in the FROM clause.
A view definition must have at least one table or table-structured object in the FROM clause, and must have at least one column in the select list. The view definition is missing one or both. Modify the view definition accordingly.


query:

select
Case_CaseId,
Logged,
CAST(DATEDIFF(minute, Logged, Waiting)/60.0 AS NUMERIC(9, 2)) AS Waiting,
CAST(DATEDIFF(minute, Logged, Investigating) /60.0 AS NUMERIC(9, 2)) AS Investigating,
CAST(DATEDIFF(minute, Logged, Rejected) /60.0 AS NUMERIC(9, 2)) AS Rejected,
CAST(DATEDIFF(minute, Logged, Resolved) /60.0 AS NUMERIC(9, 2)) AS Resolved,
CAST(DATEDIFF(minute, Logged, Solved) /60.0 AS NUMERIC(9, 2)) AS Solved,
CAST(DATEDIFF(minute, Logged, Closed) /60.0 AS NUMERIC(9, 2)) AS Closed
from
(

SELECT
Case_CaseId,
MIN(CASE WHEN case_stage = 'Logged' THEN Case_CreatedDate END) AS Logged,
MIN(CASE WHEN case_stage = 'Waiting' THEN Case_CreatedDate END) AS Waiting,
MIN(CASE WHEN case_stage = 'Investigating' THEN Case_CreatedDate END) AS Investigating,

AS Rejected, MIN(CASE WHEN case_stage = 'Resolved' THEN Case_CreatedDate END) AS Resolved,
MIN(CASE WHEN case_stage = 'Solved' THEN Case_CreatedDate END) AS Solved,
MIN(CASE WHEN case_stage = 'Closed' THEN Case_CreatedDate END) AS Closed
FROM
CaseProgress
GROUP BY Case_CaseId
) as temp
order by Case_CaseId

View 2 Replies View Related

Indexing View Definition Table Columns

Sep 29, 2007

Hi experts,


Im very very new to sql server world..wanted to know what kind of indexes to be created on the below mentioned table columns for making this view run fastly.As of now there are no indexes created on these view definition columns


CREATE View hrinu.Parity as
select
T1.Matcle as CorpID,
T2.Nmpres as Name,
T4.DATDEB as LeaveFrom,
T4.TEMDEB as PM,
T4.DATFIN as LeaveTo,
T4.TEMFIN as AM,
T10.LIBLON as LeaveType,
T8.LIBLON as Location,
T12.LIBLON as ParentOrg

from HRINU.zy00 T1,
HRINU.zy3y T2,
HRINU.zy39 T3,
HRINU.zyag T4,
HRINU.zy38 T5,
HRINU.zy1s T6,
HRINU.zd00 T7,
HRINU.zd01 T8,
HRINU.zd00 T9,
HRINU.zd01 T10,
HRINU.zd00 T11,
HRINU.zd01 T12
where T4.Nudoss = T3.nudoss
and T4.Nudoss = T1.Nudoss
and T1.Nudoss = T2.nudoss
and T3.nudoss = T5.nudoss
and T6.nudoss = T1.nudoss
AND T7.NUDOSS = T8.NUDOSS
AND T9.NUDOSS = T10.NUDOSS
AND T11.NUDOSS = T12.NUDOSS
AND T3.IDWKLO = T7.CDCODE
AND T4.MOTIFA = T9.CDCODE
AND T5.IDESTA = T11.CDCODE
and T6.stempl = 'A'
and t7.cdstco = 'z04'
AND T8.CDLANG = 'U'
and t9.cdstco = 'DSJ'
AND T10.CDLANG= 'U'
and t11.cdstco= 'DRE'
AND T12.CDLANG= 'U'
and T4.DATDEB <= T3.DTEN00 and T4.DATFIN >= T3.DTEF00
and T3.DTEN00 <= T5.DTEN00 and T3.DTEN00 >= T5.DTEF00
and T6.dtef1s <= getdate() and T6.datxxx > getdate()


Also Please suggest me some links where i can get info about the indexes that has to be created on these types of queries where joins are involved on these many tables.
Also throw some light on how to analyse the execution plan for further enhancements.



Thanks in advance


Regrds
Arvind L

View 3 Replies View Related

SQL Security :: View Definition Permission On Target Database

May 15, 2015

I am trying to do a schema compare and data compare via VS2012 and I am getting below error: The reverse engineering operation cannot continue because you do not have View Definition permission on the 'Target' database.

Whats interesting is I created a viewdefinition role and added the group(to which the user belongs) to the role. However I dont get the error if I make the group the dbowner. Is this a bug?

View 2 Replies View Related

How To Get Information From System Table Or View For Trigger's Definition

May 29, 2008

Such as check all triggers that assign value to some columns ?

Thank you very much.

View 1 Replies View Related

SQL Server 2008 :: Granting Explicit View Definition Permissions On Stored Procedure To DBO?

Mar 6, 2013

The developers in our shop have a need to explicitly grant view definition permissions to themselves on stored procedures they create in their development databases. They have dbo level permissions in these databases and although they can explicitly grant view definition permissions to other developers in the same database, they are unable to do so for themselves. When they attempt this, it appears that they are successful but when they check the stored procedure afterwards the permission is not there for themselves.

While this does not cause an issue in development, the intention is for these view definition permissions to be carried forward to the test and production databases where they only have datareader permissions.

When these stored procedures are scripted out by the dba to move to Test and Production the view definition permissions are not scripted out for the developer in question.

Is there a way that a developer with dbo rights in a database can explicitly grant themselves view definition permissions on a stored procedure they create as dbo?

View 9 Replies View Related

Matching A View's Columns To It's Underlying Table's Columns

Jul 20, 2005

Hello,Using SQL Server 2000, I'm trying to put together a query that willtell me the following information about a view:The View NameThe names of the View's columnsThe names of the source tables used in the viewThe names of the columns that are used from the source tablesBorrowing code from the VIEW_COLUMN_USAGE view, I've got the codebelow, which gives me the View Name, Source Table Name, and SourceColumn Name. And I can easily enough get the View columns from thesyscolumns table. The problem is that I haven't figured out how tolink a source column name to a view column name. Any help would beappreciated.Garyselectv_obj.name as ViewName,t_obj.name as SourceTable,t_col.name as SourceColumnfromsysobjects t_obj,sysobjects v_obj,sysdepends dep,syscolumns t_colwherev_obj.xtype = 'V'and dep.id = v_obj.idand dep.depid = t_obj.idand t_obj.id = t_col.idand dep.depnumber = t_col.colidorder byv_obj.name,t_obj.name,t_col.name

View 2 Replies View Related

SQL Server 2012 :: Parameter Datatypes Linked To Underlying Table Column Datatype

Jun 5, 2014

In Oracle when i create any procedure i define parameter datatype linked to under lying table.

For ex
create procedure testprocedure
(param1 customer.name%type,
param2 customer.salary%type )

Here i have defined param1 and param2 with datatype of name and salary of customer table respectively.

This way i do not need to worry about modifying param1 and param2 datatypes when datatypes of name & salary of customer table changes in future.

How can i accomplish this in SQL server.

View 2 Replies View Related

Comment In Column Definition

Apr 30, 2007

Plesae tell me the MSSQL Server equivalent of the below MySQL query .create table temp2(a varchar(23) comment 'male m');What is the use of specifying a keyword 'comment' in the column definition. Will it make any difference

View 14 Replies View Related

How To Get Column Description From MetaData?

Mar 25, 2008



I've tried looking in sys.syscolums and sys.syscomments, but I can't seem to find where the Description information is retain for a Field in the system tables -- any hints?

Thanks, Rob.

View 2 Replies View Related

SQL Table And Column Metadata

Jun 21, 2006

SQL table and column metadata

Is there a way to add or update the column or table (using the extended properties) description metadata via T-SQL (from within a stored procedure) or via a program (such as VB.NET using ADO)?

These metadata properties are available via the SSMS interface:
Columns via the Column Properties/Table Designer/Description
Tables via the Table Properties/Extended Properties/[Extended Property Name]

Thanks in advance,
Mark

View 6 Replies View Related

External Metadata Column Error

Oct 25, 2007

I keep getting the following error in SSIS. Also, I don't get the error on every server the package is run on, but less than 5 (the package is run on over 100).

"The external metadata column collection is out of synchronization with the data source columns. The column "Timestamp" needs to be added to the external metadata column collection"

Please tell me where I need to remove Timestamp from. Thanks

-Kyle

View 1 Replies View Related

External Metadata Column Error

Oct 24, 2007

I keep getting the following error in SSIS. Also, I don't get the error on every server the package is run on, but less than 5 (the package is run on over 100).

"The external metadata column collection is out of synchronization with the data source columns. The column "Timestamp" needs to be added to the external metadata column collection"

Please tell me where I need to remove Timestamp from. Thanks
-Kyle

View 1 Replies View Related

Finding Logins That Have GRANT CONTROL And GRANT VIEW DEFINITION

Jul 21, 2015

Have a certificate and symmetric key that i have used the following to GRANT to logins. How can I find out which SQL logins have the GRANT CONTROL and GRANT VIEW DEFINTION?

GRANT VIEW DEFINITION ON SYMMETRIC KEY:: Symetric1 TO Brenda
GRANT CONTROL ON CERTIFICATE:: Certificate1 to Brenda

View 5 Replies View Related

String Or Binary Data Would Be Truncated When Using Default Column Definition

Nov 22, 2007



When I set a column to have a default definition that uses a UDF, I am receiving the "String or binary data would be truncated" error.

The UDF:




Code BlockALTER FUNCTION GetDefaultClientTier
(
@ClientAssets decimal(15,2)
)
RETURNS char(1)
AS
BEGIN
DECLARE @Result char(1)
-- Get the first result in case of overlaps.
SET @Result = CAST((SELECT TOP 1 ClientTier FROM ClientTiers WHERE @ClientAssets BETWEEN ClientAssetsFloor AND ClientAssetsCeiling) AS char(1))
RETURN @Result
END





ClientTier is defined as char(1) in the table. I simply have (isnull([dbo].[GetDefaultClientTier]([ClientAssets])),(null))) as the definition. I can't use a computed column because I the values need to be editable. When inserting with SSIS, the insert works fine but the column has a value of null for each row.

When putting a character as the default (like 'A') the insert works fine.

The cast is there only because I have tried everything I can think of to get around this.

Is there something simple I am overlooking?

(SQL2005 SP2)

Thanks!

View 3 Replies View Related

Column Metadata From Connection Manager Programmatically

May 9, 2006

Hi all!

My problem I've been struggling with is the following. I have a set of text files (around 70), each with different column numbers and types. I define Flat File Connection Managers for each of them where I can nicely rename, set data types and omit certain columns. I do this once and this will be the basis for the rest of the data process (would be nice programmatically too actually).
I would like to pump each of these text files into SQL Server tables using CREATE TABLE and BULK INSERT (because do it one-by-one is really a pain). The question is:

is there a way to obtain column information (Script Task) from a Connection Manager so I can run CREATE TABLE-s? I just need the names, data type for each nothing fancy...

(I bumped into interfaces like IDTSConnectionManagerFlatFileColumns90, which I cannot handle from the Script Task.)

Any help appreciated!

View 6 Replies View Related

Integration Services :: Column Metadata In Table

Apr 10, 2015

I am having one store procedure which use to load data from flat file to staging table dynamically.everything is working fine. staging_temp table have single column.all the data stored in that single column below is the sample row.

AB¯ALBERTA ¯93¯AI
AI¯ALBERTA INDIRECT ¯94¯AI
AL¯ALABAMA ¯30¯ 

after the staging_temp data gets inserted into main table.my probelm is to handle such a file where number of columns are more than the actual table.if you see the sample rows there are 4 column separated by "¯".but actual I am having only 3 columns in my main table.so how can I get only first 3 column from the satging_temp table.output should be like below.

AB¯ALBERTA ¯93
AI¯ALBERTA INDIRECT ¯94
AL¯ALABAMA ¯30

View 45 Replies View Related

The External Metadata Column Collection Is Out Of Synchronization...

Mar 12, 2008

Hi,

I have an Excel file source. I keep getting this error when running the package:

"The external metadata column collection is out of synchronization with the data source columns. The column "x" needs to be updated in the external metadata column collection."

When I get this error with regular flat files, it's because I've changed the data type of a given column in the flat file connection manager. And I resolve it simply by double-clicking on the flat file source task, and viola - it corrects it for me.

How do I correct this with an Excel file? Help.

Thanks

View 10 Replies View Related







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