Click here to Skip to main content
15,909,030 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
Hi Everybody out there.
Am trying to write this statement but itz kind of not working.
Chill60 helped me out yesterday but now am tryiny to add a WHERE clause to but the EXCEPT is being underlined. I' ve tried all brackets but ain't getting it right.
An idea?

SQL
SET @Dynamictbl = N'SELECT DISTINCT [Projektdefinition DB] AS Zugänge
 FROM ' + @Table_Name + ' WHERE [Geschäftsbereich] = PB '
 ' EXCEPT
 SELECT DISTINCT [Projektdefinition DB] AS Zugänge
 FROM ' + @Table_Name2 + ' WHERE [Geschäftsbereich] = PB'
Posted
Comments
Rajesh waran 24-Oct-14 5:48am    
don't post it again,this will not clear to all. Go with your old question session and ask corresponding experts who helped you yesterday

1 solution

Try:
SQL
SET @Dynamictbl = N'SELECT DISTINCT [Projektdefinition DB] AS Zugänge
 FROM ' + @Table_Name + ' WHERE [Geschäftsbereich] = ''PB''' + 
 ' EXCEPT
 SELECT DISTINCT [Projektdefinition DB] AS Zugänge
 FROM ' + @Table_Name2 + ' WHERE [Geschäftsbereich] = ''PB'''

or simple remove ['] before Except statement.
 
Share this answer
 
v2
Comments
mikybrain1 24-Oct-14 6:08am    
Thnx @Maciej Los. Tried both but isn't working
Maciej Los 24-Oct-14 6:47am    
What it means: "not working"? Please, be more specific.
mikybrain1 24-Oct-14 7:08am    
Thnx it now fine
Maciej Los 24-Oct-14 7:37am    
If it's fine, please accept my answer as a solution (green button) - formally, to remove your question from unanswered list.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900