Jump to content

Drop Table and recreate template

Recommended Posts

I am needing to change the data type in a table but it won't allow me to. I usually manually drop and recreate a table but was going to try and use SQL server template since the table is rather large (right click on table-> script table as-> drop and create to) Would you suggest using this template or just manually writing it myself and going from there?

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblStaff]') AND type in (N'U'))DROP TABLE [dbo].[tblStaff]GOUSE [Test]GO/****** Object:  Table [dbo].[tblStaff]    Script Date: 07/10/2013 12:39:35 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[tblStaff](	[StaffID] [bigint] NOT NULL,	[LastName] [varchar](50) NULL,	[FirstName] [varchar](50) NULL,	[Status] [nvarchar](10) NULL,	[FileNum] [int] NULL,	[Supervisor] [nvarchar](150) NULL,	[extension] [nvarchar](25) NULL,	[JobID] [varchar](10) NOT NULL,	[StartDate] [datetime] NULL,	[EndDate] [datetime] NULL,	[Note] [nvarchar](250) NULL,	[Other] [nvarchar](150) NULL,	[AddedBy] [nvarchar](50) NULL,	[DateRecDeleted] [datetime] NULL,	[DeletedBy] [nvarchar](50) NULL,	[SSMA_TimeStamp] [timestamp] NOT NULL,	[MachineName] [nvarchar](50) NULL) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]GO
Edited by SqlBeginner
Link to post
Share on other sites

ultimately I have two tables. I'm needing to insert information from one table into the other but I get the error about the fields I'm needing to insert to being too small. (issue from previous post) I was just going to change the data type in the empty table and then do my insert but I got the error message. So that's why I was looking to drop and recreate. The table I was going to drop is ultimately empty so I thought that'd be the best one to drop and recreate.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...