Showing posts with label modify. Show all posts
Showing posts with label modify. Show all posts

Monday, March 26, 2012

How can I change my Primary Key

Hello,
I have transactional replication in place with @. 450 articles in the main
publication.
I need to modify the primary key to include an additional field.
How can I do this best?
Thanks.
~Lb
you can't without dropping your subscriptions and publications.
"Lonnye Blake Bower" <lbower@.excellerx.com> wrote in message
news:OoJcCdAMFHA.1096@.tk2msftngp13.phx.gbl...
> Hello,
> I have transactional replication in place with @. 450 articles in the main
> publication.
> I need to modify the primary key to include an additional field.
> How can I do this best?
> Thanks.
> ~Lb
>
|||Thank you...
Can I remove the table from the publication easily and then make the
changes... and finally create a new publication with just this table?
|||yes with transactional replication you can do with by using sp_droparticle.
You will have to drop the subscription(s) before you do this.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Lonnye Blake Bower" <lbower@.excellerx.com> wrote in message
news:%23c3blpAMFHA.3632@.TK2MSFTNGP10.phx.gbl...
> Thank you...
> Can I remove the table from the publication easily and then make the
> changes... and finally create a new publication with just this table?
>
sql

Friday, March 9, 2012

How Alter column name of table?

Hi all,
I need modify one column name of my table.
How I can do this?
ThanksHi ReTF
Please always specify what version you are using.
In SQL Server 2005, the following example renames the TerritoryID column in
the SalesTerritory table to TerrID.
USE AdventureWorks;
GO
EXEC sp_rename 'Sales.SalesTerritory.TerritoryID', 'TerrID', 'COLUMN';
GO
The same syntax works in SQL Server 7 and 2000, but there is no
AdventureWorks database to try it on.
The key point when using the sp_rename procedure to rename a column is that
the first parameter includes both the table name and column name and can
also include the schema or owner name, and the second parameter is only the
new column name.
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
"ReTF" <re.tf@.newsgroup.nospam> wrote in message
news:OgTprj8DGHA.336@.TK2MSFTNGP14.phx.gbl...
> Hi all,
> I need modify one column name of my table.
> How I can do this?
> Thanks
>|||You can use something like this:
EXEC sp_rename 'TableName.ColumnName', 'NewColumnName', 'COLUMN'
However, you should keep in mind that:
"Renaming an object such as a table or column will not automatically
rename references to that object. You must modify any objects that
reference the renamed object manually. For example, if you rename a
table column and that column is referenced in a trigger, you must
modify the trigger to reflect the new column name."
(quote from Books Online, topic "sp_rename")
Razvan