Distributed Query

  • In a stored proc I am using a cursor to access columns from a table on another server, so my T-Sql is something like 'SELECT Action FROM bid.mips.dbo.Actions AS TA INNER JOIN ...' etc. where bid is the server, mips the database. This is fine for development but when I go live I will have to modify the procedure(s) to have the correct server name. Instead, can I make the server name and/or database name dynamic (e.g. by looking it up in a table). Security issues prevent me from looking the name up in a table and then executing a dynamic T-sql string.

  • It's probably easier to use an Alias, rather than the real server name.

    If you set up a server alias (using the Client Network Utility) called X, you can write your SQL as 'SELECT Action FROM x.mips.dbo.Actions AS TA INNER JOIN ...'

    In development, the alias X can point to the 'bids' server, and in production, the alias X can point to the real production server name.

  • Thank, i'll give that a go.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply