Click here to Skip to main content
15,444,721 members
Home / Discussions / Database
   

Database

 
Questionvb.net with mysql Pin
KipkoechE8-Feb-15 17:04
MemberKipkoechE8-Feb-15 17:04 
AnswerRe: vb.net with mysql Pin
PIEBALDconsult8-Feb-15 17:33
professionalPIEBALDconsult8-Feb-15 17:33 
GeneralRe: vb.net with mysql Pin
KipkoechE8-Feb-15 18:56
MemberKipkoechE8-Feb-15 18:56 
GeneralRe: vb.net with mysql Pin
PIEBALDconsult9-Feb-15 3:47
professionalPIEBALDconsult9-Feb-15 3:47 
AnswerRe: vb.net with mysql Pin
ZurdoDev9-Feb-15 4:01
professionalZurdoDev9-Feb-15 4:01 
GeneralRe: vb.net with mysql Pin
Jörgen Andersson9-Feb-15 4:09
professionalJörgen Andersson9-Feb-15 4:09 
QuestionRe: vb.net with mysql Pin
Eddy Vluggen9-Feb-15 5:53
professionalEddy Vluggen9-Feb-15 5:53 
QuestionPopulate one table from another Pin
Corporal Agarn6-Feb-15 4:50
professionalCorporal Agarn6-Feb-15 4:50 
Hello, SQL Server 2008R2
I have a list of accounts I want to split between a set of agents. The account table and the agent table have no common value. So I use a while loop to do the populating. As a learning tool I am trying to find a way to update the table with only a query. Here is example code but I am missing the control (see ???):

SQL
CREATE TABLE #MyTestBase (IDX INT, ExampleID INT, TestID INT);
INSERT INTO #MyTestBase (IDX, ExampleID, TestID) VALUES
(132326,406,NULL),(132358,513,NULL),(132367,513,NULL),(132373,513,NULL),(132374,406,NULL),
(132379,406,NULL),(132381,513,NULL),(132405,369,NULL),(132416,406,NULL),(132433,369,NULL),
(132438,369,NULL),(132444,406,NULL),(132457,369,NULL),(132461,406,NULL),(132465,369,NULL),
(132481,369,NULL),(132488,406,NULL),(132494,406,NULL),(132499,513,NULL),(132500,406,NULL),
(132507,406,NULL),(132520,513,NULL),(132521,369,NULL),(132525,369,NULL),(132533,406,NULL),
(132537,369,NULL),(132545,406,NULL),(132551,513,NULL),(132556,513,NULL),(132572,406,NULL),
(132580,369,NULL),(132593,329,NULL),(132600,513,NULL),(132629,513,NULL),(132695,513,NULL),
(132711,406,NULL),(132730,329,NULL),(132781,513,NULL),(132782,369,NULL),(132787,513,NULL),
(132800,406,NULL),(132805,369,NULL),(132813,513,NULL),(132831,369,NULL),(132842,406,NULL),
(132863,513,NULL),(132876,329,NULL),(132880,329,NULL),(132889,329,NULL),(132891,329,NULL),
(132908,329,NULL),(132913,406,NULL);

CREATE TABLE #MyTestCounts (TestID INT, CNT INT);
INSERT INTO #MyTestCounts (TestID, CNT) VALUES
(329,7),
(369,13),
(406,17),
(513,15);

SELECT * FROM #MyTestCounts;
SELECT * FROM #MyTestBase;

UPDATE Base
SET TestID = Counts.TestID
FROM #MyTestBase Base
CROSS APPLY #MyTestCounts Counts
WHERE ??? <= Counts.CNT
AND TestID IS NULL;

In reality these are permanent tables with a lot more information and the update is more complicated but I will worry about that late.

Can someone point me in the right direction?

Thank you for your time,
djj
Mongo: Mongo only pawn... in game of life.

QuestionRe: Populate one table from another Pin
Wendelius6-Feb-15 5:23
mveWendelius6-Feb-15 5:23 
AnswerRe: Populate one table from another Pin
Corporal Agarn6-Feb-15 6:49
professionalCorporal Agarn6-Feb-15 6:49 
AnswerRe: Populate one table from another Pin
Jörgen Andersson9-Feb-15 21:29
professionalJörgen Andersson9-Feb-15 21:29 
GeneralRe: Populate one table from another Pin
Corporal Agarn10-Feb-15 0:42
professionalCorporal Agarn10-Feb-15 0:42 
GeneralRe: Populate one table from another Pin
Corporal Agarn10-Feb-15 2:23
professionalCorporal Agarn10-Feb-15 2:23 
GeneralRe: Populate one table from another Pin
Jörgen Andersson10-Feb-15 4:23
professionalJörgen Andersson10-Feb-15 4:23 
AnswerRe: Populate one table from another Pin
Rony8910-Feb-15 17:00
MemberRony8910-Feb-15 17:00 
GeneralRe: Populate one table from another Pin
Corporal Agarn11-Feb-15 0:43
professionalCorporal Agarn11-Feb-15 0:43 
QuestionHow to upgrade a SQL Server Mobile database? [Solved] Pin
TMattC6-Feb-15 3:03
MemberTMattC6-Feb-15 3:03 
AnswerRe: How to upgrade a SQL Server Mobile database? Pin
TMattC6-Feb-15 8:55
MemberTMattC6-Feb-15 8:55 
AnswerRe: How to upgrade a SQL Server Mobile database? [Solved] Pin
TMattC8-Feb-15 20:19
MemberTMattC8-Feb-15 20:19 
QuestionFull Text Search sqlserver Pin
samanehahmadi2-Feb-15 19:26
professionalsamanehahmadi2-Feb-15 19:26 
AnswerRe: Full Text Search sqlserver Pin
Eddy Vluggen2-Feb-15 22:35
professionalEddy Vluggen2-Feb-15 22:35 
QuestionShrink Problem After Compress Pin
en.Mahdi31-Jan-15 2:58
Memberen.Mahdi31-Jan-15 2:58 
QuestionRe: Shrink Problem After Compress Pin
Richard MacCutchan31-Jan-15 6:15
mveRichard MacCutchan31-Jan-15 6:15 
QuestionOracle Connection User Name and Password [UPDATE] Pin
Kevin Marois30-Jan-15 11:24
professionalKevin Marois30-Jan-15 11:24 
Questionhow can i transfer data Pin
Member 1141305829-Jan-15 12:55
MemberMember 1141305829-Jan-15 12:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.