SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 change columkn size
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jassie
Posting Yak Master

114 Posts

Posted - 08/06/2012 :  11:01:59  Show Profile  Reply with Quote
In a sql server 2008 r2 database, I am changing the size of a column called NOTES from varchar(500) to varchar(max). When this occurs, I lose the foregin key and relationships to other tables.

Basically when I run the script below in sql server management studio 2008 r2, everything runs fine. However when I right click on the 'proc' table in sql server management studio and select, 'script table as'-->create to-->new query edit window, I lose the relationship to the other tables.

Thus can you tell me if I am really losing the relationship to the tables and why this is occuring? Is the field called 'notes' used as part of the index?

If I am not losing the relationship of the 'proc' table to the other tables, can you tell me why sql server studio 2008 r2 is not showing the relationship to the other tables?

The following is the script I am referring to:


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Proc](
[Proc_ID] [int] IDENTITY(1,1) NOT NULL,
[Excep_ID] [int] NULL,
[NOTES] [varchar](max) NULL
CONSTRAINT [PK_Proc] PRIMARY KEY CLUSTERED
(
[Process_Transaction_ID] 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

ALTER TABLE [dbo].[Proc] WITH CHECK ADD CONSTRAINT [FK_Proc_Doc] FOREIGN KEY([Doc_ID])
REFERENCES [dbo].[Doc_Review] ([Doc_ID])
GO

ALTER TABLE [dbo].[Proc] CHECK CONSTRAINT [FK_Process_Transaction_Documentation_Review_6]
GO

ALTER TABLE [dbo].[Proc] WITH CHECK ADD CONSTRAINT [FK_Proc_Enroll FOREIGN KEY([Enroll_ID])
REFERENCES [dbo].[Enrol_Mech] ([Enrol_Mech_ID])
GO

ALTER TABLE [dbo].[Proc] CHECK CONSTRAINT [FK_Proc_Enroll_Mech]
GO

visakh16
Very Important crosS Applying yaK Herder

India
47099 Posts

Posted - 08/06/2012 :  11:14:30  Show Profile  Reply with Quote
for modifying a column length why should you script out table?

isnt it enough to fire a ALTER TABLE ALTER COLUMN statement?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000