Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Nilson Rishi
  Where is Nilson Rishi?
 Bangkok
 Thailand
 Nilson Rishi
 To: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 Tags
Subject: RE: SQL SERVER select * from sysobjects
Thread ID: 331461 Message ID: 331552 # Views: 25 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Saturday, December 31, 2011 7:15:03 AM         
   


> > Expert,
> >
> > For SQL Server database named myDB, I use the following 2 commands to query for its table objects. However, the 2 commands return different results. As you could see, the 1st command USE master database first, and then query from myDB..SYSOBJECTS, while the 2nd command directly USE the right database myDB and select from the same myDB..SYSOBJECTS.
> > But the 1st command returns a cursor without any record.
> > It seems: even though a specific database is specified for the SELECT command, the command simply ignores this but does the SELECT from the current database, e.g. MASTER.
> > Is this a bug?
> >
> >
> > USE MASTER
> > SELECT * FROM myDB..SYSOBJECTS 
> > WHERE OBJECTPROPERTY(id, N'IsUserTable') = 1
> > 

> >
> >
> > USE myDB
> > SELECT * FROM myDB..SYSOBJECTS 
> > WHERE OBJECTPROPERTY(id, N'IsUserTable') = 1
> > 

>
> No it is not a bug. It is just as it is documented. Maybe you are missing that ObjectProperty() is operating on current database.
>
> To your chance there weren't a match to Id's in master and myDB so you get no records. That is a good thing IMHO.
>
>
>

> Cetin Basoz
>
> .Net has got better.Think about moving - check my blog:
> My Blog
> Blog (mirror) - sounds to be down
>

> Support Wikipedia

Hi Certin,

Thank you for the info that ObjectProperty() works only on the current database.
I tried the code below, and found it works in that it displays user-defined tables.
USE MASTER
SELECT * FROM fox_data..SYSOBJECTS where xtype='U'
ORDER BY NAME


I wonder if there is any weak in this code?

Regards,
Nilson

ENTIRE THREAD

SQL SERVER select * from sysobjects Posted by Nilson Rishi @ 12/30/2011 5:05:34 AM
RE: SQL SERVER select * from sysobjects Posted by Cetin Basoz @ 12/30/2011 2:07:23 PM
RE: SQL SERVER select * from sysobjects Posted by Nilson Rishi @ 12/31/2011 7:15:03 AM