Friday, March 30, 2012

How can i Replace the Minus-Statement

Hi,

I've to translate this SQL-Statement from ORACLE to SQL-Server. But I'm missing the Minus-Statement on SQL-Server.

select table_name, column_name from user_tab_columns
where table_name not in ( select table_name from user_tab_columns
minus
select tab_name from data_dic
)
minus
select tab_name, col_name from data_dic

what can I do to run it on SQL-Server.

Thanks in advance

Raimund

use whidbey's intersect function|||

Hi you didn′t specify wheter you are using 2k5 or 2k. In SQL Server you would use EXCEPT

select table_name, column_name from user_tab_columns
where table_name not in ( select table_name from user_tab_columns
EXCEPT
select tab_name from data_dic
)
EXCEPT
select tab_name, col_name from data_dic

in 2k, you would use NOT IN, like you did in the above query:


select table_name, column_name from user_tab_columns
where table_name not in ( select table_name from user_tab_columns
WHERE table_name NOT IN
(
select tab_name from data_dic
)
)
WHERE table_name NOT IN
(
select tab_name, col_name from data_dic
)


HTH, Jens Suessmeyer.


http://www.sqlserver2005.de

|||

Thanks it works fine.

I already had it before but it didn't work. Probably there was something wrong in the Syntax.

Best Regards

Raimund

No comments:

Post a Comment