ALTER current database without using its name

前端 未结 3 1256
旧巷少年郎
旧巷少年郎 2021-02-18 15:52

I need to run update script on current database (ALTER DATABASE...), but can\'t use implicit its name. Is possible to use some function to get current db name and u

3条回答
  •  渐次进展
    2021-02-18 16:47

    Try this

    DECLARE @DBName sysname;
    SET @DBName = (SELECT db_name());
    DECLARE @SQL varchar(1000);
    SET @SQL = 'ALTER DATABASE '+@DBName+' .......'
    

    Raj

提交回复
热议问题