Viewing 15 posts - 16 through 30 (of 40 total)
In splitting string using number table is not this approch simpler?
DECLARE @s-2 VARCHAR(80)='Army,Navy,Air Force,Marines'
;WITH c AS
(SELECT 1 AS n
UNION ALL
SELECT n+1 FROM c WHERE n...
May 20, 2010 at 11:34 am
Thank you,
I use ABS() function for solving the problem.
And put here some solution for splitting string, see:
SET NOCOUNT ON
DECLARE @s-2 VARCHAR(8)='kill,ill'
;WITH c AS
(SELECT 1 AS n
UNION...
May 20, 2010 at 7:56 am
Try this:
INSERT INTO TABLERESULT
SELECT SECTION,
COURSECODE,
MAX(CASE WHEN rec_id = 1 THEN ParameterVALUES END) AS P1,
COALESCE(MAX(CASE WHEN rec_id = 2 THEN ParameterVALUES END), '') AS P2,
COALESCE(MAX(CASE WHEN rec_id = 3 THEN ParameterVALUES...
May 20, 2010 at 6:56 am
Steve Cullen (5/19/2010)
The Database Engine assumes that object_id is in the current database context. A query that references an object_id in another database will return NULL or incorrect...
May 19, 2010 at 1:52 pm
I use database name before the INFORMATION_SCHEM view but when I use the USE statement with another database name my result is incorrect.
I have two database with names "concat" and...
May 19, 2010 at 1:26 pm
ColdCoffee (5/19/2010)
Use DATALENGTH function, This will calculate white spaces at both ends of the string. This might help your cause!
Thanks a lot ColdCoffee! 🙂
I have not used this function yet.
May 19, 2010 at 3:58 am
I fine the mistake!
Assume my string is: DECLARE @s-2 VARCHAR(500) = 'abc '
SELECT LEN(@s) --The result will be 3! not 5! This was my problem
Why SQL Server...
May 19, 2010 at 2:57 am
Dave Ballantyne (5/19/2010)
Or by using a case sensitive collation
SELECT CHARINDEX('x' collate SQL_Latin1_General_CP1_CS_AS, 'X' collate SQL_Latin1_General_CP1_CS_AS) [/cod]
Thanks. It is exactly what I was looking for!
May 19, 2010 at 2:38 am
ColdCoffee (5/19/2010)
LINK : REPLACE Multiple Spaces with One[/url]
Hope this helps...
May 19, 2010 at 2:29 am
But how about this?
SELECT CHARINDEX('X', 'abcdx')
If we want compare just two characters your way is correct. But at this case we cannot do this.
Can I use something like COLATE in...
May 19, 2010 at 2:27 am
I got it! 🙂
select convert(varchar(150),0x202020202020202020202020202020202020202020202020202020202020292020202020202020202020202020202020202020) union all
select convert(varchar(150),0x202020202020202020202020202020202020202020202020202020202020202820202020202020202020202020202020202020) union all
select convert(varchar(150),0x202020202020202020202020202020202028202020202020202020202020282029202020202020202020202020202020202020) union all
select convert(varchar(150),0x202020202020202020202020202020202029202020202020202020202020202220202020202020202020202020202020202020) union all
select convert(varchar(150),0x202020202020202020202020202020202820292020202020202020202020202020202020202020202020202020202020202020) union all
select convert(varchar(150),0x202020202020202020202020202020202022202020207C202020202020202020207C2020202020202020202020202020202020) union all
select convert(varchar(150),0x202020202020202020202020207C20202020202020282820202020202020202020292920202020202020202020202020202020) union all
select convert(varchar(150),0x202020202020207C2020202020292920202020202029292020202920202020202F2F2020202020202020202020202020202020) union all
select convert(varchar(150),0x20202020202020292920202028202920202020202F202F202020282020202028202820202020207C2020202020202020202020) union...
May 18, 2010 at 10:40 pm
Lowell (5/18/2010)
ok, still easy to do...can we assume the query results will be seen in text mode?
Yes.
May 18, 2010 at 10:21 pm
Thanks, but I am looking for a query that generates the result and we cannot to see the result before running it.
May 18, 2010 at 10:16 pm
Gopi Muluka (5/18/2010)
Try this
WITH RecCTE AS
(
SELECT Convert(VarChar(30),i) i FROM T
UNION ALL
SELECT Convert(Varchar(30),t2.i+','+t3.i) as i FROM T T2
CROSS JOIN RecCTE T3
WHERE t2.i<>t3.i AND t2.i<LEFT(t3.i,1)
)
SELECT * FROM RecCTE
ORDER BY LEN(I),i
Thanks. It seems...
May 18, 2010 at 9:40 am
Viewing 15 posts - 16 through 30 (of 40 total)