SQL Server - query error - Asked By chitra ganapathy on 13-Feb-12 12:27 AM

hi, is there any mistake in the following error
select Projectdtls.ProjectId,Projectdtls.Name,Projectdtls.Projectdate=(select CONVERT(varchar(10),getdate(),101)),Projectdtls.Venue,EmployeeDetails.EmployeeName from Projectdtls,EmployeeDetails where Projectdtls.EmployeeId = EmployeeDetails.EmployeeId 
it showing me an error... plz help
Prabhakaran replied to chitra ganapathy on 13-Feb-12 12:30 AM
wat type of error shown? post the error message..
Sandeep Mittal replied to chitra ganapathy on 13-Feb-12 12:33 AM
Issue : "Projectdtls.Projectdate=(select CONVERT(varchar(10),getdate(),101))"

SELECT  Projectdtls.ProjectId,Projectdtls.Name
    , Projectdate = CONVERT(varchar(10),getdate(),101)
    , Projectdtls.Venue,EmployeeDetails.EmployeeName
FROM    Projectdtls,EmployeeDetails
WHERE   Projectdtls.EmployeeId = EmployeeDetails.EmployeeId
Web Star replied to chitra ganapathy on 13-Feb-12 12:44 AM
Issue with red marked line in your query , you make mistake in two place one is where condition is putting in column vlaue in select 
and join condition should be using ON 

select Projectdtls.ProjectId,Projectdtls.Name,
Projectdtls.Projectdate=(select CONVERT(varchar(10),getdate(),101)),
Projectdtls.Venue,EmployeeDetails.EmployeeName from Projectdtls,EmployeeDetails
Where Projectdtls.EmployeeId = EmployeeDetails.EmployeeId 
 

Change above query as follows to corect

select Projectdtls.ProjectId,Projectdtls.Name,
Projectdtls.Venue,EmployeeDetails.EmployeeName from Projectdtls,EmployeeDetails 
ON Projectdtls.EmployeeId = EmployeeDetails.EmployeeId 
 
Where CONVERT( varchar(10), Projectdtls.Projectdate,101) = CONVERT(varchar(10),getdate(),101) 

hope this helps you
chitra ganapathy replied to Sandeep Mittal on 13-Feb-12 12:48 AM
thank u its working...
Somesh Yadav replied to chitra ganapathy on 13-Feb-12 12:51 AM
Hi post the error message what ever it is showing.
Sandeep Mittal replied to chitra ganapathy on 13-Feb-12 12:58 AM
u r welcome
Chintan Vaghela replied to chitra ganapathy on 13-Feb-12 12:58 AM

Hello,

 

Try your query as following way

select Projectdtls.ProjectId,Projectdtls.Name,Projectdtls.Projectdate,Projectdtls.Venue,EmployeeDetails.EmployeeName

from Projectdtls INNER JOIN EmployeeDetails ON Projectdtls.EmployeeId = EmployeeDetails.EmployeeId

WHERE

CONVERT(varchar(10),Projectdtls.Projectdate,101)= CONVERT(varchar(10),getdate(),101)

Hope this is helpful !

Thanks

 

 

 

 

 

chitra ganapathy replied to Sandeep Mittal on 13-Feb-12 03:59 AM
hi, it shows the current date not the table entries date
CONVERT(varchar(10),getdate(),101) 
Sandeep Mittal replied to chitra ganapathy on 13-Feb-12 04:13 AM
If you want to show table field then do like this

Projectdate = CONVERT(varchar(10),Projectdtls.Projectdate,101)
chitra ganapathy replied to Sandeep Mittal on 13-Feb-12 06:35 AM
thank u
Sandeep Mittal replied to chitra ganapathy on 13-Feb-12 06:40 AM
u r welcome