sql server index 2012

kowsika devi
kowsika devi used Ask the Experts™
on
how to move selected column in the  table from one server to another server with out droping constrains and indexes in sql server 2012.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Pawan KumarDatabase Expert
Awarded 2016
Top Expert 2016

Commented:
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.

Author

Commented:
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.
Pawan KumarDatabase Expert
Awarded 2016
Top Expert 2016

Commented:
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
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
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.
Database Expert
Awarded 2016
Top Expert 2016
Commented:
No other way other than Generate Script. You can do a generate script and then remove tun unnecessary columns from the script by using find and delete.

Author

Commented:
mmm k jj thanku

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial