troubleshooting Question

Insert Into TableA... From TableB Left Outer Join

Avatar of Alan Warren
Alan WarrenFlag for Philippines asked on
Microsoft SQL Server
3 Comments1 Solution1757 ViewsLast Modified:
Using SQL Express 2005

I have a table (tblDefaultPic) that contains one record, it is priming table, the data in it is used to create a default record in another table (tblPics) when a new user is created.

The key field in all tables is UserID which is a UniqueIdentifier.
The field UserID definately exists in table (aspnet_users)

Can't quite seem to get my head around this, maybe its getting late, looking for a quick answer if possible, thanks.

This is what I have, but the select returns 0 records, hmmm.

INSERT INTO tblPics ([Filename], FileExtension, Picture, [Size], [Type], Created, Thumb, Album, Active, PrimaryPic, UserID)

SELECT      D.[Filename], D.FileExtension, D.Picture, D.[Size], D.[Type], D.Created, D.Thumb, D.Album, D.Active, D.PrimaryPic, @UserID
FROM      tblDefaultPic AS D Left OUTER JOIN
        aspnet_Users AS U ON D.UserID = U.UserId LEFT OUTER JOIN
            tblPics as Px ON D.UserID = Px.UserID
            (D.UserID IS NULL)


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros