How To Find The Tables In A View

Nov 15, 2006

Dear friends,
is there any way to find the table names from a view?

ex: suppose i have a view named as vorganization.i need all the tables in this view. is it possible to get through a query? same case for procedures and functions also.........

or we have to use sp_helptext?


is there any better way?

thank you very much.

Vinod

View 12 Replies


ADVERTISEMENT

Anything That You Find In SQL Object Scripts, You Can Also Find Them In System Tables?

Jul 26, 2005

I tried all the INFORMATION_SCHEMA on SQL 2000 andI see that the system tables hold pretty much everything I aminterested in: Objects names (columns, functions, stored procedures, ...)stored procedure statements in syscomments table.My questions are:If you script your whole database everything you end up havingin the text sql scripts, are those also located in the system tables?That means i could simply read those system tables to get any informationI would normally look in the sql script files?Can i quickly generate a SQL statement of all the indexes on my database?I read many places that Microsoftsays not to modify anything in those tables and not query them since theirstructure might change in future SQL versions.Is it safe to use and rely the system tables?I basically want to do at least fetching of information i want from thesystem tables rather than the SQL script files.I also want to know if it's pretty safe for me to make changes in thesetables.Can i rename an object name for example an Index name, a Stored Procedurename?Can i add a new column in the syscolumns table for a user table?Thank you

View 4 Replies View Related

SQL View Using The CASE Try To Find The @

Oct 20, 2005

have created a view in MS SQL2000 as followed:

Select order_NO, shiptoname, Shiptoaddress, Shiptocity,shiptostate, shiptozip,
EMAILaddress
FROM orders;

my question is: If the email @ sign exist in the EMAILaddress column then I need to have a Y show in another column called EMAILflag, if the @ sign does not exist then I would need the EMAILflag to be a N.

This what I have but the emailaddress column is not always null it just has spaces in the field.
Select order_NO, shiptoname, Shiptoaddress, Shiptocity,shiptostate, shiptozip,
EMAILaddress, CASE WHEN emailaddress IS NULL THEN 'N' ELSE 'Y' END AS emailflag
FROM orders;

Any HELP would be GREAT.
Thank You!!

View 2 Replies View Related

Find Correct Db Where View Is

Mar 19, 2008

Hi,

Is there a way to write a select statement in order to find out which database a certain view is in? One way is to write "select * from view" and switch between available databases until "Invalid object name 'vw_X'" does not show.

Any other ways?

View 3 Replies View Related

SQL Server 2012 :: How To Find Whether Object Is Used By Any SP / View

Nov 19, 2013

How to find whether an object is used by any sp , view ?

I need a query which will result the sp , view names which uses the given object name .

View 6 Replies View Related

Inline View To Find Arrivals Within Days Period

Oct 4, 2013

I have this query:

SELECT a.*
FROM Unscheduled_Arrival a INNER JOIN (SELECT Person_ID
,[arrival date]
,[leaving date]
,[unique stay id]
,[area code]
FROM Unscheduled_Arrival

[Code] ....

And what I am trying to do is find instances where a person has arrived back at a different area within 7 days of leaving from a planned visit to any other area different from the last. so lets say we had person ID = 1 and they had had 3 planned visits to one area (not equal to area_gh) in the last 4 months but after the 2nd planned trip to the other area, and before the commencement of the 3rd planned trip to any area not equal to area_gh, they had arrived unscheduled to area_gh, and this unplanned visit was within 7 days of leaving the 2nd last planned visit to any area not equal to area_gh.

The query I have shows data from unscheduled arrivals to the area_gh for a person who has also had visits to any area other than area_gh, but each record for unscheduled visits to area_gh duplicates for the amount of times the person has had scheduled visits to any area not equal to area_gh. This is the first problem but is as a result of not having the correct SQL for the refinement of the data.

This refinement requires that I return only the data that relates to the unscheduled arrival that is within 7 days of the last scheduled arrival, not duplicate rows of area_gh visits for all the scheduled arrivals.

Because my data is showing the data I want but the count is related to the scheduled arrivals I think I need to rewrite the query or alter it.

The data is already restricted to a year's worth of data.

I just need to find any instances of unscheduled arrivals (for arrival at area_gh) within 7 days of the end of any scheduled arrival (determined using leaving date) to area equal to area_gh.

There can be any number of scheduled arrivals and any number of unscheduled arrivals for each person. The [unique stay id] is distinct for each visit so person 1 can have 3 stays, all with a different [unique stay id].

View 3 Replies View Related

Why Don't You Guys Provide A Way To Find Out The Dependancies Of Any Object (SProc, Table, View And Etc...) Within SQL Server...

Nov 15, 2007



Why don't you folks (SQL SERVER Management Studio Team or SQL SERVER Database Engine Team) provide an option by using which I would be in a position to know what all the other objects are depended on a selected object and vice versa. That means:



When I select a Table within the SQL SERVER Management Studio if there is an option for understanding "Which all the objects (tables or views) it is depended on (I mean Foreign key and etc... kind of relations) and also Which all the objects (Tables, Views, Stored Procedures and etc...) are using this table", It would be of great help for all developers.



I can be contacted over kotis@microsoft.com

I BLOG @ http://blogs.msdn.com/kreddy

View 3 Replies View Related

Find A Key In All Tables

Oct 28, 2013

I have many tables that have as one of its keys POLICY_NUMBER is there a way to write a script that will look in all tables in a db for a certain POLICY_NUMBER

View 5 Replies View Related

Find Tables With No PK

Jan 27, 2004

I modified my origianl script (used a cursor) to use a looping method I saw in a different thread http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=30286 by Nigel Rivett. Since I used code on this board I though I would post back for the greater SQL Team script toolbox. Feel free to use it to catch those deliquent sql programmers who forget to create a PK. Enjoy.



declare @database varchar(128) ,
@maxdatabase varchar(128) ,
@cmd nvarchar(1000)

create table #pk (databasename sysname, tablename sysname)

select @database = '', @maxdatabase = max(name) from master.dbo.sysdatabases where dbid > 5
while @database < @maxdatabase
begin
select @database = min(name) from master.dbo.sysdatabases where dbid > 5 and name > @database

set @cmd = 'select ''' + @database + ''', o.name from ' + @database + '.dbo.sysobjects o join ' + @database + '.dbo.sysindexes i on o.id=i.id
where o.xtype=''U'' and i.indid = 0'

insert into #pk exec sp_executesql @cmd
end

select * from #pk

drop table #pk


- Eric

View 10 Replies View Related

Find Available Tables In A DB

Mar 20, 2008

I am brand new to using SQL. I created a DB with a bunch of tables there. What I would like to do is from my VB.NET application I would like to allow the user to see what tables are available in that DB.



Also I need a way to check if a table exists. I used the following:

strTemp = "IF EXISTS " & _
"(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'simplesql') AND type in (N'U'))"
cmd.Connection = conncmd.CommandType = CommandType.Textcmdcmd.ExecuteNonQuery()

but I get an exception : Incorrect syntax near ')'

thanks for your help

View 4 Replies View Related

How To Find All The Tables Which Are In Database

Feb 24, 2008

 Hi......i want to find all the tables which are in database. is there any hint or code that can help meThanks in advance

View 4 Replies View Related

Find Tables With Column Name

Oct 16, 2006

How can I find all the tables with a specific column name?

View 3 Replies View Related

How To Find Out Tables Which Can't Be Replicated

Jun 22, 2004

Is there any query to find out all the tables without a Primary key or without a Unique index ?

View 3 Replies View Related

Find Same Coumn In Other Tables

Jun 9, 2008

Is there any way i can find some certain fields in the whole database? like i know a column called Type_ID in table Sys_Type, how can i know there are same Type_ID column in other tables? Thanks in advance.

View 2 Replies View Related

Find All Differences Between 2 Tables

Mar 5, 2015

I have this 2 tables:

Table1: Table2:

ID Value ID Value
--------- ---------
1 2 2 1
2 1 3 4
4 3 4 4I

need to find all differences between the 2 Tables.

A mismatch can be:

- Table1.ID exists, Table2.ID does not exist
- Table2.ID exists, Table1.ID does not exist
- Table1.ID = Table2.ID and Table1.Value <> Table2.Value

So I want to be returned:

ID Value ID Value
--------------------
1 2 NULL NULL
4 3 4 4
NULL NULL 3 4

There must be something simpler than the solution I came up with which is:select * from Table1 a full outer join Table2 b on a.Id = b.Id

WHERE a.value <> b.value or (a.value IS NULL and b.value IS NOT NULL) or (a.value IS NOT NULL and b.value IS NULL)Martin

View 4 Replies View Related

How To Find No. Of Databases And Tables?

Mar 26, 2008

Hi,
is there any way to find out the no. of databases and
no. of tables in a particular database using a sql query ???

If any server variable is used then please mention that???


thanx in advance

San

View 20 Replies View Related

How Can I Find Connection Between Two Tables???

Mar 19, 2008

Hi,

I have a database with 150 tables.
I need to find connections between specified tables. (I need to find through what fileds and tables are table1 and table2 connected)
Is there any tool in SQL Server for this?

Thanx

View 1 Replies View Related

How To Compare Two Tables And Find The Gap?

Mar 18, 2008



Hi,

We have inventory table which is updated everyday.
I need to find the gap between updated table vs history (which means yesterday's data).
what i did is I just copy the inventory everyday before it is updated.
So, whenver inventory table is updated I want to know the gap between these two (history vs updated) tables.

The structure of two tables are same and here are columns:
date_key (fk)
store_key(fk)
item_key(fk)
begin_inventory_dollars
ending_inventory_dollars
begin_inventory_units
ending_inventory_units

I want to compare each row and if the value is changed I want to have a gap (updated value - history value) and if data is new then just want to add.

Here is tsql: however when I compare to gap between table from excel spreadsheet and this query, this query does not return a right value. (Some are correct but some don't)




Code Snippet
select a.date_date_key,
sum(a.Beg_Inventory_Dollars- (case when b.beg_inventory_dollars is NULL then 0 else b.Beg_Inventory_Dollars end)),

sum(a.Beg_Inventory_Units-(case when b.beg_Inventory_Units is NULL then 0 else b.beg_Inventory_Units end)) ,

sum(a.Ending_Inventory_Dollars- (case when b.Ending_Inventory_Dollars is NULL then 0 else b.Ending_Inventory_Dollars end)),

Sum(a.Ending_Inventory_Units-(case when b.Ending_Inventory_units is NULL then 0 else b.Ending_Inventory_Units end))

from UPDATED TABLE a

left outer join HISTORY TABLE b

on b.item_key = a.item_key and

b.store_key =a.store_key and

b.date_key =a.date_key

group by a.fisc_date_key







Did I miss something in here?
Any kind of advice would be grealy appreciated.
Thanks.

View 4 Replies View Related

Can't View Tables In EM!

Sep 25, 2002

I have suddenly lost the ability to view the tables for one of my database via Enterprise Manager. It just sits at an hourglass and never returns!
Alos, if I attempt to link to the tables via MSAccess's ODBC interface, I get a timeout.

I am able to view the table list for other user databases, as well as the system databases.

I am able to view other object list (like SPs) for the database in question, via Enterprise Manager.

I am able to perform a select query against the sysobjects table for the database in question.

Any ideas on why Enterprise Manager, and ODBC links, are hanging while trying to access the tables for one particular user database?

Any help is appreciated.

All other functions appear normal. If I can't figure anything out, or no one has any other ideas, I will try rebooting the server after the users are gone for the day.

View 4 Replies View Related

Sql EX 05 Can't View DB And Tables

Nov 28, 2005

Hi, I€™m new to sql ex 2005 and have a couple of questions I can€™t find the answers to.   Q.1   I am working with VS web dev ex 2005 and I€™m trying to backup my db,  is it as simple as copying the .mdf file? Or should I create a text file, or something else?   Q.2  How do I view the content of the db in my web programs in the sql server 2005 ex?  I can€™t figure out what to do, to view the content.  I have tried to find tutorials on ex 05 but can€™t find answers to my questions.   Help would be appreciated. Thank you.

View 7 Replies View Related

Find Max Serial Number From 2 Tables

Feb 11, 2008

I need a query to find max serial number by comparing two different tables. Here is my requirementI am having two tables named Table1 and Table2. Each tables having more than 30,000,000 records.I want a simple query to find Max srno from two tables.For exampleIf Table1 max is 245 where partno=2 and ano=2and Table2 max is 343 where partno=2 and ano=2Then 343 is max serial noIf Table1 max is 435 where partno=2 and ano=2and Table2 max is 34 where partno=2 and ano=2Then 435 is max serial noI used this query but its taking more time  select max(v.MaxSrNo) from ((select max(MaxSrNo) as MaxSrNo from Table1 where partno=@partno and ano=@ano)union all (select max(MaxSrNo) from Table2 where partno=@partno and ano=@ano)) as v Pls give me a simple query to find max srno.

View 3 Replies View Related

How To Find Text/data In All Of My Tables?

Jan 18, 2000

Hello,

I have a quick question. Can you please tell me how to find/search a string/value in all of my tables in a database.

For example I need to find a value/data "GH45678", where-ever it appears in a database.

I would really appreciate your prompt response. I would also like to thank you very much in advance for your time/help.

Note: I need to find specific data in all of my tables, I am looking for something like text search in my database. I am using SQL Server 6.5. Thanks

View 1 Replies View Related

How To Find Out All The Statistics From All The Tables And Drop Them

Jul 21, 2003

How to find out all the statistics from all the tables and drop them..any script anyone can help with?
When we are trying to make datatype changes in few related tables,it's giving error saying that some statistics are dependent onthe column blah blah...

Thanks,
Sheila.

View 1 Replies View Related

How To Find Maximum Number From Two Tables

Feb 19, 2012

My db contains two table Employee_detail and Student_Detail.Employee_detail has Emp_id and Student_Detail has stud_id.Now my problem is that i want to get one maximum no from these two table.

View 11 Replies View Related

Compare Two Tables And Find The Occurance

May 17, 2008

Hi friends,

I have a two table with following fields, table names are tbl_userinfo, tbl_Property.

tbl_userinfo fields are

user_id name
1 dhin
2 Mike
3 sam
4 Red


tbl_Property fields are

prpty_Id User_Id Address
1 1 3CostalRoad
2 1 westbengal
3 2 Loasass

what i want to do is, if tbl_info User_id occures in tbl_property, i want to display that full info abt tbl_userinfo

after comparing two tables Expected result is
user_id name
1 dhin
2 Mike


Please help me how to do this

View 6 Replies View Related

Find The List Of Tables For A User?

Feb 18, 2015

how to find the names of the tables owned by the particular user in sql server and how to display the distinct object types owned by the particular user.

View 1 Replies View Related

Where To Find Info On The Concept Of SQL Tables

Feb 7, 2006

i would like to know where can i find information on the concept of SQL like Base Table , View Table and Search Table as now i am using VS.Net 2005 and SQL Server 2005 to write a addressbook program and i am just a newbie to Sql and c#... i wish to write my sql commands in c# side before passing it into sql and may i know how to do it?

View 20 Replies View Related

Find Common Value In Column For 30 Tables

Mar 21, 2006

Hi,

I am trying to query for a common value in a column called "file_auth_nbr" in 30 different tables. I was going to try something like this (see below) but wasn't sure if this was the most efficient, fastest, or correct, way to get what I'm looking for:

Select distinct a.file_auth_nbr from table1 as a
join table2 as b
on a.file_auth_nbr = b.file_auth_nbr
join table3 as c
on a.file_auth_nbr = c.file_auth_nbr
join table4 as d
on a.file_auth_nbr = d.file_auth_nbr
join table5 as e
on a.file_auth_nbr = e.file_auth_nbr
......etc., etc.

Any suggestions would be much appreciated,
Jeff

View 1 Replies View Related

How Can I Find What Tables Are Loaded In Memory ?

Jul 23, 2005

I'm doing some performance reviews and wish to know what tables SQL haspinned in memory and which ones have are loaded through usage ...Is there a way ?Thanks,Craig

View 3 Replies View Related

Find Similar Strings In Two Tables

Jul 23, 2005

I have two tables in the same SQL database. Both have a similar numericfield. One field has the same number as the other field but is prefixedwith various letters. I know how to use LIKE but won't know the partialstring I am looking for. I am trying to use LIKE '%' + Field A orsomething that will do this.Eg.Table 1 Field A is 'A12345"Table 2 Field B is '12345"I want to find every record in Table 1 Field A that contains the exactField B data.*** Sent via Developersdex http://www.developersdex.com ***

View 3 Replies View Related

Find All Tables That A Table Is Related To

Sep 8, 2006

how can i find all the names of tables that a specific table is related to in tsql?

View 3 Replies View Related

How To Find The Last Updated Tables In A Database

May 28, 2007

Hi,



I am trying to create a data dictionary for a huge application which has aroung 300 tables in the database....when i perform any operation in the application some tables are updated.... can you help me to find out how can we find out the last updated tables in the database ??

View 1 Replies View Related

To Find Out Empty Tables In A Database

Jul 20, 2006

Hi all,

I have a database which gets its daily feed from a ftp file. Now is there any way i can figure out the empty tables in the databese which doesnot get any data on the feed.

Thanks in advance,

View 10 Replies View Related







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