# T-SQL sql server 2008 2005中的ifdef类型条件编译 [英] # ifdef type conditional compilation in T-SQL sql server 2008 2005

查看:27
本文介绍了# T-SQL sql server 2008 2005中的ifdef类型条件编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了向后兼容,我需要在 sql server 2005 和 sql server 2008 上都运行一个存储的 proc.但是,由于 sql server 2008 中不推荐使用某些命令,我​​的脚本在 2005 年编译但在 2008 年失败.我正在寻找对于 C++、C# 等价于 #define、#ifdef,我可以在 2005 年编译相同的脚本 &2008. 这方面的标准做法是什么?附上截图详细说明.谢谢

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

推荐答案

使用动态 SQL:

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

这篇关于# T-SQL sql server 2008 2005中的ifdef类型条件编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆