Viewing 15 posts - 751 through 765 (of 1,439 total)
See if this helps
DECLARE @x XML
SET @x=NULL
SELECT @x.exist('/*')
SET @x=''
SELECT @x.exist('/*')
SET @x='<Root/>'
SELECT @x.exist('/*')
August 2, 2011 at 2:12 am
If you mean this
SELECT NCHAR(8486)
you'll need to use an NVARCHAR or NCHAR column
July 21, 2011 at 4:11 am
Here's another way
WITH CTE AS (
SELECT Name,Date,Trend,Strength,
ROW_NUMBER() OVER(PARTITION BY Name ORDER BY Date) -
ROW_NUMBER() OVER(PARTITION BY Name,Trend,Strength ORDER BY Date) AS rnDiff
FROM @tbl)
SELECT Name,MIN(Date) AS Date,Trend,Strength
FROM CTE
GROUP BY...
July 20, 2011 at 7:39 am
Not entirely sure if it's a bug or not, but I think it's to do with the expansion of [A-Z]. If you change it to [ABCDEFGHIJKLMNOPQRSTUVWXYZ] it works correctly.
July 20, 2011 at 4:53 am
Jeff Moden (7/18/2011)
Mark-101232 (7/18/2011)
Have a look herehttp://databases.aspfaq.com/database/what-naming-convention-should-i-use-in-my-database.html
It's just me, I know, but I name my tables after what a single row of any given table contains. Part of the...
July 18, 2011 at 7:19 am
Have a look here
http://databases.aspfaq.com/database/what-naming-convention-should-i-use-in-my-database.html
and just for fun...
July 18, 2011 at 4:37 am
SELECT Place_ID,
SUM(CASE WHEN ReceivedDate - GETDATE() >'1899-12-31' THEN 1 ELSE 0 END) AS 'AllAvai',
SUM(CASE WHEN ReceivedDate...
July 18, 2011 at 4:16 am
SELECT DISTINCT a.Cust
FROM dbo.TT a
WHERE NOT EXISTS (SELECT * FROM dbo.TT b WHERE b.Cust=a.Cust AND b.Item=15)
ORDER BY a.Cust;
July 18, 2011 at 3:48 am
ORDER BY CASE WHEN CITYNAME='Bangalore' THEN 0 ELSE 1 END,CITYNAME
July 15, 2011 at 4:40 am
DECLARE @xml_result XML;
WITH XMLNAMESPACES('http://www.w3.org/2001/XMLSchema-instance' AS xsi,
'http://www.w3.org/2001/XMLSchema' AS xsd,
'ns0:cape_site' AS ns1),
OrderedData AS (
SELECT jc.WBSNumber,
jst.EquipmentNo,
SUM(jst.Qty) as Qty,
ROW_NUMBER() OVER(PARTITION BY jc.WBSNumber ORDER BY jst.EquipmentNo) AS rn
FROM...
July 14, 2011 at 2:05 am
Something like this?
DECLARE @T TABLE(Asset CHAR(1),PeriodYear INT)
INSERT INTO @T(Asset,PeriodYear)
SELECT 'A',2009 UNION ALL
SELECT 'A',2009 UNION ALL
SELECT 'B',2010 UNION ALL
SELECT 'C',2009 UNION ALL
SELECT 'C',2010 UNION ALL
SELECT 'C',2010;
SELECT Asset,
...
July 13, 2011 at 7:41 am
Second attempt, sort of 'relational division', should be quicker than the first
WITH Employees(Employee,ModeOfTransport) AS (
SELECT 'Employee1' , 'Car'
UNION ALL
SELECT 'Employee1', 'Bus'
UNION ALL
SELECT 'Employee1', 'Train'
UNION ALL
SELECT 'Employee2', 'Car'
UNION ALL
SELECT 'Employee2',...
July 13, 2011 at 4:11 am
ALZDBA (7/13/2011)
Very nice solution Mark. :smooooth:I hope OP understands the performance impact.
Yep, I suspect there's a fast way to do this without having to group by a concatenated string. Can't...
July 13, 2011 at 3:13 am
Try this
WITH Employees(Employee,ModeOfTransport) AS (
SELECT 'Employee1' , 'Car'
UNION ALL
SELECT 'Employee1', 'Bus'
UNION ALL
SELECT 'Employee1', 'Train'
UNION ALL
SELECT 'Employee2', 'Car'
UNION ALL
SELECT 'Employee2', 'Bus'
UNION ALL
SELECT 'Employee3', 'Train'
UNION ALL
SELECT 'Employee4', 'Car'
UNION ALL
SELECT 'Employee4', 'Bus'
UNION ALL
SELECT...
July 13, 2011 at 3:02 am
As far as I know, the only workaround is to convert the XML to the varchar(max) type and then prepend the header
SELECT '<?xml version="1.0" encoding="ISO-8859-1" ?>'
+
CAST( (SELECT ... FOR...
July 12, 2011 at 10:03 am
Viewing 15 posts - 751 through 765 (of 1,439 total)