Problems with sqlcmd -q and quotations marks
Try to use this. ;-)

use DB; EXEC sp_MSforeachtable @command1=N'print ''?'' DBCC DBREINDEX (''?'', '' '', 80) ';


Double quotation marks will escape the following quotation mark.

Here an example of sqlcmd:

sqlcmd -S YOURSERVER -Q "use net_temp_test; EXEC sp_MSforeachtable @command1=N'print ''?''';"