Wednesday, March 28, 2012
query problem
I make a query like this:
"select * from mytable where myfield like '%2006-06-15%'"
but i didn't get any record for the result and i have make it sure that there are lot of records with that value in myfield. The main problem is the char "-" that separate the date value, becouse if i make a query :
"select * from mytable" then i get all of my records.
Is there any suggest to solf my problem?why u want a like clause on a date time field.
Instead try myfield >= '2006-06-15' and myfield < '2006-06-16'|||Is your date field a datetime datatype, or is it a string?|||Your date is actually formatted more like 0x000097E2008BE35B even though SQL Server displays it as 2006-06-16 13:29 when it returns a value to the client machine. You can use string patterns on it, and SQL Server will happily convert for you, but it isn't efficient and worse yet it isn't always predictable.
The suggested syntax that Ronin gave is both efficient and predictable.
-PatP|||0x000097E2008BE35B?
Is is that late already? I missed my 0x000097E200A4CB80 meeting!
Wednesday, March 7, 2012
Query on dataset
I want to get a particular (row,column) value from the dataset.
How do I query on the dataset if the query is
firstname, lastname where employeeid='1234'?
I feel like I have missed the point, but maybe something like:
select firstName,
lastName
from dataset
where employeeId = '1234'
?
|||What do you mean...dataset? Is this a .NET programming question? Or query in SQL question? Can you post the code you have so far?|||I'm not trying to query the database and fill a dataset.Dave
I get a dataset already containing data and I need to query on the dataset to get a specific value from the dataset.
I know Dataset.Select() exists.
But it does not allow me to pick a (row,column) value based on a criteria.
For example, if the database contains FirstName, LastName, Salary and DOJ in it.
I want to pull only the firstname and lastname of people who joined on maybe 01/06/2006.|||Dave,
This query would work on database and i'm trying to do similar query on a 'DATASET'|||
Krutika:
"Dataset.Select ()" looks to me like a member function; if that is the case this post probably ought to be place in another location to get a better response.
|||which forum should I place this in?|||Dave
I think you can't directly use Select on a DataSet, but you can do it on a DataTable. So it should look like this :
expression = "EmployeeId = '1234'"
DataSet.Table[0].Select(expression)
Then you'll get an array of DataRows.
you can look at this article : http://msdn2.microsoft.com/en-us/library/det4aw50.aspx
|||Thanks this workedQuery on dataset
I want to get a particular (row,column) value from the dataset.
How do I query on the dataset if the query is
firstname, lastname where employeeid='1234'?
I feel like I have missed the point, but maybe something like:
select firstName,
lastName
from dataset
where employeeId = '1234'
?
|||What do you mean...dataset? Is this a .NET programming question? Or query in SQL question? Can you post the code you have so far?|||I'm not trying to query the database and fill a dataset.Dave
I get a dataset already containing data and I need to query on the dataset to get a specific value from the dataset.
I know Dataset.Select() exists.
But it does not allow me to pick a (row,column) value based on a criteria.
For example, if the database contains FirstName, LastName, Salary and DOJ in it.
I want to pull only the firstname and lastname of people who joined on maybe 01/06/2006.|||Dave,
This query would work on database and i'm trying to do similar query on a 'DATASET'|||
Krutika:
"Dataset.Select ()" looks to me like a member function; if that is the case this post probably ought to be place in another location to get a better response.
|||which forum should I place this in?|||Dave
I think you can't directly use Select on a DataSet, but you can do it on a DataTable. So it should look like this :
expression = "EmployeeId = '1234'"
DataSet.Table[0].Select(expression)
Then you'll get an array of DataRows.
you can look at this article : http://msdn2.microsoft.com/en-us/library/det4aw50.aspx
|||Thanks this worked