December 6, 2013 at 2:35 am
i have table house no like this below coloum.........
house_no
3-13-10
3-13-200/a
3-13-450/a
3-13-1345/b
3-13-12
3-13-4
3-13-567/c
3-13-832/a
3-13-943
i want table like this....
3-13-4
3-13-10
3-13-12
3-13-200/a
3-13-450/a
3-13-567/c
3-13-832/a
3-13-943
3-13-1345/b
pl write the quarie..................
December 6, 2013 at 4:42 am
its a cross post
you have already put same question earlier here http://www.sqlservercentral.com/Forums/Topic1511010-3077-4.aspx
December 6, 2013 at 11:51 pm
it shows error like
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value '17-280' to data type int.
December 7, 2013 at 11:00 am
One, reposting on a new thread isn't going to get you different answers.
Two, on your original thread, please post the code you are using. You should also take the time to read the first article I reference below in my signature block. It will walk you through what you need to post and how to post it to get the best possible answer to your question.
December 9, 2013 at 4:13 am
The short answer is that you should re think your database.
From the question it is clear that the field is storing at least three separate entities:
Sector (3-13) - varchar
PropertyID (414) - int
Sub Property ID (/a) - varchar
To do the sorting that you want, you will need to split the value into three, sort by the middle and last columns and then recombine the values. Longer term it would probably be better to store these permanently rather than split and recombine each time.
If you can't change the existing columns, you could possibly add computed columns to the existing table, or create a lookup table with Create, Update and Delete triggers on the existing table. Failing that, a table function would do it, but performance may take a hit, depending on the size of the dataset being processed.
December 15, 2013 at 11:07 am
Each one of your five current threads
select quarie between houseno ..........
select only up to first '-' only
display order by like 1,2,3,4,5...............plz write quarie
relate to the same issue. Help us and you will help yourself. Please provide a sample data set which is properly representative of your data. Your data doesn't all look like "3-9-55". If it did, any one of several solutions already posted would work just fine.
Is "3-9-55" just a Hyderabad house number or is it three data elements combined into one?
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
December 15, 2013 at 7:41 pm
If you have to keep the data this way, maybe can parse the hourse_no, then order by different parts.
SELECT
CAST(SUBSTRING(hourse_no,1,CHARINDEX('-',hourse_no)-1) AS INT),
CAST(SUBSTRING(hourse_no,CHARINDEX('-',hourse_no)+1,2) AS INT),
...
FROM #temp
ORDER BY
CAST(SUBSTRING(hourse_no,1,CHARINDEX('-',hourse_no)-1) AS INT),
CAST(SUBSTRING(hourse_no,CHARINDEX('-',hourse_no)+1,2) AS INT),
...
December 16, 2013 at 12:27 am
ChrisM@home (12/15/2013)
Each one of your five current threadsselect quarie between houseno ..........
select only up to first '-' only
display order by like 1,2,3,4,5...............plz write quarie
relate to the same issue. Help us and you will help yourself. Please provide a sample data set which is properly representative of your data. Your data doesn't all look like "3-9-55". If it did, any one of several solutions already posted would work just fine.
Is "3-9-55" just a Hyderabad house number or is it three data elements combined into one?
:w00t: now these are some threads ....
December 18, 2013 at 2:06 am
twin.devil (12/16/2013)
ChrisM@home (12/15/2013)
Each one of your five current threadsselect quarie between houseno ..........
select only up to first '-' only
display order by like 1,2,3,4,5...............plz write quarie
relate to the same issue. Help us and you will help yourself. Please provide a sample data set which is properly representative of your data. Your data doesn't all look like "3-9-55". If it did, any one of several solutions already posted would work just fine.
Is "3-9-55" just a Hyderabad house number or is it three data elements combined into one?
:w00t: now these are some threads ....
501's, mate. Best in the world ๐
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 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply