Get every n-th record using SQL Server

First, a few things you should already know:
Modulus Returns the remainder of one number divided by another.
SELECT 32/10 -> 3
SELECT 32%10 -> 2

To return the n-th row only of a table, use:

WITH myTableWithRows AS (
    SELECT (ROW_NUMBER() OVER (ORDER BY myTable.SomeField)) as row,*
    FROM myTable)
SELECT * FROM myTableWithRows WHERE row = [value of n]

To return every n-th row in a table, use:

WITH myTableWithRows AS (
    SELECT (ROW_NUMBER() OVER (ORDER BY myTable.SomeField)) as row,*
    FROM myTable)
SELECT * FROM myTableWithRows WHERE [row]%[value of n] = 0

Example:

Return every 10th event from an events table:

WITH tableEvents AS (
    SELECT (ROW_NUMBER() OVER (ORDER BY EventDate)) as row,*
    FROM tblEvents
	Where Month(EventDate) = 7)
SELECT * FROM tableEvents WHERE [row]%10= 0
Advertisements

Assembly Language: Video Character Interface

This section has a set of code examples for writing character data to a PC in 80 character by 25 line mode. The first routine will check the video mode, and if it is a standard mode, the code returns with a no carry condition and starts using the standard video BIOS routines to perform the requested functions. These routines provide many code entry points where other programs may call in. Before using any of the video routines, the program must call the reset_video routine to initialize and make ready the other video calls. Some of the video display routines will respond to video display escape codes. Most of the escape codes deal with standard cursor control functions. There is an example of table selection jumping code.

Most computers use a raster graphics video system. The data is sent to the monitor as rows from left to right that are arranged from top to bottom. The first data bit sent goes to the upper left corner and the last data bit in a frame goes to the lower right corner. When addressing video RAM, the memory may be divided into rows that can be divided into columns. A fundamental understanding of this system is necessary when translating a row and column position into the actual video RAM address for a character or pixel location.

Continue reading “Assembly Language: Video Character Interface”

How to check if a constraint exists

In SQL Server, you can check if a constraint exists using the following script:

SELECT 
    OBJECT_NAME(OBJECT_ID) AS NameofConstraint
        ,SCHEMA_NAME(schema_id) AS SchemaName
        ,OBJECT_NAME(parent_object_id) AS TableName
        ,type_desc AS ConstraintType
    FROM sys.objects
    WHERE type_desc LIKE '%CONSTRAINT'
        AND OBJECT_NAME(OBJECT_ID)='[constraint name here]'

or by running one of the following commands:

SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS where TABLE_Name = '[TableName]'

SELECT *
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE CONSTRAINT_NAME='[constraint name here]'

--Returns one row for each FOREIGN KEY constrain
SELECT *
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
WHERE CONSTRAINT_NAME='[constraint name here]'

--Returns one row for each CHECK constraint
SELECT *
FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS
WHERE CONSTRAINT_NAME='[constraint name here]'

Assembly Language: How to Make Sounds example

This code example provides a set of keyboard routines to control sound output while waiting for a user to enter a keyboard character. The advantage to this method is that a main routine can call these sound routines to play a sound sequence, and the sound routines will return control back to the main routine whenever the user enters keyboard data so that the main routine can continue computing while the sound plays in the background. The code example has two different code entry points for getting keyboard data. One code entry point is a standard get_keyinput call which will wait for a key and update the sound data until a key code is found. The other code entry point is the get_keyinput_to call, which will wait a set amount of time for a key code and if none is found, return with a no key code found condition. The calling routine puts a timeout counter value in register AX on entry. The counter value is based on the system clock which ticks at 18.2 times per second. The entry point start_table_sound is used to begin a background sound sequence. On entry, the register BX indexes a table of sound data. The table has a format of four byte entries and is terminated by a data word of zero. The four bytes are used as two words: the first is a duration count and the second is a tone value. There are two code entry points for turning the background sound off and on. There is also a utility to flush out the keyboard buffer that can be executed with a call to flush_keyboard. Continue reading “Assembly Language: How to Make Sounds example”

Barrister Tony Gani scam

Hiya all, it’s been a while since I had the opportunity to laugh at a scam so nicely done

Capture

Full Text:

STOP CONTACTING THEM !!!!
MW

Mrs. Rozella Wittmeyer. <it@fakhrimen.ir>
Thu 18/01/2018, 3:06 PM

Attention:

I am Mrs. Rozella Wittmeyer, I am a US citizen, 48 years Old. I reside here in Texas USA.My residential address is as follows, 1109 Lake Haven Drive Little Elm Texas 75068 United States,am thinking of relocating since I am now rich. I am one of those that took part in the compensation in United State of American many years ago and they refused to pay me, I had paid over $56,000 while in the US,trying to get my payment all to no avail.

So I decided to travel to Washington with all my compensation documents, And I was directed by the Federal Bureau of Investigation Director to contact Barrister Tony Gani, who is a representative of the Federal Bureau of Investigation and a member of the Compensation Award Committee, currently in USA and I contacted him and he explained everything to me. He said whoever is contacting us through emails are fake.

He took me to the paying bank for the claim of my compensation payment. Right now I am the most happiest woman on earth because I have received my compensation funds of $10.5 Million US Dollars,Moreover,Barrister Tony Gani showed me the full information of those that are yet to receive their payments and I saw your email as one of the beneficiaries on the list he showed me, that is why I decided to email you to stop dealing with those people, they are not with your fund, they are only making money out of you. I will advise you to contact Barrister Tony Gani. Kinldy send your personal details to him to prove your identification.

Full Name:
Home Address:
Occupation:
Phone Number:
Age:
Gender:
country:

Listed below are the name of mafias and banks behind the non release of your funds that I managed to sneak out for your kind perusal.

1) Prof. Charles soludo
2) Senator David Mark
2) Micheal Edward
3) Chief Joseph Sanusi
3) Sanusi Lamido
4) Dr. R. Rasheed
5) Mr. David Koffi
6) Barrister Awele Ugorji
7) Mr. Roland Ngwa
8) Barrister Ucheuzo Williams
9) Mr. Ernest Chukwudi Obi
10) Dr. Patrick Aziza Deputy Governor - Policy / Board Member
11) Mr. Tunde Lemo Deputy Governor - Financial Sector
Surveillance/Board Member
12) Mrs. W. D. A. Mshelia Deputy Governor - Corporate Services / Board
Members
13) Mrs. Okonjo Iweala
14) Mrs. Rita Ekwesili
15) Barr Jacob Onyema
16) Dr. Godwin Oboh: Director Union Bank Of Nigeria.
17) Mr. John Collins: Global Diplomat Director.
18) Foreign fund diplomatic courier
19) Barr. Becky Owens
20) Rev. Steven Jones
21) Mr. Alfred james
22) Mrs. Sherry Williams
23) Mr. Scott Larry

You have to contact Barrister Tony Gani directly on this information below.

Compensation Award House
Name: Barrister Tony Gani
Email: barrtonygani4@gmail.com

You really have to stop dealing with those people that are contacting you and telling you that your fund is with them, it is not in anyway with them, they are only taking advantage of you and they will dry you up until you have nothing. The only money I paid after I met Barrister Tony Gani was just $450 USD for the paper works, take note of that.

Once again stop contacting those people, I will advise you to contact Barrister Tony Gani so that he can help you to deliver your fund instead of dealing with those liars that will be turning you around asking for different kind of money to complete your transaction.

Thank you and be Blessed.

Mrs. Rozella Wittmeyer.
1109 Lake Haven Drive,
Little Elm Texas 75068 United States.

Now why would a middle aged woman from the “United States of American” having an email address made in IRAN contact me without actually knowing my name? 🙂
It seems the text has been copied from Google translate and what I found, the lady name might differ but the Barrister Tony Gani has been reported before:
The so-called “419” scam is a type of fraud dominated by criminals from Nigeria and other countries in Africa. Victims of the scam are promised a large amount of money, such as a lottery prize, inheritance, money sitting in some bank account, etc.

BARRISTER TONY GANI – LAWYERGANI@QQ.COM


This is obviously a scam but just a reminder:

  • Never disclose personal information in any email
  • any amounts that has millions and millions awaiting you are not yours
  • the names of people involved in the email might be real but might not actually be used with the people’s permissions
  • If the reply-to email is different than the sending email – that’s a spoof marker

BE SAFE

Assembly Language: Simple IO Program

The following example illustrates a simple program that gets keyboard input from a user, adds two numbers together, and displays output to the standard video output. This routine uses three basic DOS calls: the DOS function 1 (StdConInput) for input, the DOS function 2 (StdConOutput) for output, and the DOS function 4CH (Exit) to terminate the routine. This routine gets two single-digit numbers from a user, then adds the numbers together and displays the results. The routine continues to operate until the user enters a keyboard character that is not a number.

Continue reading “Assembly Language: Simple IO Program”

An Introduction To Interrupts P2

Describe the problems associated with the timing of interrupts with respect to.

  1. Software Events

    The problem with interrupts is that their occurrence cannot be predicted. They could occur at any time. Critical code portions should be protected by disabling
    interrupts for their duration. A typical example is accessing shared data.The use of interrupts can affect the timing of existing coded routines. This effect
    is unpredictable, due to the nature of interrupts. Code which is heavily timing dependent may not work when interrupts are enabled. These timing critical portions need to be protected also.

    The processing of interrupts should be kept as short as possible, with reguard to the duration of the software event in question.

Continue reading “An Introduction To Interrupts P2”