在SQL2000下使用SqlServer2005生成的建表脚本

     首先在所选的数据库上右键,任务,生成脚本。生成过程中,注意选择目标数据库为SQL Server2000.

     第二,这个脚本是不能在SQL2000的查询分析器中使用的,通过如下的Emeditor宏来转换吧:

function TSql2005_2000(sql)
{
	return sql.replace(/WITH\s*\(.*?\)/g,'')
		.replace(/(sys\.objects)|(sys\.views)|(sys\.indexes)/g,'sysobjects')
		.replace(/object_id/g,'id')
		.replace(/exec\s+sys\.sp_addextendedproperty.+$/gmi,function(line){
			return line.replace(/sys\.sp_addextendedproperty/g,'dbo.sp_addextendedproperty')
				//@level0type=N''SCHEMA''改成@level0type=N''user'',再把@name=,@value =,@level0type=,@level0name=,@level1type=,@level1name=全部替代为空
				.replace(/@level0type=N?'.+?'/,"@level0type=N'user'")
				.replace(/@level0type=N?'.+?'/,"@level0type=N'user'");
					
			});
}


document.selection.Text=TSql2005_2000(document.selection.Text)


原文地址:https://www.cnblogs.com/evlon/p/1643475.html