Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert "Where" Clause to SQL Server

Status
Not open for further replies.

capronton

MIS
Jun 28, 2013
159
US
Could someone convert the SyBase “Where” clause listed below to SQL Server? See SQL Script below:

[SQL]: SELECT ml.ts, ml.bus, ev.ts, ev.n, ev.route, ev.run, ev.fs, ev.loc_n, ev.rdr_c

from ml, ev
where (ev.loc_n=1 OR ev.loc_n=2 OR ev.loc_n=3) AND (ml.ts>=dateadd(hour,-20, today(*)) AND ml.ts<dateadd(minute,240,today(*)))
and ml.loc_n=ev.loc_n
and ml.id=ev.id

ORDER BY ev.loc_n, ml.bus
[Error]: SQLSTATE = 42000
Microsoft SQL Server Native Client 10.0
Incorrect syntax near '*'.

SELECT ml.ts, ml.bus, ev.ts, ev.n, ev.route, ev.run, ev.fs, ev.loc_n, ev.rdr_c from ml, ev where (ev.loc_n=1 OR ev.loc_n=2 OR ev.loc_n=3) AND (ml.ts>=dateadd(hour,-

Thanks for any assistance.
 
today(*) doesn't exist in SQL Server. Use GETDATE().

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top