Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ColumnProperty from different database
Message
From
14/04/2004 18:08:00
 
 
To
14/04/2004 16:17:32
Larry Long
ProgRes (Programming Resources)
Georgia, United States
General information
Forum:
Microsoft SQL Server
Category:
Database management
Miscellaneous
Thread ID:
00894932
Message ID:
00894958
Views:
13
This message has been marked as the solution to the initial question of the thread.
>I am migrating data from 1 database to another with a different schema altogether and need to designate identity columns in the original. If I am in the new database and issue the following from a stored procedure where northwind is the original..
>
> select o.name , c.name AS [idcolumn]
> from northwind..sysobjects o join northwind..syscolumns c
> on o.id = c.id
> and COLUMNPROPERTY(o.id, c.name, 'IsIdentity') = 1
>
>I get nothing, because apparently the COLUMNPROPERTY is bound to the local database. Is there a way to "tell" the system to use the northwind COLUMNPROPERTY?
>
>I know I can just issue a USE NORTHWIND before the query and then switch back if I use a standard script, but I would like to keep it in a procedure file.
>
>TIA

You could create a user-defined function on the Northwind DB to get the value, then call the UDF while in your other DB. That wouldn't be too complex.

The only other way I could think of would be to check the syscolumns table on the Northwind DB, but a UDF would be much easier to deal with.
Dan LeClair
www.cyberwombat.com
SET RANT ON - The Wombat Blog

Life isn’t a morality contest and purity makes a poor shield. - J. Peter Mulhern
Disclaimer: The comments made here are only my OPINIONS on various aspects of VFP, SQL Server, VS.NET, systems development, or life in general, and my OPINIONS should not be construed to be the authoritative word on any subject. No warranties or degrees of veracity are expressed or implied. Void where prohibited. Side effects may included dizziness, spontaneous combustion, or unexplainable cravings for dark beer. Wash with like colors only, serve immediately for best flavor.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform