Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««1234

display order by like 1,2,3,4,5...............plz write quarie Expand / Collapse
Author
Message
Posted Wednesday, November 6, 2013 9:10 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 5:22 PM
Points: 36,763, Visits: 31,217
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!


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

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1512077
Posted Thursday, November 7, 2013 2:52 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 3:03 PM
Points: 384, Visits: 1,519
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?!

Post #1512461
Posted Thursday, November 7, 2013 5:37 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 9:44 PM
Points: 3,610, Visits: 5,223
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?!



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!
Post #1512501
Posted Friday, December 6, 2013 11:52 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, April 6, 2014 12:03 AM
Points: 30, Visits: 119
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value '17-280' to data type int.
Post #1520790
Posted Saturday, December 7, 2013 12:18 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, April 6, 2014 12:03 AM
Points: 30, Visits: 119
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
Post #1520791
Posted Saturday, December 7, 2013 3:09 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 3:06 PM
Points: 1,074, Visits: 6,364
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
Post #1520805
Posted Saturday, December 7, 2013 6:42 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, April 6, 2014 12:03 AM
Points: 30, Visits: 119
IT SHOWS ERROR

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


Post #1520810
Posted Saturday, December 7, 2013 8:40 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 5:22 PM
Points: 36,763, Visits: 31,217
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1520816
Posted Sunday, December 15, 2013 11:07 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 3:06 PM
Points: 1,074, Visits: 6,364
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
Post #1523054
« Prev Topic | Next Topic »

Add to briefcase «««1234

Permissions Expand / Collapse