alter database DB1_DEV set SINGLE_USER with rollback immediate
Modify Name = DB1;
alter database DB1 set MULTI_USER
To create a link between two SQL Servers you need to use the sp_addlinkedserver and sp_addlinkedsrvlogin stored procedures.
@server is the name of the link
@srvproduct is the type of product, by default SQL Server
@datasrc is the server you link to
Then, you need to set the username and password to use on the link.
The first parameter is the name of the link to use,
The fourth is the account of the remote server to use,
The fifth is the password for the account.
I was having trouble adding configuring Database Mail on a SQL2005 server today.
I followed the wizard just like I had done on the previous 6 servers, but this one just didn’t want to add it. It was giving me an error about not being able to insert a NULL into the server name field, although I was giving it a server name.
I tried manually adding the data into the table, but of course that didn’t work. You have to use a stored procedure.
You need to use msdb.dbo.sysmail_add_account_sp with options like below,
msdb.dbo.sysmail_add_account_sp @account_name=’company.com mail server’,@email_address=’email@example.com’,@display_name=’John Doe’,@replyto_address=’firstname.lastname@example.org’,@mailserver_name=’mail.company.com’,@port=25;
You can list all the databases on a SQL server by running the following query.
SQL> select name from sys.sysdatabases
You can pass operating system parameters to SQL*Plus using this syntax:
sqlplus username/password @cmdfile.sql var1 var2 var3
var1 will be mapped to SQL*Plus variable
Here’s an example:
sqlplus scott/tiger @test.sql '"test parameter"' dual
test.sql consists of:
select '&1' from &2;