Viewing 15 posts - 481 through 495 (of 1,439 total)
Sean Lange (9/28/2012)
September 28, 2012 at 8:19 am
Another one
WITH GrpCounts(ComputerName, ApplicationName,GrpCnt) AS (
SELECT ComputerName, ApplicationName,
COUNT(*) OVER(PARTITION BY ComputerName)
FROM #MyTable),
Results(ComputerNameA,ComputerNameB) AS (
SELECT x.ComputerName , y.ComputerName
FROM GrpCounts x
INNER JOIN GrpCounts y...
September 28, 2012 at 2:58 am
anthony.green (9/27/2012)
If the SPID is <= 50 then no dont kill it,
In my experience, Service Broker internally activated sessions are often on SPIDs less than 50
September 27, 2012 at 9:01 am
The query can be made to handle XML special characters by doing this
SELECT t.id,
STUFF(
(
...
September 26, 2012 at 3:29 pm
Here's a snappy query for you
WITH StartsAndEnds(StartEnd,StartDate,EndDate,HotelId,RoomTypeId) AS (
SELECT 'S' AS StartEnd,
StartDate,
DATEADD(day,-1,StartDate),
...
September 26, 2012 at 3:24 pm
Use the 'nodes' function
DECLARE @t TABLE(xml_data XML)
INSERT INTO @t(xml_data) VALUES('
<Booking Reference= "1111111" Created ="2012-09-24">
<Hotel Name="Villa Bella">
</Hotel>
<Hotel Name="Sea View">
</Hotel>
</Booking>')
SELECT n1.value('@Reference','VARCHAR(10)') AS BReference,
n1.value('@Created','DATE') AS DateCreated,
...
September 26, 2012 at 4:47 am
SELECT ID, NAME
FROM EMP_TBL
INTERSECT
(SELECT '1','foo1'
UNION ALL
SELECT '2','foo2')
September 26, 2012 at 3:57 am
matak (9/26/2012)
September 26, 2012 at 3:47 am
Luis Cazares (9/25/2012)
SELECT SUBSTRING(@s,t2.number,t1.number)
FROM master.dbo.spt_values t1
INNER JOIN master.dbo.spt_values t2 ON t2.type='P' AND t2.number BETWEEN 1 AND...
September 25, 2012 at 8:13 am
Use a numbers table
DECLARE @s-2 VARCHAR(10)
SET @s-2 = 'tapsaw1'
SELECT SUBSTRING(@s,t2.number,t1.number)
FROM master.dbo.spt_values t1
INNER JOIN master.dbo.spt_values t2 ON t2.type='P' AND t2.number BETWEEN 1 AND LEN(@s) - t1.number + 1
WHERE t1.type='P' AND t1.number...
September 25, 2012 at 6:15 am
Just for fun...
Using a lookup table improves performance, a bit suprising (for me at least).
// Pre-calculated sums of 0 to 99
static readonly...
September 25, 2012 at 3:55 am
Try using ROW_NUMBER instead
WITH CTE AS (
SELECT Username, thumbnailPhoto, [Display Name], Department, USERID, email, BADGENUMBER, NAME, CHECKTYPE, CHECKTIME,
ROW_NUMBER() OVER(PARTITION BY USERID ORDER...
September 25, 2012 at 2:43 am
Rather than a trigger, can you change the table so that Full_Name is a calculated column?
September 24, 2012 at 6:50 am
SQL Kiwi (9/24/2012)
Handling NULL and -2147483648 is another good point (though the original test rig can produce neither value, in my defence).
NULL can also be handled by adding 'RETURNS NULL...
September 24, 2012 at 6:39 am
SQL Kiwi (9/21/2012)
Source:
[font="Courier New"] public static int SumDigits(int Input)
{
int sum = 0;
for (int n = System.Math.Abs(Input); n > 0; sum += n % 10,...
September 24, 2012 at 3:35 am
Viewing 15 posts - 481 through 495 (of 1,439 total)