sqlselectconditional-statements

Selectively importing data in sql


First, I apologize if the title is misleading. I am still quite new to this and not all that adept with the verbage in SQL.

I have a table named Original. It has 90 columns. I am seeking to create another table which takes 25 of these columns. Only one of them has a condition on it. The z column has values between 1 and 6. I want to copy/take those records where z is not equal to 2. As of yet, this is what i am thinking might work.

select 1-24,'z' not equal to 2 from dbo.original

Is it really this simple or is there more to it?


Solution

  • Try this one out and see if it works out for you:

    SELECT 1,2,3,...,23,24,z
    FROM dbo.original
    WHERE z != 2;