473,545 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copy one row from tableA to tableB

I want to copy all columns from tblA into tblB where tblA.UniqueID =
parameter @ID without having to list each column name in an insert
statement. Is this possible?
Thanks,
lq

Jul 23 '05 #1
3 1485
I forgot to mention all column names and data types are identical in
tblA and tblB except for the UniqueID which is PK in tblA and not PK in
tblB.
lq

Jul 23 '05 #2
Stu
Sure,

INSERT INTO tblB
SELECT *
FROM tblA
WHERE UniqueID = @ID

Stu

Jul 23 '05 #3
laurenq uantrell (la************ *@hotmail.com) writes:
I want to copy all columns from tblA into tblB where tblA.UniqueID =
parameter @ID without having to list each column name in an insert
statement. Is this possible?


Under some circumstances, yes.

Then again, in application code, I think it is very bad practice to say:

INSERT tbl2 SELECT * FROM tbl1

SELECT * itself is bad practice, so are INSERT statements without listing
of target columns.

Why are this bad:

* You cannot see if a column is actually used.
* If the table defintion changes, the result of the SELECT changes.
* And for INSERT it is likely to result in the INSERT statment failing.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4546
by: Ray | last post by:
Hello, This one I think should be easy when you now how but I couldn't get it today. I have to run a kind of double check routine. 1 database, 2 tables. No linking or referential integrity or any of that. TableA has 2 fields that matter - .... TableB is exactly the same - ....
42
5723
by: Edward Diener | last post by:
Coming from the C++ world I can not understand the reason why copy constructors are not used in the .NET framework. A copy constructor creates an object from a copy of another object of the same kind. It sounds simple but evidently .NET has difficulty with this concept for some reason. I do understand that .NET objects are created on the GC...
0
2718
by: fhelik | last post by:
I have "tableA" with column "a" and "tableB" with column "b". Column "a"has new material to, i need to run somthing like upgrade? please help. give examples i am a newbe this is mysql thank you
1
1442
by: Mclaren | last post by:
hi, i have 2 subforms on a form(Form1) (SubformA and SubformB). each subform is on a seperate page of a tab control. each of the subforms displays data in datasheet view. each of the subforms are based on their own seperate table(TableA and TableB). these 2 tables are linked to Table1, via a one to many relationship. Each of the tables have...
3
12823
by: maheshkadam | last post by:
Hi friends I am new to perl so please guide me. I have one application which created backup log file every day.But it appends that file so you can see logs for different day in one file only. My requirement is to copy backup log for the specific day (yesterday) and write in other file. That file will be mailed to admin for ready reference....
9
15105
by: fniles | last post by:
I would like to copy a table(s) from SQL Server 2005 to a CVS file and vice versa. I was thinking to use the BCP command line utility, but I have a few questions: 1. The machine where I am going to run BCP utility does not have SQL Server installed, so BCP.exe and its underlying DLLs are not there. I copied BCP.EXE, then it tells me that...
0
1061
by: dave | last post by:
I've tried various things for the last two hours, and I give up! What I really need is ImportRowAt(), and it would solve my issue, but since that doesn't exist: I have two tables with identical schema. I run through TableB and if I find a row that matches my criteria, I want to insert it as the FIRST row of TableA, which already contains...
0
7478
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7923
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5984
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4960
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3466
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.