select * from sysdatabases

解决方案 »

  1.   

    --根据安装路径得到默认的备份目录:
    select @path=rtrim(reverse(filename)) from master..sysfiles where name='master'
    select @path=substring(@path,charindex('\',@path)+1,8000),
    @path=reverse(substring(@path,charindex('\',@path),8000))+'BACKUP\'
    select SQL默认备份目录=@path
      

  2.   


    --得到SQL中的各种目录
    declare @path varchar(8000)
    --根据安装路径得到默认的备份目录:
    select @path=rtrim(reverse(filename)) from master..sysfiles where name='master'
    select @path=substring(@path,charindex('\',@path)+1,8000),
    @path=reverse(substring(@path,charindex('\',@path),8000))+'BACKUP\'
    select SQL默认备份目录=@path
      

  3.   

    select phyname from sysdevices  where name='tempdev'
      

  4.   

    不是这个意思
    现在我怕程序要做的是为数据库备份与还原,
    数据库名为NetEdu,现在要检查备份集NetEdu_bac是否已经被创建,
    如已经存在,则要得得它的备份文件名,
    如不存在则进行创建并备份
    该怎么做?
      

  5.   

    感谢welyngj(平平淡淡) !!!
    不知道用SQL是否能更改该备份集的目录?
      

  6.   

    可以先删除,然后再添加。
    USE master
    go
    sp_dropdevice 'mydiskdump'go
    EXEC sp_addumpdevice 'disk', 'mydiskdump', 'c:\dump1.bak'