Viewing 15 posts - 196 through 210 (of 311 total)
lmu92 (2/23/2010)
Peter Brinkhaus (2/23/2010)
...
SELECT
COUNT(CASE WHEN live = 'Y' AND disab = 'N' THEN 1 END) * 100. / COUNT(*)
FROM
@tbl
WHERE
live <> 'I'
Peter
Excellent job, Peter!!
If I...
February 23, 2010 at 3:32 pm
If the amount of numbers is fixed here's an example of 8 numbers. I doesn't look efficient but given the number of parameters it will do. I have changed the...
February 23, 2010 at 3:00 pm
GSquared (2/23/2010)
Makes sense....
As a second thought, it might be easier to select top 1 and order by the date column.
Makes sense too. But looking at the query plan of the...
February 23, 2010 at 2:32 pm
foscsamuels (2/23/2010)
I tried rewriting the calculation for the percent as (live_eq_y/live_not_i) * 100When I try this it returns zero, but wasn't sure why.
You get zero because all the operands in...
February 23, 2010 at 1:38 pm
GSquared (2/23/2010)
If your datetime column is called MyDate and it's in table MyTable:
select IsNull(MyDate, 0)
from dbo.MyTable;
That will replace the nulls with 0s (datetime 0 = 1 Jan...
February 23, 2010 at 1:18 pm
DECLARE @table TABLE (d date)
INSERT INTO @table
VALUES (GETDATE()), (GETDATE() + 10), (GETDATE() - 50000), (NULL)
SELECT
DATEADD(dd, 0, NULLIF(MIN(COALESCE(DATEDIFF(dd, 0, d), -2147483648)), -2147483648))
FROM
@table
February 23, 2010 at 12:50 pm
REMOVED: false statement
February 19, 2010 at 3:46 am
BTW, the same holds true for the LIKE method
declare @test-2 table(value varchar(50))
insert into @test-2(value) values('a123²³')
select * from @test-2 where value like '%[^''0-9a-Z .,-]%'
select...
February 19, 2010 at 3:36 am
Jeff Moden (2/18/2010)
...
Lowell's code does that correctly.
Well, not exactly. The second version of StripHighAscii (the one with the loop) can give you very odd results depending on the collation being...
February 19, 2010 at 3:26 am
This is what I came up with, but even in this small example, it takes a long time to execute, so I must be doing something silly...
The reason that it's...
February 18, 2010 at 11:13 am
Tim Januario-145496 (2/17/2010)
The difference between DDL and DML results in a Operand data type varchar is invalid for subtract operator exception. Was that a trick question??
Strange.
select difference('DML', 'DDL')
gives...
February 17, 2010 at 6:35 am
select
t1.id, t2.requirement
into
#myTable2
from
#myTable1 t1
cross apply
(
select t1.req1 requirement
union all
select t1.req2
union all
select...
February 16, 2010 at 9:15 am
Ricky Helgesson (2/3/2010)
Peter, you need to check XACT_STATE since -1 means the transaction is Doomed and nothing can be done.
I know, but I was wondering if there is any error...
February 3, 2010 at 7:05 am
bitbucket-25253 (2/3/2010)
Peter Brinkhaus
I tried a new approach, where I started a nested transaction to solve the problem but since SQL Server does not support rollback of inner transactions without...
February 3, 2010 at 6:47 am
I was just looking up the documentation of SAVE TRANSACTION in BOL and now I'm really confused. It gives an example of just what you are trying to do:
USE AdventureWorks;
GO
IF...
February 3, 2010 at 5:36 am
Viewing 15 posts - 196 through 210 (of 311 total)