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


display order by like 1,2,3,4,5...............plz write quarie


display order by like 1,2,3,4,5...............plz write quarie

Author
Message
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)

Group: General Forum Members
Points: 218476 Visits: 41996
dwain.c (11/6/2013)
Based on cursory review of the information surrounding the quote, I'm in a position of "initial reluctance to agree."

I'm thinking that part of that 97% he talks about should be addressed if it can be done without significant overhead to getting the code written and tested.

Need to take a deep dive to see if my initial position holds fast.

Then again, who am I to disagree with the distinguished Dr. Knuth! :-P


I don't disagree with Knuth at all. I do disagree with what many people have erroneously come to believe that he means. If you read the preceding paragraphs from the right column of the preceding page through the text up to the "evil" statement, you'll see why I get so ticked when someone uses the "evil" statement to justify poor design including but not limited to the use of RBAR for small numbers of rows or one-off jobs and using the wrong data-types in the initial design of tables.

Yes, Knuth states that it's a waste of time to spend time to "optimize" one-off jobs and I mostly agree with that. But if you already know a way to have the code run faster and it takes no extra dev time to do so, why would anyone intentionally write it using a slower, "less optimal" method?

That's a subject that I don't believe Knuth spent enough time on... learning and practicing the optimal methods so that they become second nature so that they don't actually take any extra time to incorporate in areas that are known to be troublesome insofar as performance goes. To wit, that's not "premature optimization" in my book. That's knowing the trade and understanding known design problems.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
sqldriver
sqldriver
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2236 Visits: 2536
dwain.c (11/4/2013)
Jeff Moden (11/4/2013)
dwain.c (11/4/2013)
Jeff Moden (11/4/2013)
shashianireddy (11/4/2013)
sql 2008 version ,,nvarchar(MAX)


You're using NVARCHAR(MAX) for a housenumber???? In SQL Server 2008???? Why?????

You probably don't release it but you cannot rebuild a clustered index in an Online fashion in SQL Server 2008 if the table contains a blob. This is a totally unneccessary blob.

Yes, yes... I know... all of your character based columns are NVARCHAR(MAX) because someone believes that "Premature optimization is the root of all evil." The problem is no one ever considers such things as what I've just mentioned and even fewer go back and optimize when they're supposed to.

I strongly recommend that someone go fix that table to have the correctly sized datatypes.


Glad to see I'm not the only one that felt that way. Although your feelings seem a bit stronger on the subject. Probably because you're not seeing such nonsense as frequently as I do.


The reason why I don't see such nonsense that often is because I've trained my Developers. I would never allow such a table design to even go into Dev never mind Prod. This is the kind of garbage that some of the automatic front-end designer software does. What really kills me is that one of the products that does it is Microsoft software.

I'm all for the avoidance of prematue optimization but any system or human that creates all NVARCHAR(MAX) or even all NVARCHAR(4000) for all character based columns in a table is way over the top so far as I'm concerned.


Sounds like you have the luxury of an orderly, controlled shop. Congratulations for exercising such strict controls (and being able to)!


I don't use any VARCHAR columns; they're all NVARCHAR, though I do control their sizes in increments of 64 to keep data from being truncated.

I've gotten some feedback that this is inappropriate, but I receive dozens and dozens of Excel files a week that I have to import and make sense of (no control over their generation). Going back to correct Unicode or UTF characters showing up as question marks in VARCHAR columns would put me on Queasy Street. Especially if they make it to a live server.

Since taking advice from a Kevin Boles talk and querying them with N'' I've noticed a definite improvement in performance, but since this looks like a lively talk on the subject...

Am I doing it wrong?! Blush
dwain.c
dwain.c
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18123 Visits: 6431
erikd (11/7/2013)
I don't use any VARCHAR columns; they're all NVARCHAR, though I do control their sizes in increments of 64 to keep data from being truncated.

I've gotten some feedback that this is inappropriate, but I receive dozens and dozens of Excel files a week that I have to import and make sense of (no control over their generation). Going back to correct Unicode or UTF characters showing up as question marks in VARCHAR columns would put me on Queasy Street. Especially if they make it to a live server.

Since taking advice from a Kevin Boles talk and querying them with N'' I've noticed a definite improvement in performance, but since this looks like a lively talk on the subject...

Am I doing it wrong?! Blush



I personally believe in typing columns to what they need to be, so understanding the underlying data is quite important. Of course, when your data is coming in uncontrolled, like through Excel, it is usually better to be safe than sorry.


My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!

My thought question: Have you ever been told that your query runs too fast?

My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.


Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Learn to understand recursive CTEs by example.
Splitting strings based on patterns can be fast!
My temporal SQL musings: Calendar Tables, an Easter SQL, Time Slots and Self-maintaining, Contiguous Effective Dates in Temporal Tables
shashianireddy
shashianireddy
SSC Veteran
SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)

Group: General Forum Members
Points: 250 Visits: 135
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value '17-280' to data type int.
shashianireddy
shashianireddy
SSC Veteran
SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)

Group: General Forum Members
Points: 250 Visits: 135
the first method is ok but ..... it works only if housenumber is integer only ...
it shows error when housenumber mixed wit varchar .............



plz write the code if housenumber is varchar
ChrisM@home
ChrisM@home
SSCertifiable
SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)

Group: General Forum Members
Points: 5300 Visits: 10608
shashianireddy (12/7/2013)
the first method is ok but ..... it works only if housenumber is integer only ...
it shows error when housenumber mixed wit varchar .............



plz write the code if housenumber is varchar


Please respond to Jeff's earlier post here. He's provided a solution which works well for your given sample data. If it fails with other patterns of house number, then include them in your sample. There's no single algorithm which will work for this.


Low-hanging fruit picker and defender of the moggies





For better assistance in answering your questions, please read this.




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
shashianireddy
shashianireddy
SSC Veteran
SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)SSC Veteran (250 reputation)

Group: General Forum Members
Points: 250 Visits: 135
IT SHOWS ERROR

Conversion failed when converting the varchar value '1867 C' to data type int
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)

Group: General Forum Members
Points: 218476 Visits: 41996
shashianireddy (12/7/2013)
IT SHOWS ERROR

Conversion failed when converting the varchar value '1867 C' to data type int


There's been a lot of code and suggestions on this thread. Please post the readily consumable data and the code that you're currently using that produces this error.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
ChrisM@home
ChrisM@home
SSCertifiable
SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)

Group: General Forum Members
Points: 5300 Visits: 10608
Each one of your five current threads

select quarie between houseno ..........
select house_no order
select only up to first '-' only
display order by like 1,2,3,4,5...............plz write quarie
display order by houseno

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?


Low-hanging fruit picker and defender of the moggies





For better assistance in answering your questions, please read this.




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
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