Click here to Skip to main content
15,885,886 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is Qyery in ms Access how to write and execute this in Sql server 2008


SQL
select VrNo,OrderNo, (First_name + ' ' + Last_name) as Name,DoB,Gender,ShippingType,Address,City,State,Country,ZipCode,DrName,PName,vr_date,Status,Remark from TransactionMaster where
                            CDate(IIF(isnull(SuppliedDate),'01/01/1990',SuppliedDate))=CDate(' 11/30/2013')
OR
  ( ( CDate(IIF(isnull(SuppliedDate),'01/01/1990',SuppliedDate))  and  (CDate(IIF(isnull(vr_date),'01/01/1990',vr_date)) >= CDate('11/30/2013')-1 AND CDate(IIF(isnull(vr_date),'01/01/1990',vr_date))
 <= CDate('11/30/2013'))) and AdminEdit='0') order by vrno desc
Posted
Updated 16-Dec-13 21:36pm
v2
Comments
Amir Mahfoozi 17-Dec-13 3:56am    
In this case everything is like SQL Server but for "IIF(ISNULL" part you can replace it with COALESCE function.

1 solution

SQL
CDate(IIF(isnull(SuppliedDate),'01/01/1990',SuppliedDate))


becomes

SQL
coalesce(SuppliedDate, '1900/01/01')


This returns supplied date, or the constant, if supplied date is null.

It seems you want to convert an int to a date. You can't do that in SQL Server. CDate also does not exist ( as I keep saying ). Here is a page listing possible conversions and if you need to make them explicit:

http://msdn.microsoft.com/en-us/library/ms187928.aspx[^]
 
Share this answer
 
v3
Comments
Maciej Los 17-Dec-13 4:11am    
5ed!
[no name] 17-Dec-13 4:22am    
No itz not working in sql server 2008
Christian Graus 17-Dec-13 4:27am    
Instead of saying 'it's not working', try reading the error messages, or posting the SQL you're trying and the error message. IF you want us to do your job for you, it helps if you don't ask us to read your mind.
[no name] 17-Dec-13 4:44am    
when i tried this CDate(IIF(isnull(SuppliedDate),'01/01/1990',SuppliedDate)) to change

CDate(IIF(isnull(SuppliedDate),'01/01/1990',SuppliedDate)) its not showing result . in sqlserver2008
Christian Graus 17-Dec-13 4:46am    
OK, I was not clear. CDate does not work. Don't use it, it is not needed, and does not work. That's why your error message is telling you it is wrong.

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