PS > Get-SPContentDatabases -WebApplication http://nimaintranet | >> Dismount-SPContentDatabase in VS .NET

Generating QR Code 2d barcode in VS .NET PS > Get-SPContentDatabases -WebApplication http://nimaintranet | >> Dismount-SPContentDatabase

PS > Get-SPContentDatabases -WebApplication http://nimaintranet | >> Dismount-SPContentDatabase
Read QR In .NET
Using Barcode Control SDK for VS .NET Control to generate, create, read, scan barcode image in .NET applications.
QR Code JIS X 0510 Encoder In Visual Studio .NET
Using Barcode creator for Visual Studio .NET Control to generate, create QR Code ISO/IEC18004 image in VS .NET applications.
In this example, we will detach a specific content database for demonstrative purposes
Decoding QR Code In Visual Studio .NET
Using Barcode recognizer for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
Bar Code Creator In Visual Studio .NET
Using Barcode maker for Visual Studio .NET Control to generate, create barcode image in .NET applications.
PS > $cd | Dismount-SPContentDatabase -Confirm:$false
Reading Barcode In .NET
Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
Quick Response Code Creation In C#.NET
Using Barcode generation for VS .NET Control to generate, create QR image in .NET applications.
Now let us see how we can change the name of the database in the SQL Server instance
QR Creation In Visual Studio .NET
Using Barcode encoder for ASP.NET Control to generate, create QR Code 2d barcode image in ASP.NET applications.
QR Code JIS X 0510 Drawer In Visual Basic .NET
Using Barcode generator for VS .NET Control to generate, create QR Code image in .NET applications.
Renaming Content Databases
Creating Bar Code In .NET
Using Barcode generation for Visual Studio .NET Control to generate, create barcode image in .NET framework applications.
2D Barcode Printer In .NET
Using Barcode drawer for VS .NET Control to generate, create Matrix Barcode image in .NET applications.
Windows PowerShell offers the ability to connect to an instance of the Microsoft SQL Server service using an object of the type SystemDataSQLClientSQLConnection, which supports execution of queries against a SQL Server database The following Set-SQL function uses this feature to connect to a database and allow us to alter the name of a database in SQL Server
Data Matrix ECC200 Maker In .NET
Using Barcode maker for .NET Control to generate, create Data Matrix ECC200 image in Visual Studio .NET applications.
2/5 Industrial Generation In VS .NET
Using Barcode generator for VS .NET Control to generate, create Standard 2 of 5 image in .NET framework applications.
function Set-SQL([string]$command, [string]$connectionString) { $connection = New-Object SystemDataSQLClientSQLConnection; $connectionConnectionString = $connectionString; $connectionOpen(); $sqlCommand = New-Object SystemDataSQLClientSQLCommand; $sqlCommandConnection = $Connection; $sqlCommandCommandText = $command; $sqlCommandExecuteNonQuery(); $connectionClose(); }
GS1-128 Generator In .NET Framework
Using Barcode creation for ASP.NET Control to generate, create EAN / UCC - 14 image in ASP.NET applications.
Create Code 128 Code Set A In None
Using Barcode creation for Excel Control to generate, create Code128 image in Office Excel applications.
The function supports two parameters: command and connectionString It commences by storing an object of type SystemDataSQLClientSQLConnection
Printing DataMatrix In None
Using Barcode encoder for Microsoft Excel Control to generate, create Data Matrix ECC200 image in Excel applications.
Barcode Printer In Visual C#
Using Barcode printer for Visual Studio .NET Control to generate, create barcode image in VS .NET applications.
PowerShell for Microsoft SharePoint 2010 Administrators
Decode Bar Code In .NET Framework
Using Barcode reader for .NET framework Control to read, scan read, scan image in .NET framework applications.
Barcode Generation In Java
Using Barcode generator for Java Control to generate, create barcode image in Java applications.
in a variable Next, the connection string provided is used as value for the ConnectionString property The Open method is used to open a database connection using the information specified in the ConnectionString Then we create an object of type SystemDataSQLClientSQLCommand and use the connection variable as the value for the Connection parameter and the command variable as value for the CommandText parameter When retrieving information from a database using a SELECT statement, the ExecuteReader() method is used, but since we want to actually modify a database, we use the ExecuteNonQuery() method instead Finally, we close the connection using the Close method A connection string includes the target database name and other information needed to establish a connection Let s take a look at a typical connection string using the value stored in the XML file we created earlier First, we load the XML file into an object in Windows PowerShell, as shown here:
Code 39 Full ASCII Decoder In VB.NET
Using Barcode scanner for VS .NET Control to read, scan read, scan image in Visual Studio .NET applications.
UPC-A Supplement 5 Generator In None
Using Barcode drawer for Online Control to generate, create UPC-A image in Online applications.
PS > $xml = New-Object SystemXmlXmlDocument PS > $xmlLoad("E:\ContentDatabasexml")
Next, we store the elements in a variable, working with a single content database for this example
PS > $xmlElement = $xmlContentDatabasesContentDatabase | >> Where-Object { $_Name -eq "WSS_Content" }
Now we use the value from the Server property as input to the connection string
PS > $conn = "server=" + >> $xmlElementServer + >> ";database=master;trusted_connection=true;"
Here s what the resulting connection string looks like:
PS > $conn server=SQLServer01;database=master;trusted_connection=true;
First, we add a server name using the value stored in the Server property, and then we specify the database to use Since we are going to alter the name of a database, we need to use the master database Finally we add trusted_connection=true, since the SQL Server instance we are connecting to uses Integrated Windows Authentication TIP A good reference for other types of connection strings is available at wwwconnectionstringscom To make changes to the database, we use the Transact-SQL statement ALTER DATABASE, which allows us to modify a database or the files and filegroups associated with a database First, we set the Restrict Access setting on the content database to
Single_User to get exclusive access, next we rename the database, and finally, we set Restrict Access back to Multi_User Here is how we build up the command string:
20:
Working with Content Databases
PS >> >> >> >>
> $command = "ALTER DATABASE " + $xmlElementName + " SET SINGLE_USER WITH ROLLBACK IMMEDIATE; ALTER DATABASE " + $xmlElementName + " MODIFY NAME = " + $xmlElementNewName + "; ALTER DATABASE " + $xmlElementNewName + " SET MULTI_USER"
And here s what the string looks like:
PS > $command ALTER DATABASE WSS_Content set single_user with rollback immediate; ALTER DATABASE WSS_Content MODIFY NAME = NimaIntra_ContentDB_01; ALTER DATABASE NimaIntra_ContentDB_01 SET MULTI_USER
We can execute this Transact-SQL statement using the Set-SQL function
PS > Set-SQL -command $command -connectionString $conn -1
The output from the function is returned from the ExecuteNonQuery() method inside the function When using UPDATE, INSERT, or DELETE statements, the value returned represents the number of rows affected Other statements, such as ALTER, return 1 NOTE Changing the database name as shown in this example does not change either the logical or the physical names of any of the database files It is possible to use the ALTER DATABASE Transact-SQL statement to change these names as well You can read more about the ALTER DATABASE statement at MSDN: http://msdnmicrosoftcom/en-us/library/ms174269aspx
Copyright © OnBarcode.com . All rights reserved.