Dear SQL, How to convert If statement to Case ? I have already tried but does not work. Here my function : ALTER Function MaxId() Returns Char(4) As Begin ...
2698
Arnie Rowland
arnie1568
Dec 14, 2006 10:36 pm
Wouldn't it be much simpler to do something like this: DECLARE @MaxValue SmallInt SET @MaxValue = 2 SELECT right( '000' + cast(@MaxValue as varchar(4)), 4) -...
2699
Qurashi Ameer
dinq11
Dec 14, 2006 10:47 pm
hi All i want to match dates of two table to finde the result i have a quiry dat didn't work Select c.prodid as PCode, p.ProdName as Product, sum(c.qty ) as ...
2700
Arnie Rowland
arnie1568
Dec 14, 2006 11:06 pm
If you want all times for Oct 1, 2006, then change your WHERE clause to: WHERE ( ( m.CustInvDate >= '10/1/200639; AND m.CustInvDate < '10/2/200639; ) AND (...
2701
Rick Justis
rickj2
Dec 15, 2006 9:02 am
I have found that date comparisons are easier for me if it is a text field and the fate is formatted yyyy-mm-dd. That's just what works for me. ... From:...
2702
Jeremy Hilden
jeremy_hilden
Dec 15, 2006 7:22 pm
Try "inner join" instead of "join" for those tables that you are joining. In your where clause, make it: where m.custinvdate = '10/1/200639; and sm.dtpreturn =...
2703
Arnie Rowland
arnie1568
Dec 15, 2006 8:07 pm
INNER is the default JOIN -it is NOT necessary to use the work INNER. With this suggestion, I hope none of the datetime fields have a time portion other than...
2704
Noman Aftab
noman17pk
Dec 16, 2006 9:16 am
where m.custinvdate >= '10/1/200639; And m.custinvdate <= '10/1/2006 23:59:59' and sm.dtpreturn >= '10/1/200639; and sm.dtpreturn <= '10/1/2006 23:59:59' when...
2705
Alberto Mujica
amujica@...
Dec 16, 2006 10:26 am
The most effective way I have found to perform date comparisons is to do something like this: SELECT [SomeFields] FROM [dbo].[SomeTable] WHERE...
2706
Arnie Rowland
arnie1568
Dec 16, 2006 4:12 pm
One problem with this approach is that it will NOT use indexes on the [DatetimeStampField]. A table scan will occur. Anytime you wrap a column with a function,...
2707
Alberto Mujica
amujica@...
Dec 16, 2006 7:13 pm
Ohhh... I see, that explains some things.... Thanks, Alberto Mujica amujica@... ________________________________ From:...
2708
Arnie Rowland
arnie1568
Dec 16, 2006 8:22 pm
This example will properly use indexing AND return data for a week from the @ReportDate parameter: USE Northwind GO DECLARE @ReportDate datetime SET...
2709
John Warner
john@...
Dec 16, 2006 11:01 pm
Cool, I was unaware that using the cast and format codes would stop it from using indexes, nice to see how to work around. Is there no way to 'effectively39;...
2710
Rick Justis
rickj2
Dec 17, 2006 9:11 pm
I am creating an online poll that has the ability to do freeform and multiple choice. On the view results page, I've got it working on the multiple choice but...
2711
Rick Justis
rickj2
Dec 17, 2006 9:16 pm
sorry, I made a error. I have the different polls in one table and the answers in another table linked by PollID. Any help would be greatly appreciated. ...
2712
A.J. Morales
ajmorales.rm
Dec 18, 2006 6:47 am
I find on occasion the numeric comparison sometimes needs to be inside a pair of single quotes; example case when Len(Cast(ItemOfInterest As Varchar)) = '1'...
2713
Arnie Rowland
arnie1568
Dec 18, 2006 7:21 am
Then it is not a 'numeric comparison39;, is it? Len() returns a number, not a string. Putting a number in single quotes makes it a string. Comparing a number to...
2714
alex.benitez@...
Dec 18, 2006 9:46 am
I will be out of the office starting Mon 12/18/2006 and will not return until Wed 12/27/2006. I will respond to your message when I return. I will be checking...
2715
tgray@...
imadba2006
Dec 18, 2006 3:51 pm
I made a table called test with the following structure: create table test (PollID int, Ans varchar(30)) Because you can't do a DISTINCT within a TOP n...
2716
Elanchezhian S
chels_1977
Dec 18, 2006 4:23 pm
Hi, I think this will be take out both IF and CASE confusions. DECLARE @MaxValue SMALLINT, @Value Char(4) SET @MaxValue = 1 SELECT @Value = STUFF(@MaxValue, 1,...
2717
A.J. Morales
ajmorales.rm
Dec 19, 2006 1:09 am
Well, OK then, please disregard! Thanks AJ Arnie Rowland <arnie@...> wrote: Then it is not a 'numeric comparison39;, is it?...
2718
Rick Justis
rickj2
Dec 19, 2006 5:15 pm
you are awesome!!! That worked great!! thanx!!! I adapted the rowcount part to fit my dbms and webserver but it did the trick. If you are even in Austin,...
2719
Ronda Pederson
rondakay
Dec 20, 2006 7:26 pm
I am stuck! I am using the 2.0 SQLDatasource to pass a query and can not seem to make it work. I am not even sure if the query itself is good. as I seem to...
2720
Ronda Pederson
rondakay
Dec 20, 2006 7:54 pm
Okay forget everything below.. I ended up putting it into a sproc. Which STILL isn't working. Can someone show me what I am doing wrong with the datediff...
2721
tgray@...
imadba2006
Dec 20, 2006 8:27 pm
Are you sure that tcbond_payment.p_date column is defined as a datetime? If not, you'll need to convert it before you can use it in datediff. Tracey Gray ...
2722
Arnie Rowland
arnie1568
Dec 20, 2006 8:44 pm
Rhonda, You know that you 'should39; have put it in a sproc to start with... ;-) Also, anytime you wrap a column with a function, you eliminate the possibility...
2723
Ronda Pederson
rondakay
Dec 20, 2006 9:49 pm
Arnie, Do you see any reason it would be returning these records? Clearly they aren't in the date range? Could it just be looking at the DAY Project Date ...
2724
John Warner
john@...
Dec 20, 2006 10:12 pm
It might be looking at the month, these are within 3 months of each other. John Warner ... <mailto:SQLQueriesNoCode%40yahoogroups.com> yahoogroups.com. If you...
2725
Arnie Rowland
arnie1568
Dec 20, 2006 10:43 pm
The date range is MORE than 30 days old [<=]. The data looks correct. Or, Do you wish for the past 30 days, and if so, change the [<=] to [>=]. - Arnie Rowland...
2726
Ronda Pederson
rondakay
Dec 20, 2006 11:32 pm
Arnie, I think I misspoke. I want the records that are within a 30 day range. Ronda ... From: Arnie Rowland [mailto:Arnie@...] Sent: Wednesday, December...