开发者

Execute Command and Now()

开发者 https://www.devze.com 2023-01-01 18:19 出处:网络
DataContext.ExecuteCommand(\"DELETE from Table WHERE Date < Now()\"); I get an error about how Now() is not a recogn开发者_如何转开发ized built in function name.When you send your SQL query direc
DataContext.ExecuteCommand("DELETE from Table WHERE Date < Now()");

I get an error about how Now() is not a recogn开发者_如何转开发ized built in function name.


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()


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


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


You should use GETDATE() instead of NOW()


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

0

精彩评论

暂无评论...
验证码 换一张
取 消