日期:2014-05-18  浏览次数:20656 次

sql2005中如何导出内容的sql语句?
如表users有自段:
aa |bb |cc
111|222|333

我需要导出这样的sql语句:INSERT INTO [users](aa,bb,cc)VALUES(111,,222,333)

------解决方案--------------------
给你个案例:select'delete from CardScoreSave'
select 'insert into CardScoreSave (cardScoreSave_ID, CardScoreSave_CardID, CardScoreSave_Score, CardScoreSave_ConsumeScore,
CardScoreSave_Time, CardScoreSave_OperatorNo) 
values ('+ case when cardScoreSave_ID is null then 'null' else ''''+convert(varchar(30), cardScoreSave_ID)+'''' end + ','
+ case when CardScoreSave_CardID is null then 'null' else '''' + convert(varchar(10), CardScoreSave_CardID) + '''' end + ','
+ case when CardScoreSave_Score is null then 'null' else '''' + convert(varchar(30), CardScoreSave_Score) + '''' end + ','
+convert(varchar(30), CardScoreSave_ConsumeScore)+','
+ case when CardScoreSave_Time is null then 'null' else '''' + convert(varchar(30), CardScoreSave_Time) + '''' end + ','
+ case when CardScoreSave_OperatorNo is null then 'null' else '''' + convert(varchar(10), CardScoreSave_OperatorNo) + '''' end + ')'
from CardScoreSave
where datediff(n, @datetimefrom, CardScoreSave_Time) >= 0 and datediff(n, CardScoreSave_Time, @datetimeto) >= 0
------解决方案--------------------
这并不是什么问题。