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
Category: SQL
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
SQL- Store Procedure Vs Function
Stored Procedure: SP is a SQL entity which helps in achieving consistent logic across application. SQL is group of SQL-transact statement complied to one single execution plan or would say a pre-compiled object compiled to first time only. SPs having a single execution plan which is point to ponder which makes it differ from function. … Continue reading SQL- Store Procedure Vs Function
SQL- Performance tuning
Writing SQL Stored Procedures and Views with multiple Table joins is a very common task and have to ensure that the execution time should be minimal. There are many possible SQL performance tuning tricks like usng indexer etc.. A very common one I am highlighting here i.e. performance of the SQL Query while using JOIN. … Continue reading SQL- Performance tuning