March 12, 2010 at 1:18 pm
Hi. How would I go about inserting multiple values into a table based on the results of the IN as below:
SELECT UserId
FROM Users
WHERE UserName IN ('Joes_Bloggs','John Doe' etc..........)
GO
--Inset values returned from previous query.
INSERT INTO [db].[dbo].[ProfileUsers]
([Profile],
[UserId],
[CreatedDate],
[CreatedUser],
[LastModifiedUser],
[LastModifiedDate])
VALUES
(1,
WHATEVER THE USER NAMES MIGHT BE FROM IN,
GETDATE(),
'Sys',
'Sys',
GETDATE())
GO
Am I barking up the wrong tree?
Kind Regards,
Phil.
-------------------------------------------------------------------------------------
A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."
Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '
Tommy Cooper
March 12, 2010 at 1:23 pm
Don't think about a specific user. Do it set based:
INSERT INTO [db].[dbo].[ProfileUsers]
([PROFILE],
[UserId],
[CreatedDate],
[CreatedUser],
[LastModifiedUser],
[LastModifiedDate])
SELECT
1,
UserId,
GETDATE(),
'Sys',
'Sys',
GETDATE()
FROM Users
WHERE UserName IN ('Joes_Bloggs','John Doe' etc..........)
March 12, 2010 at 1:35 pm
Lutz now that is what I call service.
Many thanks,
Phil.
-------------------------------------------------------------------------------------
A neutron walks into a bar. "I'd like a beer" he says. The bartender promptly serves up a beer. "How much will that be?" asks the neutron. "For you?" replies the bartender, "no charge."
Two hydrogen atoms walk into a bar. One says, 'I think I've lost an electron.' The other says 'Are you sure?' The first says, 'Yes, I'm positive... '
Tommy Cooper
March 12, 2010 at 1:56 pm
You're welcome! 😀
Going back to the picture you used:
Sometimes it's faster to just cut the tree rather than just barking up... 😉
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply