SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


In select query values with space appended takes higher precedence than normal characters


In select query values with space appended takes higher precedence than normal characters

Author
Message
nazmunnisa_g
nazmunnisa_g
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 2
In select query values with space appended takes higher precedence than normal characters . How to overcome this . I.e the result is like this as shown below but i want 1001 to come on the top. Since i am using union all cannot use order by.
Cost Evaluation Sheet
Decision Gate 1 Complete
Involvement Complete
Statement of Work
1001
kevriley
kevriley
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3118 Visits: 2618
Why can't you use ORDER BY?

try this


declare @items1 table (item varchar(100))
declare @items2 table (item varchar(100))

insert into @items1
select 'Cost Evaluation Sheet'
union select 'Decision Gate 1 Complete'
union select 'Involvement Complete'
union select 'Statement of Work'

insert into @items2
select 1001


select item from @items1
union all
select item from @items2
order by item



returns


1001
Cost Evaluation Sheet
Decision Gate 1 Complete
Involvement Complete
Statement of Work


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search