select values from 1 table and insert in another RRS feed

  • Question

  • Dear All,

    i am making a program in which i have to detect if any changes occur in Client Machine my logic is this

    i am having 2 tables UserInfo and Conflic at server side , since its a client server program so server is on listening mood

    and it take the data which came from client and store it in the UserInfo Table. i pick the loginname and check the quantity of ram and harddisk and then i want to store information about the client whose ram or harddisk decreaase, in a table name conflict

    UserInfo have colums LoginName,UserName,Date,IP,TotalHD,TotalRAM,RamSerialNO,OSName

    Conflict have columns LoginName,UserName,Date,IP,TotalHD,TotalRAM.

    Sever Applications have some strings like loginname in which the name of loginname store similarly username for Username each time new value come and store in particular strings and similarly for others.

    i have successfully inserted the data in UserInfo now i want to run a Query like this

    "SELECT LoginName,UserName,Date,IP where Loginname =@loginname and TotalHD>@totalhd or TotalRam>@totalram";

    and i want to store the result of this query in Conflict Table.

    Can you tell me solution to do that

    if the post helpful please mark it right else feel free to correct me
    Sunday, April 11, 2010 8:46 PM


  • It sounds like you're trying to execute a query within the database to insert rows from one table into another.  If that's the case, you can execute an INSERT query that inserts the results of your UserInfo query into the Conflict table using a query that would look something like:



      INSERT INTO Conflict (LoginName, UserName, [Date], IP, TotalHD, TotalRAM)
        SELECT LoginName, UserName, [Date], IP, TotalHD, TotalRAM FROM UserInfo
          WHERE LoginName = @loginname AND (TotalHD > @totalhd OR TotalRAM > @totalram)

    I hope this information proves helpful.

    David Sceppa
    • Marked as answer by uahmed Monday, April 12, 2010 10:14 AM
    • Marked as answer by uahmed Monday, April 12, 2010 10:14 AM
    Monday, April 12, 2010 2:51 AM