SQL Server – Import CSV file to SQL table – Bulk-Insert

Here is an example –  Import CSV file to SQL table using Bulk-Insert CSV file means  Comma Separated Values file. USE testdb GO CREATE TABLE table1 ( id INT, name VARCHAR(255), address VARCHAR(255) ) GO Create CSV file in Shared folder on any remote location with name csv.txt Suppose location of the file is \\dcc-566\Share\CSV.txt Content of CSV file as : Now let‘s Import this CSV file into Table1. BULK INSERT table1 FROM '\\dcc-566\Share\CSV.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR

» Read more

SQL Server – Comma Separated INSERT Option

  Here is new feature of SQL Server 2008 – “Comma Separated INSERT Option” In this feature using a single INSERT statement you can pass multiple value for the table using comma separated option. USE testdb GO CREATE TABLE table1 ( id INT IDENTITY(1,1), name VARCHAR(255), address VARCHAR(255) ) SELECT * FROM testdb..table1 INSERT INTO testdb..table1 VALUES (‘Varinder’,’ABC Street’), (‘Amit’, ‘CDE Street’), (‘Dinesh’,’XYZ Street’) Result :    

» Read more

SQL Server – Insert same value multiple time in SQL table

  Here is an example:  Inserting same value multiple time in SQL table USE testdb GO CREATE TABLE table1 ( id INT IDENTITY(1,1), name VARCHAR(255), address VARCHAR(255) ) SELECT * FROM testdb..table1 INSERT INTO testdb..table1 VALUES (‘Varinder’,’ABC Street’) go 5 Result :  

» Read more

SQL Server – Understanding of Replication

The primary purpose of replication is to distribute data from a master database to one or more secondary databases. Because Replication maintains a duplicate copy of data in synchronization with the master copy, the technology can be used to provide availability for application. Type of Replication Snapshot Transactional Merge Snapshot Replication Snapshot Replication takes the entire set of data and sends it during the each cycle of replication. This is full copy of data that is sent by Publisher to

» Read more

SQL Server Azure

Microsoft Webcast topic: “Introduction to SQL Azure (Level 100)” Sharing with brief introduction and difference between SQL Servers and SQL Azure SQL Azure is a highly available and scalable cloud database service built on SQL Server technologies. With SQL Azure, developers do not have to install, setup, and patch or manage any software. High availability and fault tolerance is built-in and no physical administration is required. Additionally, developers can get productive on SQL Azure quickly by using the same familiar

» Read more

Migrating from Crystal Reports to SQL Server 2008 Reporting Services

I have attended the Microsoft Webcast topic: “Migrating from Crystal Reports to SQL Server 2008 Reporting Services” Here sharing with you the Key Points of this Webcast New Feature in SQL Reporting Services in SQL 2008 R2 Major Enhancement New Data visualization controls SharePoint Integration change Introduction of Reports Parts New Report Designer New Report Builder Same BIDS Designer for Report Server 2008 and 2008R2 reports Redesigned Report Manager user Interface Extended Protection network authentication settings Why Migrate from Crystal

» Read more

SQL Server – Validation of Backup

Database backup are insurance policy for a database, we need to ensure that backups created are valid and useful. To validate the backup, we can use following command Restore verifyonly from <backup device> When a backups is validated, SQL Server performs the following steps Calculated a checksum for the backup and compare to checksum stored in the backup files Verify that the header of backup is correctly written and valid Transits the page chain to ensure that all pages are

» Read more

SQL Server – Policy Based Management

SQL Server 2008 has a new feature called Policy Based Management, also know as Declarative Management Framework (DMF), to tackle the problem of standardizing your SQL server instance. Although Policy Based Management can be used just to alert an administrator when an object is out of compliance, depending upon the type of policy, you can also enforce compliance by preventing changes that would violate a policy. Policy Based Management introduces the following new objects that are used to design and

» Read more

SQL Server – Distributing and Partitioning

Key Points of Distributing and Partitioning Partition allow you to divide a table or index into multiple filegroups. Table and index are partition horizontally, based on rows by specifying a partitioning column. To create a portioned table or index you need to perform the following actions: Create a partition function Create a partition schema mapped to partition function Create a table or index on the partition schema SPLIT function to add a new boundary point and hence partition. MERGE function

» Read more

SQL Server – Backup Type for Each Recovery Model

Before looking about Backup type for each Model, sharing with brief information about Recovery and Recovery Model Recovery Recovery options determine the behavior of transaction log and how damaged pages are handled. Recovery Model Every database within a SQL server a SQL server instance has a property setting called recovery model. The recovery model determines the types of backups you can perform against a database. The recovery models available in SQL server 2008 are: Full Bulk-Logged Simple

» Read more

SQL Server – Backup all the sql server databases

Sharing with you script to backup all the SQL server databases Script: DECLARE @name VARCHAR(50) — database name DECLARE @path VARCHAR(256) — path for backup files DECLARE @fileName NVARCHAR(256) — filename for backup DECLARE @fileDate VARCHAR(20) — used for file name SET @path = ‘D:Backup’ SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),113) SELECT name,flag=0 INTO #temp FROM master.dbo.sysdatabases WHERE name NOT IN (‘master’,’model’,’msdb’,’tempdb’) –according to requirement we can filter databases in where clause SET ROWCOUNT 1 WHILE (exists(SELECT * FROM #temp WHERE flag=0))

» Read more

SQL Server – Understanding the System Databases of SQL Server

We all know there are some system databases available in SQL Server. But we should have understanding about system databases. Here just try to give you understanding of system databases very briefly. There are four system databases available in SQL Server 2008 Master Model msdb tempdb Master Database The master database records all the system-level information for a SQL Server system. The master is the database that records the existence of all other databases and the location of those database

» Read more
1 8 9 10 11 12