一个类似于这样的SQL语句:
if exists(select * from tabsource where col1=1)
begin
select col1,col2 where col1=1
end
else
begin
select col1,col3,col4 where col1=0
end这样生成的列名和列的个数是不固定的,而每天要根据条件的不同,将对应的数据导出到一个同名的文本文件里
if exists(select * from tabsource where col1=1)
begin
select col1,col2 where col1=1
end
else
begin
select col1,col3,col4 where col1=0
end这样生成的列名和列的个数是不固定的,而每天要根据条件的不同,将对应的数据导出到一个同名的文本文件里
begin
select col1,col2,'' as col3,'' as col4 where col1=1
end
else
begin
select col1,'' as col2,col3,col4 where col1=0
end