November 28, 2011 at 3:43 am
CREATE TABLE #desc
( NAME VARCHAR(100))
INSERT INTO #desc
SELECT 'Balanço - Activo não corrente' UNION ALL
SELECT 'Balanço - Autonomia Financeira' UNION ALL
SELECT 'Balanço ANO'
SELECT * FROM #desc ORDER BY NAME
DROP TABLE #desc
Can same one explain to me why I’m a gating this output
Balanço - Activo não corrente
Balanço ANO
Balanço - Autonomia Financeira
Instead of:
Balanço - Activo não corrente
Balanço - Autonomia Financeira
Balanço ANO
I’m executing this script in:
Microsoft SQL Server 2008 (SP2) - 10.0.4285.0 (X64)
Thanks
November 28, 2011 at 3:48 am
Please check your Server’s collation.
SQL Server Collation Fundamentals
http://msdn.microsoft.com/en-us/library/aa174903(v=SQL.80).aspx
November 28, 2011 at 3:53 am
Character position 9 of two of your strings is a hyphen. There are ways to get around this, for instance you could remove the hyphen and a white space using REPLACE.
Changing the collation won't put an alpha between two hyphens:-P
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 28, 2011 at 4:01 am
DROP TABLE #desc
CREATE TABLE #desc
( NAME VARCHAR(100))
INSERT INTO #desc
SELECT 'Balanço- Activo não corrente' UNION ALL -- note changed position of hyphen
SELECT 'Balanço - Autonomia Financeira' UNION ALL
SELECT 'Balanço ANO'
SELECT
NAME,
REPLACE(REPLACE(Name,'- ',' '),' ',' ')
FROM #desc ORDER BY REPLACE(REPLACE(Name,'- ',' '),' ',' ')
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 28, 2011 at 4:03 am
Balanço - Activo não corrente -- 1
Balanço ANO -- 2
Balanço - Autonomia Financeira -- 3
I didn't check the character position but based on you comment, it should appear in this order...
Either
1/3
3/1
2
OR
2
1/3
3/1
November 28, 2011 at 10:25 am
There is a slight problem in the third Select statement you have to put 2 spaces between Balanço and ANO
SELECT 'Balanço[space][space]ANO'
CREATE TABLE #desc
( NAME VARCHAR(100))
INSERT INTO #desc
SELECT 'Balanco - Activo nao corrente' UNION ALL
SELECT 'Balanco - Autonomia Financeira' UNION ALL
SELECT 'Balanco ANO'
SELECT * FROM #desc ORDER BY NAME
DROP TABLE #desc
November 28, 2011 at 10:30 am
Jorge Lopes (11/28/2011)
There is a slight problem in the third Select statement you have to put 2 spaces between Balanço and ANOSELECT 'Balanço[space][space]ANO'
CREATE TABLE #desc
( NAME VARCHAR(100))
INSERT INTO #desc
SELECT 'Balanco - Activo nao corrente' UNION ALL
SELECT 'Balanco - Autonomia Financeira' UNION ALL
SELECT 'Balanco ANO'
SELECT * FROM #desc ORDER BY NAME
DROP TABLE #desc
It had to be that or a space missing on one of the other two rows. Have you tried using REPLACE() yet?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply