Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select all rows except some rows

Author  Topic 

hubschrauber
Starting Member

16 Posts

Posted - 2006-02-03 : 09:51:30
Hi all,

Is it possible to say something like

INSERT INTO Book
Book.* EXCEPT (a,c,d)

Something like WITHOUT
DESELECT
EXCLUDING
LESS

Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-03 : 10:05:39
Did you mean this?

Select * from Book where col not in('a','c','d')

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-02-03 : 10:07:14
Please, please, please ...
...Get a book

http://www.sqlteam.com/store.asp
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-02-03 : 10:07:48
Is it something to do with columns or rows ?


If it is columns u can use the following:

DECLARE @s VARCHAR(8000)
Set @s = ''
SELECT @s=@s + Column_name + ','
from INFORMATION_SCHEMA.Columns
where table_name = 'MyTable' and Column_name not in ('a','b','c')
set @s = left(@s, Datalength(@s)-1)
set @s = 'Select ' + @s + ' from MyTable'

INSERT INTO Book
execute ( @s)
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2006-02-03 : 10:11:08
upgrade to 2005 :)

-------
Moo. :)
Go to Top of Page
   

- Advertisement -