SQL SERVER – UPDATE From SELECT Statement

Problem Scenario: Need to update values in a Table1 By the values form other Table2. Provided condition for JOINS in between the tables. Solution: By Using JOIN clause in the UPDATE statement.   UPDATE Table1 SET Col2 = t2.Col2, Col3 = t2.Col3 FROM Table1 t1 INNER JOIN Table2 t2 ON t1.Col1 = t2.Col1 WHERE t1.Col1 IN … Continue reading SQL SERVER – UPDATE From SELECT Statement

Rename SQLServer Database

Steps: Open Microsoft SQL Server Management Studio. Connect to the server where in the DB you want to rename existing database. Modify the following script accord to Db name and run it – Old- TestLocalDB Rename to - Testdb_DEV USE [TestLocalDB]; ALTER DATABASE TestLocalDB MODIFY FILE (NAME = 'TestLocalDB', FILENAME = 'C:\Program Files\Microsoft SQL Server\localServer\MSSQL\DATA\Testdb_DEV.mdf'); ALTER DATABASE TestLocalDB MODIFY … Continue reading Rename SQLServer Database