Blogs

Inserting multiple records simultaneously in a table in SQL Server

Inserting multiple records simultaneously in a table in SQL Server

While developing applications, we may come across the situations where we need to insert/update multiple records in a database table at the same time. Inserting (or updating) records one by one isn't that much of good idea. In such a case, we can send the data in XML format and use some built-in functions and stored procedures in SQL server to save the records. Let’s create a sample web application demonstrating this using VS 2015 Express edition for Web.

Suppose there is a zoo and one of the staff members at the entry gate is required to make entries of visitors by providing their basic information (first name, last name,
mobile number, age and ticket amount). User can save details of multiple visitors (one row for each visitor) if required; on single click of 'Save' button.

  • Open Visual Studio and create a new empty MVC application.

(File → New Project... → Select “Installed” >> “Templates” >> “Visual C#” >> “Web” in the left pane in the opened window → Enter name for your web application(“InsertMultipleRecordsUsingXMLDemo”) → Click “OK” to navigate to next window → Select “Empty” as a template type with check marked checkbox for "MVC" → Click "OK")

Topics: SQL Server SQL

Backup and restore database using SQL stored procedure

backup-and-restore-database-using-sql-stored-procedure.jpg

Many times we need to backup and restore our databases on daily basis. We do this all process manually which increases our repetitive work. For the same, here we have SQL stored procedures to make it automated and easy which is helpful for doing database backup and restore. We can also make SQL job to run it automatically. Here is a sample code:

  • To Backup databases

USE [master]
GO
/****** Object: StoredProcedure [dbo].[DBbackup] Script Date: 11/03/2017 7:35:54 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Pranita Pendharkar>
-- Create date: <11-03-2017>
-- Description: <To create database backups >
-- =============================================
/*
EXEC [DBbackup] 'DBbackup'
*/
Alter PROCEDURE DBbackup

@name VARCHAR(MAX) = '' -- DB NAME TO CREATE BACKUP
AS
BEGIN

DECLARE @path VARCHAR(256) -- path of backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
DECLARE @fileDate VARCHAR(20) -- used for file name

SET @path = 'E:\Data\FTP\Backup\'

-- specify filename format
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)

BEGIN
SET @fileName = @path + @name + '_' + @fileDate + '.BAK'
BACKUP DATABASE @name TO DISK = @fileName
END
END
GO

Likewise just pass names of db’s to stored procedure to create backup.
EXEC [DBbackup] 'Database1'
EXEC [DBbackup] 'Database2'

Also there are different database backup types

Topics: SQL SQL Server database

Architectural Changes in SharePoint 2013

Released by Microsoft on 17 July, SharePoint 2013 public beta is being discussed worldwide for its advanced features and improvements. I was fortunate to get enlightened at Microsoft India, Hyderabad when Wayne Ewington, the Principal Consultant at Microsoft Corporation spoke on ‘Architectural Changes in SharePoint 2013’. I’m sharing the same with you; following are the changes in the architecture of SharePoint 2013:

Topics: Microsoft SharePoint SharePoint 2013 SQL Cache Service Request Management Microsoft .Net SharePoint 2010 Shredded Storage Technology

Tech Digest – Week 39, 2012

Private Cloud Deployment: Six factors to consider

Topics: mobile devices Private Cloud Deployment Social Media Analytics business intelligence SQL Amazon EC2 StructuredWeb private cloud socialondemand Big data Social media marketing Socialize Your Stuff GaggleAMP Hadoop mapreduce Technology Business Intelligence Tools

How to get the running balance from a table with a single SQL Query

 

Topics: SQL running balance query Technology

e-Zest is a leading digital innovation partner for enterprises and technology companies that utilizes emerging technologies for creating engaging customers experiences. Being a customer-focused and technology-driven company, it always helps clients in crafting holistic business value for their software development efforts. It offers software development and consulting services for cloud computing, enterprise mobility, big data and analytics, user experience and digital commerce.