Showing posts with label SQL Server. Show all posts
Showing posts with label SQL Server. Show all posts

Sunday, 15 December 2013

Table backup with data in sql server through generate script


We have a following table name tblEmployee in customersdatbs database and we want to back up the table with data through generate script












Step 2

Right click on database.Go to Task=>Generate Script seect. 
step 3
step3

Step 4
Step5
step 6
Step 7
Step 8
 Step 9 Final Step


You got the following Data like this
USE [customersdatbs]
GO
/****** Object:  Table [dbo].[tblEmployee]    Script Date: 12/15/2013 13:06:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tblEmployee](
    [employeeid] [int] IDENTITY(1,1) NOT NULL,
    [name] [varchar](50) NULL,
    [gender] [nvarchar](50) NULL,
    [city] [nvarchar](50) NULL,
 CONSTRAINT [PK_tblEmployee] PRIMARY KEY CLUSTERED
(
    [employeeid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET IDENTITY_INSERT [dbo].[tblEmployee] ON
INSERT [dbo].[tblEmployee] ([employeeid], [name], [gender], [city]) VALUES (2, N'name1', N'female', N'karachi')
INSERT [dbo].[tblEmployee] ([employeeid], [name], [gender], [city]) VALUES (3, N'name2', N'female', N'karachi')
INSERT [dbo].[tblEmployee] ([employeeid], [name], [gender], [city]) VALUES (4, N'name3', N'female', N'karachi')
INSERT [dbo].[tblEmployee] ([employeeid], [name], [gender], [city]) VALUES (5, N'name4', N'male', N'kpk')
SET IDENTITY_INSERT [dbo].[tblEmployee] OFF




Save the script for future use

Thanks for reading