Home All Groups Group Topic Archive Search About

Databasepropertyex problem

Author
17 Feb 2006 9:02 PM
Amish Shah
Hi
when I run this query

SELECT *    FROM OPENROWSET('MSDASQL', 'DRIVER={SQL
Server};SERVER=test;UID=sa;PWD=amish;','select  name,
databasepropertyex(name,''status'') as status from
master..sysdatabases') AS a  

Result is

Name      Status

master    0x4F004E004C0049004E004500
tempdb    0x4F004E004C0049004E004500
model    0x4F004E004C0049004E004500
msdb    0x4F004E004C0049004E004500
test1    0x5300550053005000450043005400
northwind    0x4F004E004C0049004E004500

If we run select databasepropertyex('dbname','status') it gives result
as character  , why here it gives varbinary results in status column?

Regards
Amish Shah

Regards
Amish shah


*** Sent via Developersdex http://www.developersdex.com ***

Author
17 Feb 2006 11:07 PM
David Gugick
Amish Shah wrote:
Show quote
> Hi
> when I run this query
>
> SELECT *    FROM OPENROWSET('MSDASQL', 'DRIVER={SQL
> Server};SERVER=test;UID=sa;PWD=amish;','select  name,
> databasepropertyex(name,''status'') as status from
> master..sysdatabases') AS a
>
> Result is
>
> Name      Status
>
> master 0x4F004E004C0049004E004500
> tempdb 0x4F004E004C0049004E004500
> model 0x4F004E004C0049004E004500
> msdb 0x4F004E004C0049004E004500
> test1 0x5300550053005000450043005400
> northwind 0x4F004E004C0049004E004500
>
> If we run select databasepropertyex('dbname','status') it gives result
> as character  , why here it gives varbinary results in status column?
>
> Regards
> Amish Shah
>
> Regards
> Amish shah
>

Good question, but you can cast is back:

SELECT * FROM OPENROWSET(
'MSDASQL',
'DRIVER={SQL Server};SERVER=(local);UID=sa;PWD=my_pass;','select  name,
CAST(databasepropertyex(name,''status'') as NVARCHAR(100)) as status
from master..sysdatabases') AS a



--
David Gugick - SQL Server MVP
Quest Software

AddThis Social Bookmark Button