Viewing 15 posts - 1,306 through 1,320 (of 1,492 total)
How about:
SELECT *
FROM YourTable
ORDER BY
CASE Code
WHEN 1 THEN 10000 -- larger than MAX(ACCT)
ELSE Acct
END
,Amount DESC
February 9, 2007 at 10:58 am
How about:
SELECT [ID]
,COUNT(CASE WHEN Value BETWEEN 0 AND 9 THEN 1 END) AS [0_9]
,COUNT(CASE
February 9, 2007 at 10:21 am
Maybe something like the following will work:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("""c:\program files\internet explorer\iexplore.exe"" http://www.yahoo.com")
February 9, 2007 at 8:20 am
Sorry if I seemed a little hard, but I have seen code like this cause too many problems.
On the question of the results, it is difficult for anyone to comment...
February 9, 2007 at 5:54 am
This is NOT the best approach to take for this type of problem. It is best to use a set based approach with the data either being cleansed first or...
February 8, 2007 at 11:06 am
If possible, change the dates and times to use datetime.
Also, how are you going to define a month? For days, hours and minutes the following should work:
SELECT D.MiDiff/1440 AS...
February 8, 2007 at 9:18 am
Try casting the column to varchar(n) and then back to nvarchar(n) and seeing if it is the same.
SELECT YourNVarCharColumn
FROM YourTable
WHERE YourNVarCharColumn <>
CAST(CAST(YourNVarCharColumn as varchar(<collength>
February 8, 2007 at 4:48 am
Your example output does not seem to make much sense. You may want something along the lines of:
-- *** Start of test data ***
DECLARE @t TABLE
(
UserID int NOT NULL PRIMARY...
February 6, 2007 at 10:16 am
Is this what you want?
WHERE 1 =
CASE
WHEN NULLIF(NEWREQDATE, '00000000') IS NULL AND NULLIF(ORIGREQDATE, '00000000') IS NULL
THEN 0
WHEN NULLIF(NEWREQDATE, '00000000') IS NULL
AND DATEDIFF(d, CAST(ORIGREQDATE AS datetime), GETDATE()) > 1
THEN 1
WHEN NULLIF(NEWREQDATE,...
February 6, 2007 at 9:17 am
Your second SP still uses a pseudo cursor.
You should really look at writing set based code. To do this one needs to know the DDL (CREATE TABLE with PKs and...
February 6, 2007 at 3:40 am
Something else you could try is explicitly specifying the type of join.
When there are more than 3 or 4 tables in a query I have noticed that the optimizer works...
February 5, 2007 at 9:56 am
I doubt if you need to use a cursor for this. Why not just do a batch insert of everything in the correct order with the INSERT queries getting rid...
February 5, 2007 at 9:32 am
P.S. I did my guess conversion using the WHERE clause on the following basis:
1. moving the INNER JOINs to the top. (The only INNER JOIN was there already.)
2. converting all...
February 5, 2007 at 6:23 am
It has been some time since I have converted outer joins from old style to new style format, however there are generally two points to bear in mind:
1. With the...
February 5, 2007 at 5:19 am
You need to SUM the CatchNumber. Something like the following should work:
SELECT A.ShipName, A.FishingDate, A.FishingLocation, D.Jack, D.Rose
FROM TABLE1 A
JOIN (
SELECT B.ShipName
,B.FishingDate
,SUM(CASE B.FishSpecies WHEN 'Jack' THEN CatchNumber END) AS Jack
,SUM(CASE B.FishSpecies...
February 1, 2007 at 2:48 am
Viewing 15 posts - 1,306 through 1,320 (of 1,492 total)