-------------在master库执行重新安装用友前数据库还能使用的时候生成附加语句
select name from (
select dbid,0 as fid, 'sp_attach_db @dbname=N'+''''+name+''',' as name from master..sysdatabases where dbid>7 union
select dbid,fileid,
'@filename'+cast(fileid as varchar)+'=N'''+replace(LTRIM (filename),'\\','\') from master..sysaltfiles where dbid>7 union
select dbid,3,'go' from master..sysaltfiles where dbid>7 and fileid=1
) a
order by dbid,fid