|
try something like this.
*assumption that all contract end dates are in the future
select branchname, contractno, email, startdate, enddate, contractreminder, remindertype
from branch
where convert(varchar(20), enddate,112) = convert(varchar920), dateadd(dd, contractreminder, current_timestamp),112)
-- this will then removes the issues of the times in the datetime column
Marc Clifton wrote: That has nothing to do with VB. - Oh crap. I just defended VB!
|
|
|
|
|
I have to search keyword "searching"
Out of this keyword i have to find any 8 characters in the following string
"string to search" .
Can u suggest any approach ?
|
|
|
|
|
look at the patindex function.
Marc Clifton wrote: That has nothing to do with VB. - Oh crap. I just defended VB!
|
|
|
|
|
Hi..
please solve my prob i try this query
select PRODUCTID,u_price, max(qc_dt) dt
from qc where PRODUCTID=1011
group by PRODUCTID,u_price
order by PRODUCTID
result of this query is like
productid.,u_price.,dt
1011......6.00.....2010-01-27 00:00:00.000
1011......5.50.....2010-04-27 00:00:00.000
but i want to show the max date record like
productid.,u_price.,dt
1011......5.50.....2010-04-27 00:00:00.000
please tell me the query
hope you understand
i am waiting ur reply.
|
|
|
|
|
Try this
select top 1 PRODUCTID,u_price, max(qc_dt) dt
from qc where PRODUCTID=1011
group by PRODUCTID,u_price
order by qc_dt
|
|
|
|
|
thanks this query is working for me
|
|
|
|
|
when i change the productid query show old record but i want to show latest u_price of product.
|
|
|
|
|
try
select top 1 productid, u_price, qc_dt
from (select productid, u_price, qc_dt
from qc
where productid = 1011
order by qc_dt desc) z
Marc Clifton wrote: That has nothing to do with VB. - Oh crap. I just defended VB!
|
|
|
|
|
I have a table that has a PK index on a VARCHAR(10) field. I insert 'A'. Next I try to insert 'A '. The insert isn't allowed because of the index. How can I make it so that 'A ' is allowed to be inserted?
Thank you in advance.
EDIT: The first is just A. The second was A[space].
modified on Monday, May 3, 2010 10:35 AM
|
|
|
|
|
yeah, primary keys are a nuissance; they have a habit of wanting to be unique. Remove the old 'A' before you insert a new 'A'.
|
|
|
|
|
The first is just A. The second was A[space].
|
|
|
|
|
If you genuinely need to add a second 'A' (rather than just trying to find out what happens if you do), then the chances are that the design of your database is less than optimal.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
yes, there is an issue with trailing spaces; here[^] is one discussion of that topic. I would avoid such situations by trimming all text before it goes into the database, otherwise you'll get trouble sooner or later, as you can hardly see the spaces at all and they may cause your selections to behave inconsistently.
|
|
|
|
|
Too slow Pattyn!
I still think it's in the wrong place. Shouldn't it be a reply to the OPs' second post?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
As he modified the OP, my answer stands; no need to demote it...
|
|
|
|
|
OK. You get away with it.............this time.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
you're too kind. almost one of a.
|
|
|
|
|
Luc Pattyn wrote: as you can hardly see the spaces at all
I had a PHB asked me once if I could make the spaces blink. That way they could be seen.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|
|
Chris Meech wrote: make the spaces blink.
That makes perfect sense: show all special characters the way MS Word does ("show/hide P"), however don't do it permanently, give the user the option to blink them.
|
|
|
|
|
VARCHARs don't make good primary keys anyway.
|
|
|
|
|
hi
SELECT *
FROM Employees
WHERE (FirstName LIKE N'%ф3rcwvcwvcehveivewiuvgetiugheiheiogheighetighiogheioghioegheiowghioghi
oetjehbvjwebvjefbvjefbvjhebvfjkwbejkfbvjhebvjewbvbevjkewkjvjevfw
jhevfjhebvjefbvejwkfbvewjvbejwbvjefbvjewbvfjkebvjkefvbjefvbjefbvefw
ewvhbewjvbejvbejvfbejfvbjehfvbjewfbvjwefvbewjfvbejhvfbjkevbjhefbvefb
ewkljhvewfvekfjvekfvewkljfbvkejfvbkefbvkewfv%')
In the above query, I have more than 128 characters to search in like predicate, what should be in this case ?
and the error message is
The identifier that starts with is too long. Maximum length is 128.
|
|
|
|
|
Strange: I tried your query with SQL Server 2000 and that did not produce an error message.
By the way, Employees.FirstName is a nvarchar(10), hence the long search term is not very useful here anyway.
What do you actually want to do? Do you want to get a list of employees whose FirstName contains either 'abc' or 'def'? That would be WHERE FirstName Like N'%abc%' OR FirstName Like N'%def%' and so on.
|
|
|
|
|
FormView1.FindControl("TextBox2") as TextBox;
I need like it to select the value for DrowpDownList inside GridView
|
|
|
|
|
(GridView1.Rows[Index].findControl("DropDownList1") as DropDownList).SelecteedValue
|
|
|
|
|
I tried your code . but there is some error :
Compiler Error Message: CS0122: 'System.Data.Index' is inaccessible due to its protection level
|
|
|
|