Viewing 15 posts - 2,146 through 2,160 (of 2,462 total)
I am not recommending that you use this but query, I am posting it for reference. It will produce the same result and it's easier to read & understand.
DECLARE @listStr...
-- Itzik Ben-Gan 2001
August 29, 2013 at 1:05 pm
The correct way to split a string using T-SQL would be to use Jeff's splitter as Louis mentioned. That said, what you are doing is quite simple; you could do...
-- Itzik Ben-Gan 2001
August 29, 2013 at 12:31 pm
Also,
I'd get rid of those NOLOCK table hints. NOLOCK (READ UNCOMMITTED) is for when you don't care if you always get the right answer. Here's a good article about that:
-- Itzik Ben-Gan 2001
August 29, 2013 at 11:57 am
The error you are getting is true: GROUP BY/HAVING,etc are not allowed in the recursive part of a CTE. It does not look like you are trying to do a...
-- Itzik Ben-Gan 2001
August 29, 2013 at 11:50 am
Something like this perhaps...
-- your data
DECLARE @Report1 TABLE (contract varchar(20), A int, E int, N int, P int);
INSERT @Report1
SELECT 'Income', 5000, 6000, 8000, 4000 UNION
SELECT 'Costs', 4000, 7000,...
-- Itzik Ben-Gan 2001
August 28, 2013 at 3:59 pm
If you can use CLRs you could look at mdq.regexmatches. See this thread.
-- Itzik Ben-Gan 2001
August 22, 2013 at 4:43 pm
opc.three (8/19/2013)
DECLARE @sql NVARCHAR(MAX) = N'';
SELECT @sql += 'EXEC LoadFile ' + QUOTENAME(FILENAME, '''')...
-- Itzik Ben-Gan 2001
August 20, 2013 at 3:55 pm
Thanks Luis!
-- Itzik Ben-Gan 2001
August 15, 2013 at 3:28 pm
-- (1) Source Data
DECLARE @nbrs TABLE (n int primary key);
INSERT @nbrs VALUES (10),(20),(30),(40),(50);
-- (2) Solution
WITH
s1 AS (SELECT ROW_NUMBER() OVER (ORDER BY n) AS rn,n FROM @nbrs),
s2 AS (SELECT rn-1...
-- Itzik Ben-Gan 2001
August 15, 2013 at 12:19 pm
First, I second both responses to your question. I actually have a couple versions of SQL server installed on my machine: 2008R2 Developer Edition & SQL Server 2012 Express. Developer...
-- Itzik Ben-Gan 2001
August 14, 2013 at 2:47 pm
I have run into the exact same type of thing...
/bangs head.
This is the cause of my receding hairline. :hehe:
-- Itzik Ben-Gan 2001
August 13, 2013 at 1:29 pm
the source data is coming from a database in the UK and the values sometimes contain non alpha-numeric characters. i'm probably wrong, but i'm wondering if some of these characters...
-- Itzik Ben-Gan 2001
August 13, 2013 at 12:50 pm
Shot in the dark here but, are you using a case sensitive collation?
-- Itzik Ben-Gan 2001
August 13, 2013 at 11:24 am
learning_sql (8/13/2013)
However I have just been playing around and when just typing the query it worked every time, I have...
-- Itzik Ben-Gan 2001
August 13, 2013 at 7:11 am
dwain.c (8/12/2013)
Alan.B (8/12/2013)
Instead of the case statement you can also do this:
SELECT ISNULL(thing1.name,(ISNULL(thing2.name,thing3.name))) AS nameAnd why not:
SELECT COALESCE(thing1.name,thing2.name,thing3.name) AS name
?
Nice. That is cleaner and easier to read.
+1
-- Itzik Ben-Gan 2001
August 12, 2013 at 7:15 pm
Viewing 15 posts - 2,146 through 2,160 (of 2,462 total)