Link to home
Create AccountLog in
Avatar of kowsika devi
kowsika devi

asked on

sql server index 2012

how to move selected column in the  table from one server to another server with out droping constrains and indexes in sql server 2012.
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Do you want to remove the column from the table. If yes it is not possible with dropping depending object like constrains and indexes in SQL Server.
Avatar of kowsika devi
kowsika devi

ASKER

hi jj
all the tables  with selected columns copied on to a different database with the 'Select * Into...' clause from one server to another. But this statement does not transfer constraints and indexes. How do we transfer the constraints and indexes to the destination server.
Generate Scripts is the answer-

Go to  SSMS -> Choose your database -> tasks-> Generate scripts -> Next
-> Script Check Constraints to true
-> Script Indexes  to true
-> ScriptDependencies to true
-> Select the tables you need
-> next -> next ->

read more from here
i need selected columns alone if i use the generate scripts it comes all the column in the specified table jj. iam doing now trunctate table and selecting the columns  and inserting .  like this


if OBJECT_ID(N'LGen_ArbitrationExpenses_D', N'U') is not null
    Truncate Table LGen_ArbitrationExpenses_D;

 Insert into  LGen_ArbitrationExpenses_D  (Pk_Id,Amount,CrtdBy,CrtdDt,ExpenseDt,ExpenseType,Hdr_Fk,HearingDate,LnNo,LnNo_Fk,LstModDt,MediaName,PublicationAgainst,PublicationDt)
 select Pk_Id,Amount,CrtdBy,CrtdDt,ExpenseDt,ExpenseType,Hdr_Fk,HearingDate,LnNo,LnNo_Fk,LstModDt,MediaName,PublicationAgainst,PublicationDt  
 from [192.169.1.77\sql12].SHRICITYUNO.dbo.LGen_ArbitrationExpenses_D  with(nolock)

 Go

is tere any way to do simple and common script jj.
ASKER CERTIFIED SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
mmm k jj thanku