.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Copy data from 2 tables

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :Sql Server
I have 2 tables. One is more normal and I am trying to find the easiest way to do this. This is a 1 time deal. So the from table These columns; A B C Ak1 Ak2 Ak3 The to table has; A B C One Two Three I want to copy only if ak1 > 0 to the corresponding cols on the 2nd table.*** Please allow me to mark threads as answered and I will, Thank you ***

View Complete Post

More Related Resource Links

Copy data from two tables on one db to identical tables in prod db

Hello, I need to copy some data from my dev box to the db on my to be prod box.    The db is exactly the same, just some data added on my dev box which needs to be transferred. I have two tables which hv a PK-FK relationship.  What is the best way to copy data from this db to another so that the PK-FK constraints are intact and i face no errors.

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

Data Points: Creating Audit Tables, Invoking COM Objects, and More


Dealing with error handling between T-SQL and a calling application, evaluating when a field's value has changed, and creating auditing tables in SQL ServerT are all common issues that developers must tackle.

John Papa

MSDN Magazine April 2004

Get data from 4 tables

Hi everybody! I have 4 table : A : Guid, name B : Guid, name C : Guid, name D : AGuid, BGuid, CGuid I need to get the table with AName, BName, CName where Aname (or BName/Cname) = x I don't witch join expression I need to use. Can anyone help? Thank you

How to copy table data from test to production database

I'm using SQL Server 2008 R2 and I'd like to copy all data rows from one table of a test database to the identical table in a production database. The primary key of the table is referred to by other tables so a DELETE followed by a number of INSERTs won't do it because of referential integrity issues. What is the best method to replace the data rows in the destination database with the values from the source database? Thanks, Guido

ASP.NET insertion and joining data between tables

I have the following tables:1.) PRODUCT_INFORMATION2.) CUSTOMERS3.) DISTRIBUTORS4.) PRODUCT_NAME5.) CONTROLLEREach table has a primary key assigned. The customers table has an ID column and a CUSTOMER_NAME column with unique index property set to avoid any duplication. How do I insert values in the product_information table that has a foreign key column from the CUSTOMERS table if we insert a value in the CUSTOMER_NAME field of the CUSTOMERS table. I want to know how can I create a join between all the tables so that when I insert values in individual tables they are joined with a serial number column in the PRODUCT_INFORMATION  table?Please suggest!!

Copy Search Meta Data

Not sure if this is possible.  I have a bunch of search meta data configured on my dev server.  Is there a way to copy the search meta data to my stage server?

Import a flat file with combined data into separate SQL tables using SSIS

I have a flat text file (comma delimited) that is essentially multiple files, each with its own format, combined into one file. The file is coming from an external software vendor so unfortunately we don't have much choice but to work with what we are receiving. Here is an example of what the file could look like: Customer Data CustID,FName,LName,PhNum,Email 12345,John,Smith,,jsmith@gmail.com 12346,Jane,Doe,8001111111,jdoe@hotmail.com Customer Plan CustID,PlanType,PlanName,PlanStart 12345,0,Plan1,01/01/2010 12345,2,PlanVis,01/01/2010 12346,3,PlanLf,04/01/2010 12346,0,Plan1,01/01/2010 Customer Payment CustID,LastPayment,Amount 12345,09/01/2010,100.00 12346,05/01/2010,50.00 There is an empty line between each 'section' of data. I adapted a VB script I found online that can take the incoming file and save off each section as its own file so that each one can be separately imported, but this seems inefficient. I'm really new to SSIS in general, but it seems like it shouldn't be that difficult to take the data, split it where there is an empty line, and then import each section into the appropriate SQL table. Any ideas would be most welcome. Thanks!  

Copy Data From one table to another

Hi All, I have a XYZ Database (50 Tables init and lots of data ) on 01 Server and I need to create a XYZ_MOCK Database on same Server 01 with 20 tables of XYZ Similarly with the exact data of XYZ Database.... SO I DID Create XYZ_MOCK database AND 20 TABLES Now there are 20 tables with lots of lots of Records in XYZ ...... All i want is now I need to move all the records from XYZ DB to XYZ_MOCK. DB (20 Selected Tables).. for ex: From Server01-XYZ Database -table abc (20columns and 10,000rows) TO Server01 - XYZ_MOCK Database table abc(20 columns and 10,000rows).... How can i Insert all records for 20 tables so that my Selected tables in Xyz and XYZ_MOCK lokks same Thanks

compare data from tow tables ?

HI all I have tow tables ,, i want to add Column1 from table1 to Column1 in table2 , where Column2 in table1 is bigger than Column2 in table2

Cannot create/shadow copy 'Microsoft.Practices.EnterpriseLibrary.Data' when that file already exis

Lately I am getting this error when compiling my application. Does anybody have an idea what is going wrong??? Cannot create/shadow copy 'Microsoft.Practices.EnterpriseLibrary.Data' when that file already exists. === Pre-bind state information ===LOG: User = DREAMCATCHER\BischiLOG: DisplayName = Microsoft.Practices.EnterpriseLibrary.Data Calling assembly : (Unknown).===LOG: This bind starts in default load context.LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/shareyourlossweb/887ea9ec/383e808e/Microsoft.Practices.EnterpriseLibrary.Data.DLL.LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/shareyourlossweb/887ea9ec/383e808e/Microsoft.Practices.EnterpriseLibrary.Data/Microsoft.Practices.EnterpriseLibrary.Data.DLL.LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).ERR: Failed to complete setup of assembly (hr = 0x800700b7). Probing t

Excel data into multiple tables

Hi,       I  have excel file with columns EmpName,Date1,Date2,...Date7 .I want to insert EmpName into Employee table after inserting i will get EmpNo(Identity column) with that  i need to insert Date1,Date2...Date7 into TimeSheet table.    My Excel structure is like this EmpName  8/1/2010      8/2/2010     8/3/2010       8/4/2010    8/5/2010    8/6/2010 8/7/2010 Naresh    17:00-2:00   17:00-2:00   14:00-12:00  7:00-12:00  7:00-12:00  ..               Off Similarly 500 employees data I want to insert name i.e into Emp table after inserting i will get EMpNo i.e identity column with that i should insert Date1(8/1/2010) i.e excel header to date7 into Timesheet table Date column and corresponding time into TimeIn and TimeOut.I will split the time.I just want write Stored procedure for this task. My database tables are like this Emp-EmpNo,EmpName,CompaignId Timesheet-TimeID,EMpNo,Date,TimeIn,TimeOut,TotalHours   Date in Timesheet should be like this   TimeId     EmpNo     Date       TimeIn     TimeOut 

Is there any Data Flow Task in SSIS to merge 3 different recordsets (from 3 different tables) and se

I have a requirement, that has 3 different Execute SQL Task that returns 3 different recordsets which differ from each other.  I want to know whether these 3 recordsets can be sent as Input to a Script Component.  I know that Script Component accepts only 1 Input... But is there any way, to have this done

copy partition data from 2000 cube to 2005 cube



i am upgrading 2000 olap cube to 2005.  i built an ssas project and deploy to the server.

the 2000 olap cube store it's data in partitions - one for each month.

the face table delete it's data and store data for only the last 13 month so basically most of the data

is store onle in the 2000 cube.

while upgrading the cube and processed it , a lot of information had lost.

i know that i cant restore the fact from the partiotn data but is there a way to copy the partition has is

from olap 2000 to 2005?


Join Tables For Definitions (Data Table/Definition Table)



I am well versed with Join/Outer Join/Inner Join. My question is not related to normal Joining of two tables. Its little complex. Let me see if I can explain well.

There are two tables, were data is stored.

Name_Info : nvarchar(10)
Date_Info : smalldate()
Spec_Info_1 : tinyint
Spec_Info_2 : tinyint
Spec_Info_3 ; tinyint

Name_Data : nvarchar(10)
City_Data : nvarchar(10)
State_Data : nvarchar(10)

To join these two tables, I use the following query (joined on Name_Info ON Name_Data)


SELECT Name, Date=CONVERT(varchar, Date, 101), City, State,
CASE Spec_Info_1 WHEN '0' THEN 'House' WHEN '2' THEN 'Shop' WHEN '3' THEN 'Bay' ELSE '-' END AS Spec_Info_1, 
CASE Spec_Info_2 WHEN '0' THEN '10 Feet' WHEN '2' THEN '20 Feet' WHEN '3' THEN '40 Feet' ELSE '-' END AS Spec_Info_2, 
CASE Spec_Info_3 WHEN '0' THEN '2 Windows' WHEN '2' THEN '4 Windows' WHEN '3' THEN '6 Windows' ELSE '-'  END AS Spec_Info_3
FROM Table_Spec_Data LEFT OUTER JOIN Table_Name_Data On Table_Spec_Data.Name_Info=Table_Name_Data.Name_Data  

Insert/Update data to multiple tables on a single button click


Hi experts,

I need to insert/update data to 3 or more tables on a single button click.What is best method for achieving this?I am using mysql as my DB.

Thanks for your valuable reply in advance.

How to copy a Column data from one List to another list whenever a new item created .


Hello ,


I have List A and List B

List A


Ticket ID

Column A

Column B

Column C


List B


Ticket ID

Column 1

Column 2

Column 3

I want to copy only Ticket ID from List A to List B , whenever a new item created in List A.

can you please give your thoughts?

how to do it?

Thanks in Advance!


Share Knowledge and Spread Love!
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend