Viewing 15 posts - 4,501 through 4,515 (of 5,504 total)
It works with even Edit: odd numbers as well...
You'd just have the most right bit set to 1 as well (2^0=1). Basically starting your "Power table" with 0 instead of...
January 14, 2010 at 12:23 am
I'm still trying to figure out why it works, but it works.
Let's see what I can do...
Using your example, 46(base10) can be written as 101110(base2). Agreed?
Let's start with...
January 13, 2010 at 2:24 pm
GSquared (1/13/2010)
January 13, 2010 at 2:04 pm
You're very welcome, Greg!
The FOR XML PATH clause is available since 2K5.
I tried to explain how it works here . Not sure if it helps to understand though...
Regarding "&":...
January 13, 2010 at 1:39 pm
@Gus (again): Another thought:
If you'd add AND (@Sum & power(2, Number)) > 0
to your WHERE clause in the Rules CTE you'd get rid of the repetitive Col1=@Col1 part...
January 13, 2010 at 1:23 pm
@Gus:
Just as a side note: AFAIK varchar(max) columns tend to have a bad influence on performance due to the handling of more than one page (8k).
I guess, varchar(8000) will do...
January 13, 2010 at 1:16 pm
Lowell (1/13/2010)
a name like Mac Bride/Bob Lee would make that happen... you'll need to tweak it...
January 13, 2010 at 12:57 pm
I would use a function to get the "binary pattern". Something like the following:
CREATE FUNCTION tvf_binarySplit(@a int)
returns TABLE
as
RETURN
SELECT (@a & power(2,n)) val
FROM
(SELECT 1 AS n UNION ALL...
January 13, 2010 at 12:42 pm
Here's the solution I'd use as a complete test scenario. (Please note how I defined the sample data in a ready to use format). Also, this is a 2005 solution...
January 13, 2010 at 10:31 am
glen.wass (1/13/2010)
Never used stuff beforewhats the FOR XML bit used for? as i constantly get a syntax error saying incorrect syntax near xml
What SQL Server version do you...
January 13, 2010 at 9:55 am
tkacyndra (1/13/2010)
my table, for example, has the following fields:
id (self incrementing key field)
name
address
phone
date_modified (has a...
January 13, 2010 at 9:44 am
Please have a look at the TallyTable article linked in my signature. It describes a pretty fast method to split a string.
January 13, 2010 at 6:34 am
Would you mind sharing how you'll do it?
One reason is to provide a solution for someone having the same isse.
The second reason: there might be better/faster/cleaner solutions out there but...
January 13, 2010 at 4:07 am
I have no idea how to program it using a loop. But a set based solution could look like the following (and is usually a lot faster....)
SELECT
STAFF_ID,
stuff(( SELECT ',...
January 13, 2010 at 4:04 am
I'll second Johns question regarding more details.
Please provide table definition together with sample data and expected result.
Some of us like to provide tested solutions. So you'll increase the number of...
January 13, 2010 at 1:02 am
Viewing 15 posts - 4,501 through 4,515 (of 5,504 total)