Server and Table Alias

  • Hi Guys,

    Can any one point me in the right direction please.

    I have a long statement that involves trasnsferring some data to a remote database.

    I have lots of statements:

    insert into table1 select *.table1 from server.database.dbo.table1 where etc etc

    What I want to do is create a variable or alias for the "server.database.dbo." element so that I can define this at the start of the statement and use it for different source data.

    Is this possible, and if so how to do it ?

    Many thanks,

    Matt

  • in 2005, you can use a synonym for any object...a table/view/procedure, etc, but not part of a name.

    in 2000, i think you'd have to use a view for any object on your linked server, and that should work for your updates/inserts etc.

    but again, it'd be a view per object, and not just the first three parts of the 4 part name;

    maye someone else has a better idea.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • I'd second Lowell's advice here. Don't really know of a better way.

  • that's how I do it all the time. I even have some procedures to automate it.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

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

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