mojo666's Profile User Rating: -----

Reputation: 356 Architect
Group:
Expert
Active Posts:
785 (0.39 per day)
Joined:
27-June 09
Profile Views:
11,996
Last Active:
User is offline Dec 03 2014 10:57 AM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Mozilla
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0
Expert In:
Computer Science

Latest Visitors

Icon   mojo666 has not set their status

Posts I've Made

  1. In Topic: Cursor to Create Login from table

    Posted 3 Dec 2014

    You need to use dynamic sql for this. Make a string that contains the whole command for creating user and login and then use the command EXEC @cmd.
  2. In Topic: SQL SERVER Performance tuning

    Posted 3 Dec 2014

    The two ways rows are accessed are "scan" and "seek". A scan looks at every record in the table and checks whether the it is consistent with your where clause. A seek will look at a fraction of the records to find those consistent with your where clause. Seeks are much faster. Basically, if your where clause uses key fields or indexed fields, SQL will tend to use a seek otherwise it will tend to use scans.
  3. In Topic: [C++] bubble sort

    Posted 17 Nov 2014

    for (a = 1; a < size; a++){  
    /*Everything less than a-1 has already been sorted.  Everything else still needs to be sorted.  For example, if you started with {5,4,3,2,1}, when a is gets to 3, the array will look like {1,2,5,4,3}.*/
             for (b = size - 1; b >= a; b--){  /*Because of a's value, the inner loop will only consider the unsorted part of the array, scanning across positions greater or equal to a.*/
                 if (nums[b - 1] > nums[b]){  /*if the right number is smaller than the left number, swap the values*/
                     t = nums[b - 1];  
                     nums[b - 1] = nums[b];  
                     nums[b] = t;  
                 }  
             } 
    
    


    Take the following array: {5,4,3,1,2}

    For the outerloop, a starts at 1. The inner loop will start with b=4 and stop when b=0. After each iteration of the inner loop, the array will look as follows:
    b=4 {5,4,3,1,2} nothing happened since nums[4] was already greater than nums[3]
    b=3 {5,4,1,3,2} swapped nums[3] with nums[2]
    b=2 {5,1,4,3,2} swapped nums[2] with nums[1]
    b=1 {1,5,4,3,2} swapped nums[1] with nums[0]
    b is now 0 so we stop.
    
    Now a is 2, so the inner loop will start with b=4 and stop when b=1
    b=4 {1,5,4,2,3} swapped nums[4] with nums[3]
    b=3 {1,5,2,4,3} swapped nums[3] with nums[2]
    b=2 {1,2,5,4,3} swapped nums[2] with nums[1]
    b is now 1 so we stop
    
    This process repeats untill a is 5
    
    
  4. In Topic: Remove repeating numbers in array

    Posted 14 Nov 2014

    As pointed out, your assignment statement is backwards. Another issue is that the way your algorithm is going, your output is going to be the same as your input. What you are doing is storing an element in the output so long as there is a different element somewhere later in the input. For example:
    {1,1,1,2,1}
    When i=0 and y=3, you will store the value at 0 into the output at 0. The same goes for when i is 1 or 2.

    Your inner loop should not be concerned with other areas of the input array. Rather you should be checking the output array that has been constructed so far to see if you have already inserted the value somewhere in the output. After you searched the entire output array you make a choice whether or not to insert the value of the input.
  5. In Topic: CAST to INT if a number

    Posted 10 Nov 2014

    I think you can just do something like the following.

    SELECT SUM(CAST(myField AS INT))/COUNT(*) AS Average FROM myTable WHERE myField<>'N/A'
    

My Information

Member Title:
D.I.C Addict
Age:
30 years old
Birthday:
July 23, 1984
Gender:
Interests:
Chess, math, computers, AI
Years Programming:
6
Programming Languages:
C++, C#, VB.net, SQL, OCAML, LISP, MIPS

Contact Information

E-mail:
Private
Website URL:
Website URL  http://

Friends

Comments

mojo666 has no profile comments yet. Why not say hello?