Thursday, February 16, 2012

cross reference of database

Hi all gurus
From Pubs database I want to get some ObjectProperty value from NorthWind
ObjectProperty(<object id of Northwind DB> , <property> )
Is it possible?
Thanksuse pubs
go
select objectproperty(object_id('northwind.dbo.orders'), 'IsUserTable')
go
AMB
"AM" wrote:

> Hi all gurus
> From Pubs database I want to get some ObjectProperty value from NorthWind
> ObjectProperty(<object id of Northwind DB> , <property> )
> Is it possible?
> Thanks
>
>|||Sorry boss
Its not working
Thanks
"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:CA3BF8A4-8AB9-4E9C-BC71-E3C85670551E@.microsoft.com...
> use pubs
> go
> select objectproperty(object_id('northwind.dbo.orders'), 'IsUserTable')
> go
>
> AMB
> "AM" wrote:
>
NorthWind|||AM,
You are right. Function objectproerty expects an object id from current
database. Try,
use pubs
go
declare @.i int
exec sp_executesql N'use northwind; select @.i =
objectproperty(object_id(''dbo.orders''), ''IsUserTable'')', N'@.i int
output', @.i output
print @.i
go
AMB
"AM" wrote:

> Sorry boss
> Its not working
> Thanks
> "Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in messag
e
> news:CA3BF8A4-8AB9-4E9C-BC71-E3C85670551E@.microsoft.com...
> NorthWind
>
>|||Thanks
It works
But one more question
How can I use for database on other server
Thanks
"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:9AA0B83B-509B-4D2F-87A1-A4913B5A898D@.microsoft.com...
> AM,
> You are right. Function objectproerty expects an object id from current
> database. Try,
> use pubs
> go
> declare @.i int
> exec sp_executesql N'use northwind; select @.i =
> objectproperty(object_id(''dbo.orders''), ''IsUserTable'')', N'@.i int
> output', @.i output
> print @.i
> go
>
> AMB
> "AM" wrote:
>
message
'IsUserTable')|||AM,
You have to add the server as a linked server. See sp_addlinkedserver in BOL
.
select
*
from
openquery(linked_server, 'exec sp_executesql N''set nocount on; use
northwind; select objectproperty(object_id(''''dbo.orders''''),
''''IsUserTable'''')''')
go
AMB
"AM" wrote:

> Thanks
> It works
> But one more question
> How can I use for database on other server
> Thanks
>
> "Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in messag
e
> news:9AA0B83B-509B-4D2F-87A1-A4913B5A898D@.microsoft.com...
> message
> 'IsUserTable')
>
>|||Thanks for the answer
I have found one more solution
USE northwind
GO
declare @.val varchar(100)
set @.val = (SELECT a.*
FROM OPENROWSET('SQLOLEDB',
'DRIVER={SQL Server};SERVER=amish;UID=sa;database=pub
s',
'select objectproperty(object_id(''pubs.dbo.authors''),
''IsUserTable'')') AS a)
print @.val
GO
"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:39FBD04B-066B-4AFD-BBA3-6C309ED41F44@.microsoft.com...
> AM,
> You have to add the server as a linked server. See sp_addlinkedserver in
BOL.
> select
> *
> from
> openquery(linked_server, 'exec sp_executesql N''set nocount on; use
> northwind; select objectproperty(object_id(''''dbo.orders''''),
> ''''IsUserTable'''')''')
> go
>
> AMB
> "AM" wrote:
>
message
current

No comments:

Post a Comment