insert into statement

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Stephen (facetoface72_at_hotmail.com)
Date: 04/07/04


Date: 7 Apr 2004 06:48:53 -0700

I'm not too familiar with SQL, but I have this statement which seems
to work but I'm not sure why. I have a table called RAS which has the
same fields as RASTemp table, with a FullName, DeptCode, and
CompanyCode fields as well. However, I have an additional field in
RAS called RASId which is an identity field. The statement below
works, but yet I dont specify anything about the RASId field. How
does the insert into statement know how to match the columns? I tried
reversing the FullName and DeptCode fields in the statement and it
crashed.

INSERT INTO Ras
SELECT dbo.RASTemp.*, dbo.Clients.FullName, dbo.Clients.DeptCode,
dbo.Clients.CompanyCode
FROM dbo.RASTemp LEFT OUTER JOIN
          dbo.Clients ON dbo.RASTemp.UserName = dbo.Clients.UserName

Thanks in advance,
Stephen