Results 1 to 3 of 3

Thread: Compiler Conditional statements in t-SQL?

  1. #1

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Compiler Conditional statements in t-SQL?

    What I am trying to do is this:

    Some of our customers have SQL server 2000 databases and some have 2005.

    Can we create a stored procedure that is put on both systems but has a compiler conditional statement that includes a call to a system function that only exists in SQL server 20005? Thus, if that stored procedure is created on an SQL sever 2000 database, it will not fail to create? When it runs, it simply skips over the bit call to the call to the non-existance system function (because it is wrapped in compiler conditional logic).

    Is this possible?
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Compiler Conditional statements in t-SQL?

    The first way I can think of doing that is to put the SQL 2005 specific function call into another function or stored procedure.

    On the 2005 box you simply call that udf/sproc.

    On the 2000 box you have an "empty" routine in the udf/sproc - so calling it does nothing.

    Or you could actually create the "name" of the 2005 system sproc on the 2000 machine - although that seems intrusive.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Compiler Conditional statements in t-SQL?

    That would still require me having seperate scripts for 2000 and 2005 servers. I would like to avoid that if attall possible.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width