[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.0

Assign random users into a field in another table--- SQL

Asked by AIdoHSG in SQL Server 2005, MS SQL Server, SQL Server 2008

Hello,

My group is in the process of trying create a process to reach out to respondents we don't' work with. To clean up our database we are creating this database to generate random ids based on a criteria and assign random people to those ids to call.

I'm trying to create a stored procedure so i can have it run on a weekly bases and assign ids.
I have a table called tblAssignedIDs: I have ID and UserName as Fields
I'm pulling random ids based on a view I created vwAllContacts_ToAssing which only has IDs
I also have a table called tblHSGUser_ResOps which has my users who will get assigned to those Ids.

First I want to duplicate the existing tblAssignedIDs because I need to clear it out and replace it with new IDs each week. so my query to select new Ids and inserting them into the table is working. but I need to limited the Top select based on # of Users in the tblHSGUser_ResOps X 5 so example I have 12 users in the table then it would be 12 * 5 = 60 so I need to select top 60. This is working, but i'm not sure if there is a better way
That is the first step

Second step:
After the ids have been added to the tblAssigneIDs I want to randomly again assign users to those IDs... so for example 12 user each get 5 respondents. in the tblHSGUser_ResOps i have their userAbbrev I want to take that info and drop it randomly i the tblAssignedIDs.

Below are the codes I'm using
Can anyone help?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
/*Step 1-- Duplicate table  */
SELECT * INTO tblTempAssign FROM dbo.tblAssignedIDs_ToUpdate;
 
/*Step 2-- Delete existing data  */
DELETE FROM dbo.tblAssignedIDs_ToUpdate;
 
/*Step 3-- Find out the number of users  */
SELECT Count(UserNetworkName) * 5 As UCount
FROM dbo.tblHSGUsers_ResOps;
 
/*Step 4-- Insert data into table  */
INSERT INTO dbo.tblAssignedIDs_ToUpdate (ID)
SELECT     TOP (SELECT Count(UserNetworkName) * 5 As UCount
FROM dbo.tblHSGUsers_ResOps) dbo.vwAllContacts_ToAssign.ID
FROM         dbo.vwAllContacts_ToAssign LEFT OUTER JOIN
                      dbo.tblTempAssign ON dbo.vwAllContacts_ToAssign.ID = dbo.tblTempAssign.ID
WHERE     (dbo.tblTempAssign.ID IS NULL)
GROUP BY dbo.vwAllContacts_ToAssign.ID
ORDER BY RAND(dbo.vwAllContacts_ToAssign.ID);
 
/*Step 5-- Drop Duplicate table  */
DROP TABLE tblTempAssign;
 
/*Step 6-- Assign Users  */
 
Related Solutions
Keywords: Assign random users into a field in ano…
 
Loading Advertisement...
 
[+][-]04/27/09 07:04 AM, ID: 24241754Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: SQL Server 2005, MS SQL Server, SQL Server 2008
Sign Up Now!
Solution Provided By: AIdoHSG
Participating Experts: 2
Solution Grade: A
 
[+][-]04/16/09 10:30 AM, ID: 24160177Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/16/09 10:48 AM, ID: 24160351Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/16/09 11:25 AM, ID: 24160857Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/16/09 11:32 AM, ID: 24160964Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/16/09 12:03 PM, ID: 24161327Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/16/09 12:12 PM, ID: 24161429Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/16/09 12:37 PM, ID: 24161661Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/16/09 07:36 PM, ID: 24164527Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/17/09 05:42 AM, ID: 24167131Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625