im pretty new in sql coding and i couldent find a solution on internet, heres my code:
CREATE PROCEDURE GET_SAMEDATE (@FileName VARCHAR(50))
AS
/* SET NOCOUNT ON */
SELECT Hash
FROM Beamer.PackageDetailFile A(NOLOCK)
INNER JOIN(SELECT FileName,
MAX(Date) MaxDate
FROM Beamer.PackageDetailFile(NOLOCK)
GROUP BY FileName)B
ON B.FileName = A.FileName
AND A.Date = B.MaxDate
WHERE FileName = @FileName
what i want to do is i want to compare the FileName with the filename i obtain from a c# class
And im also getting "Ambiguous column name 'FileName' "
* ambigious column name is resolved but still i cannot get the FileName from the other class to compare if they have the same filename
the c# code
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand = new SqlCommand("dbo.GET_SAMEDATE", myConnection );
myCommand.CommandType = CommandType.StoredProcedure;
try
{
myConnection.Open();
SqlDataReader sdr = myCommand.ExecuteReader();
while (sdr.Read())
{
string h = (string)sdr.GetString(0);
if (hash != h)
{
exists = true;
}
sdr.Read();
}