IT Questions and Answers :)

Thursday, December 6, 2018

What does the Transact-SQL server RAND function do?

What does the Transact-SQL server RAND function do?

  • Aggregates a subset of random numbers
  • Generate a random number
  • Requests a range of numbers from a subset
  • Selects an random number from subset 

 
What does the Transact-SQL server RAND function do?

EXPLANATION




 SQL Server: RAND Function
This SQL Server tutorial explains how to use the RAND function in SQL Server (Transact-SQL) with syntax and examples.

Description

In SQL Server (Transact-SQL), the RAND function can be used to return a random number or a random number within a range.

Syntax

The syntax for the RAND function in SQL Server (Transact-SQL) is:
RAND( [seed] )

Parameters or Arguments

seed
Optional. If specified, it will produce a repeatable sequence of random numbers each time that seed value is provided.

Note

  • The RAND function will return a value between 0 and 1 (not inclusive), so value > 0 and value < 1.
  • The RAND function will return a completely random number if no seed is provided.
  • The RAND function will return a repeatable sequence of random numbers each time a particular seed value is used.

Random Decimal Range

To create a random decimal number between two values (range), you can use the following formula:
SELECT RAND()*(b-a)+a;
Where a is the smallest number and b is the largest number that you want to generate a random number for.

SELECT RAND()*(25-10)+10;
The formula above would generate a random decimal number between 10 and 25, not inclusive.
TIP: This formula would generate a random decimal number that is > 10 and < 25 but it would never return exactly 10 or 25.

Random Integer Range

To create a random integer number between two values (range), you can use the following formula:
SELECT FLOOR(RAND()*(b-a+1))+a;
Where a is the smallest number and b is the largest number that you want to generate a random number for.
SELECT FLOOR(RAND()*(25-10+1))+10;
The formula above would generate a random integer number between 10 and 25, inclusive.
TIP: This formula would generate a random integer number that is >= 10 and <= 25.

Applies To

The RAND function can be used in the following versions of SQL Server (Transact-SQL):
  • SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005

Example of Random Number

Let's explore how to use the RAND function in SQL Server (Transact-SQL) to generate a random number between 0 and 1, not inclusive.
For example:
SELECT RAND();
Result:  0.143811355073783     (no seed value, so your answer will vary)

SELECT RAND(9);
Result:  0.713741056982989     (with seed value of 9)

SELECT RAND(-5);
Result:  0.713666525097956     (with seed value of -5)

Example of Random Decimal Range

Let's explore how to use the RAND function in SQL Server (Transact-SQL) to generate a random decimal number between two numbers (ie: range).
For example, the following would generate a random decimal value between 1 and 10, not inclusive (random number would be greater than 1 and less than 10):
SELECT RAND()*(10-1)+1;
Result:  5.09104269717813      (no seed value, so your answer will vary)

SELECT RAND(9)*(10-1)+1;
Result:  7.4236695128469       (with seed value of 9)

SELECT RAND(-5)*(10-1)+1;
Result:  7.42299872588161      (with seed value of -5)

Example of Random Integer Range

Let's explore how to use the RAND function in SQL Server (Transact-SQL) to generate a random integer number between two numbers (ie: range).
For example, the following would generate a random integer value between 10 and 20, inclusive:
SELECT FLOOR(RAND()*(20-10+1))+10;
Result:  19                   (no seed value, so your answer will vary)

SELECT FLOOR(RAND(9)*(20-10+1))+10;
Result:  17                   (with seed value of 9)

SELECT FLOOR(RAND(123456)*(20-10+1))+10;
Result:  10                   (with seed value of 123456)
 
Share:

Tuesday, December 4, 2018

What is the largest partition size supported by native DOS running FAT16?

What is the largest partition size supported by native DOS running FAT16?

  • 3GB
  • 2GB
  • 1GB
  • 512MB 
What is the largest partition size supported by native DOS running FAT16?

EXPLANATION

Due to the mathematical limitations of FAT16, without an overlay file or special driver the largest partition size is 2GB.The limit on partition size was dictated by the 8-bit signed count of
sectors per cluster, which originally had a maximum power-of-two value of 64. With the standard hard disk sector size of 512 bytes, this gives a maximum of 32 KiB cluster size, thereby fixing the "definitive" limit for the FAT16 partition size at 2 GiB for sector size 512.

SOURCE

https://en.wikipedia.org/wiki/File_Allocation_Table

Share:

Wednesday, November 28, 2018

What is the not equals operator in Excel?

What is the not equals operator in Excel?

  • NOT()
  • <>
  • >=
  • !=

 
What is the not equals operator in Excel?

EXPLANATION

When comparing two pieces of data in Excel, what operator would you use to test if they were not equal?
If I were comparing cells A1 to B1, my formula would be:

=A1___B1
NOT() is a function, not an operator.

SOURCE

https://support.office.com/en-us/article/Calculation-operators-and-precedence-in-Excel-48be406d-4975-4d31-b2b8-7af9e0e2878a#tblID0EABCAFAAA
Share:

Monday, November 26, 2018

In SQL, what is the effect of the TRUNCATE TABLE statement?

In SQL, what is the effect of the TRUNCATE TABLE statement?

  • To delete all of the rows contained within a table
  • To drop all of the tables in a database
  • To shorten all textual values in a column to a specified number of characters
  • To drop all of the columns defined on a table 

 
In SQL, what is the effect of the TRUNCATE TABLE statement?

EXPLANATION

TRUNCATE TABLE table-name;
 
TRUNCATE removes all of the rows from the specified table without logging the individual row deletions, without scanning the table, and makes freed disk space available to the operating system immediately, without requiring a subsequent VACUUM operation.
TRUNCATE TABLE is similar to a DELETE statement with no WHERE clause, which also removes all of the rows from a table; however, TRUNCATE is faster and uses fewer resources. TRUNCATE is most useful when working with very large tables where an unqualified DELETE could adversely affect database performance.

Share:

Tuesday, November 20, 2018

Which of these is an advantage of Manchester Encoding?

Which of these is an advantage of Manchester Encoding?

  • It uses less bits than the original signal
  • It is named after an English City
  • Very easy to understand
  • The signal is self-synchronizing 

Which of these is an advantage of Manchester Encoding?

EXPLANATION

"In data transmission, Manchester encoding is a form of digital encoding in which data bits are represented by transitions from one logical state to the other. This is different from the more common method of encoding, in which a bit is represented by either a high state such as +5 volts or a low state such as 0 volts".
"The chief advantage of Manchester Encoding is the fact that the signal synchronizes itself." (See link for further reading).

http://searchnetworking.techtarget.com/definition/Manchester-encoding
Share:

Tuesday, November 13, 2018

Which of these files will not fit in a 32GB flashdrive formatted as FAT32?

Which of these files will not fit in a 32GB flashdrive formatted as FAT32?

  • 10 .msi files with 1000MB each
  • A .zip file with 1024MB
  • 3 .tar.gz files with 5GB each
  • All of them would fit just fine 
Which of these files will not fit in a 32GB flashdrive formatted as FAT32?

EXPLANATION

Since your flash drive is formatted with the FAT32 file system, any file that is larger than 4GB will not be placed there. This type of a file system has a built-in limitation on the size of the files that it may contain. Although the total size of the files that you can copy to a FAT32 drive could be as large as 2TB (or the physical capacity of the drive, whichever is smaller), the size of each individual file may not exceed 4GB.

This limitation may sound silly: why would anyone design a system that would not allow for the larger files? The problem is, when the FAT32 file system was designed (that was back in the days of Windows 95), no one anticipated that we would have such large files in use today. Or, maybe the designers hoped that by the time such large files became common, the use of the FAT32 system would be replaced by more modern systems.

Share:

Which of the following is not an example of a denial-of-service attack?

Which of the following is not an example of a denial-of-service attack?

  • Fraggle
  • Smurf
  • Teardrop
  • Roadrunner 

Which of the following is not an example of a denial-of-service attack?

EXPLANATION

 Smurf / Smurfing

When conducting a smurf attack, attackers will use spoof their IP address to be the same as the victim’s IP address. This will cause great confusion on the victim’s network, and a massive flood of traffic will be sent to the victim’s networking device, if done correctly.

Most firewalls protect against smurf attacks, but if you do notice one, there are several things you can do. If you have access to the router your network or website is on, simply tell it to not forward packets to broadcast addresses. In a Cisco router, simply use the command: no ip directed-broadcast.

This won’t necessarily nullify the smurf attack, but it will greatly reduce the impact and also prevent your network or website from attacking others by passing on the attack. Optionally, you could upgrade your router to newer Cisco routers, which automatically filter out the spoofed IP addresses that smurf attacks rely on.

Fraggle


A Fraggle attack is exactly the same as a smurf attack, except that it uses the user datagram protocol, or UDP, rather than the more common transmission control protocol, or TCP. Fraggle attacks, like smurf attacks, are starting to become outdated and are commonly stopped by most firewalls or routers.

If indeed you think you are being plagued by a fraggle attack, simply block the echo port, located at port 7. You may also wish to block port 19, which is another commonly used fraggle exploitable port. This attack is generally less powerful than the smurf attack, since the TCP protocol is much more widely used than the UDP protocol.

Teardrop


In the teardrop attack, packet fragments are sent in a jumbled and confused order. When the receiving device attempts to reassemble them, it obviously won’t know how to handle the request. Older versions of operating systems will simply just crash when this occurs.

Operating systems such as Windows NT, Windows 95, and even Linux versions prior to version 2.1.63 are vulnerable to the teardrop attack. As stated earlier, upgrading your network hardware and software is the best way to stay secure from these types of attacks.
Fraggle, Smurf, and Teardrop are all actual denial-of-service attacks. Roadrunner is not.
Share:

Popular Posts