views:

63

answers:

5
DataContext.ExecuteCommand("DELETE from Table WHERE Date < Now()");

I get an error about how Now() is not a recognized built in function name.

+2  A: 

Could that be GetDate() instead of Now()?

shahkalpesh
+4  A: 

Now() is not TSQL. Use GETDATE() or GETUTCDATE()

StingyJack
+1  A: 

You should use GETDATE() instead of NOW()

sshow
+1  A: 

I don't think Now() is a recognized function in SQL.

Yogendra
+6  A: 

When you send your SQL query directly to SQL Server, you need to use the SQL Server functions - not the .NET ones.

Use this instead:

DataContext.ExecuteCommand("DELETE from Table WHERE Date < GETDATE()");

GETDATE() is the T-SQL equivalent for Now()

marc_s