# ifdef type conditional compilation in T-SQL sql server 2008 2005

柔情痞子 提交于 2019-12-23 18:52:53

问题


For sake of backwards compatibility I need to have a stored proc run on both sql server 2005 AND sql server 2008. However due to some commands being deprecated in sql server 2008 my script compiles on 2005 but fails on 2008. I am looking for the c++, c# equivalent of #define, #ifdef so I can compile the same script on 2005 & 2008. What is the standard practice on this ? Attached screenshot explains in detail. thank you


回答1:


Use dynamic SQL:

if (@returnVal = 1)
    exec ('backup log myDB with truncate_only');


来源:https://stackoverflow.com/questions/6612224/ifdef-type-conditional-compilation-in-t-sql-sql-server-2008-2005

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!