Order By Ignoring The Hyphen Character

Sep 24, 2007

Hi,
I'm using the following SQL script to return a list of part number and the order is not what I expect. Perhaps this is a collation problem but I have no idea where to look to modify that.

Thanks in advance, John
select part from transactions T where (T.transdate between '20070701' and '20070705') and
(T.transtype = 'ISSU' or T.transtype = 'RTRN') order by part


Here is the beginning of the Transactions table create script


CREATE TABLE [Transactions] (
[RecNo] [int] IDENTITY (1,1) NOT NULL,
[Part] [nvarchar] (30) NOT NULL ,
[TransDate] [nvarchar] (8) NOT NULL ,
[TransType] [nvarchar] (4) NOT NULL ,
[FromLoc] [nvarchar] (10) ,


The 'Part' column is an alphanumeric field. The problem I am having is that the
Order By seems to ignore the hyphen character '-' when the returned rows
are ordered by the Part (which can contain hyphens in any column).

Here is an example of what I get.

130909N9
130909N9
130909N9
1-480698-0 * These two should not be here
1-480699-0 *
15-423
164-07700
164-07700
164-07700
1683


I was expecting this ( and I get this in and older database ).

068-03000
068-03000
06A19956
074-03200
077-367-0
08DU08
1-480698-0 * These should be here eariler in the data
1-480699-0
100-364072
100-364072

View 3 Replies


ADVERTISEMENT

Views Ignoring Order By Clause

Sep 7, 2007

I have just transferred my site to a new server with SBS R2 Premium, so the site's database changed from SQL 2000 to SQL 2005.   I find that searches are now returning results in random order, even though they use a view with an Order By clause to force the order I want.
I find that the results are unordered when I test the view with Management Studio, so the issue is unrelated to my VB/ASP Net code.
Using my SQL update tool (SQL Compare, from Redgate) I find that there are no differences in the views, or the underlying tables.
Using Management Studio to test a number of views, I find that I have a general problem with all views.  For example, one of the simpler views is simply a selection of fields from one table, with an Order By clause on the tables primary key: -       SELECT     TOP (100) PERCENT GDQid, GDQUser, GDQGED, GDQOption, gdqTotalLines, GDQTotalIndi, GDQRestart, GDQCheckpointMessage,                             GDQStarted, GDQFinished, gdqCheckpointRecordCountr       FROM         dbo.GEDQueue       ORDER BY GDQid DESC
If I right-click the view (from Management Studio's Object Explorer pane), select Design from the menu to show the view's design, and then click the Execute SQL icon, the view's results are displayed perfectly, in descending order of GDQid.  However, if I select "Open View" the view's results are displayed out of order.
When I do this with the SQL 2000 database, both Design/Execute and Open View correctly display the data in the correct order.
Is there something that I should check in the SQL 2005 installation - some option that has been set incorrectly?
Regards, Robert Barnes

View 16 Replies View Related

View Ignoring Order By - Used To Work In Sql 2000

Dec 13, 2005

This works fine in  SQL 2000, but not in SQL 2005

View 12 Replies View Related

Order By On Character Field

Jun 11, 2001

Does ORDER BY work on character data type in SQL Server through ODBC?
I tried using the SQL Query Tool in SQL Enterprise Manager and it works but using through ODBC I can't get any results.

Query: SELECT company_id, company_name FROM lt_company ORDER BY company_name

company_id = integer
company_name = 30 characters

View 1 Replies View Related

ORDER BY, Only Orders By The First Character?

Feb 22, 2007

Hi,

I am using a stored procedure that is databound to a dropdownlist. The stored procedure works fine, aside from the fact that the ORDER BY only sorts the list of items using the first character in the cell. E.g. The numbers 1, 20, 100 and 200 would be ordered as follows:

1

100

20

200

clearly i am doing something wrong and i apologise if it is a stupid question, but could anyone please offer me some help?



Thank you,



Shep

View 11 Replies View Related

Order By Turkish Character Problem

Sep 27, 2007

i want to order by name coloumn.but if i do that ordering is (A,B,C,D,E,F......X,Y,Z,İ,Ş,Ğ,Ü). i want to order these letters at place of turkish alphebetical order.how can i do that? i'm sorry for my english.

View 2 Replies View Related

Character Set,Sort Order & Unicode Collation

Nov 7, 2000

Hi Everybody,

Can anyone tell me apart from "sp_helpsort" system stored procedure, is there any other command to find details of Character Set,Sort Order & Unicode Collation?.

thanks,
Vasu

View 2 Replies View Related

About Character Set And Sort Order Involved In Upgrade SQL 6.5 To 7.0

Jun 13, 1999

i have 2 questions,

1. cause there is no record of my old SQL 6.5 installation leaft for me,so i try to find the character set and sort order of my old SQL 6.5 installation, and in the MSSQLlog directory the errlog.? file there are these lines:

99/06/11 12:59:24.29 spid1 SQL Server's default sort order is:
99/06/11 12:59:24.29 spid1 'nocase' (ID = 52)
99/06/11 12:59:24.29 spid1 on top of default character set:
99/06/11 12:59:24.29 spid1 'iso_1' (ID = 1)

so my old installation's character set and sort order is as above,am i right?

2. cause i am in chinese so any good idea for me to upgrade this old SQL 6.5 to use chinese character set (cp936) , is there anyway to transfer the old data?

thanks if any suggestions!
welcome to send me mail about the question.

View 1 Replies View Related

SQL 'Hyphen' Problem...

Aug 24, 2001

I am new to SQL.

But here is my question. I have a column 'name' and contents are like
A-B, C-D, E-F

When I query DB using, SQL

select * from tbl_Names
where name='C-D'

it does not display anything...
What am I doing wrong?

View 1 Replies View Related

SQLServer Name With Hyphen

Dec 30, 1999

Does anybody knows a workaround to register SQLServer with the name which contains hyphen('-') character in it? I work for multi-national company & they have naming standard for NT servers & this server has hyphen in it.
Also site server guru here thinks that server name change option is not feasible. Please help.

View 1 Replies View Related

Using A Hyphen In SQL Server Name

Oct 14, 2003

We are about to name a new SQL Server and was wondering if anybody has any documentation/knowledge that states one should avaoid using hyphens when naming Servers, objects, etc in SQL.

I have always heard its bad practise, but have not found any solid documentation. For example, I know that the 'connect to' statement does not like hyphens, but what about a SQL Server name on the network ?

Thanks

View 2 Replies View Related

Creating A Job With A Database That Has Hyphen

Jun 22, 2004

Hi,

1- I have given a dbo permission on a database named F12345-1, now I want to create a job on that server using this database.

2- I tried to create the first step in the new job but I don’t see my database name on the databases drop down menu (I only see the system databases)

3- I tried being under Master and using the USE sql command (Ex: Use F12345-1) at the beginning of my step but I get a message saying that the database F12345 doesn’t exist (The message doesn’t say the whole database name only the part before the hyphen)

4- I tried putting quotes around the database name with no luck, although that worked in SQL Query Analyzer but the Job didn’t like it.

Can you please help with this, knowing that I have no control on the database name (In order to remove the hyphen from the name which I am assuming is the cause of this problem)

Thanks

View 3 Replies View Related

Know Of Any SQL Function That Would Chop-off The Hyphen From The Zipcode??

Dec 14, 2006

Anyone know what's the MS-SQL function that look at the zipcode like "30296-6912" and chop off the "-6912" suffix by just looking at the hyphen part?

Thanks...

View 6 Replies View Related

Inserting A Hyphen (-) Into The 3rd Position Of A Nvarchar Field

Sep 13, 2004

I have a colum of numbers, which datatype is nvarchar;

157853
4389
1999999999556
4568987

I need to insert a hyphen, 3 spaces from the right (to left) My numbers would look like this:

157-853
4-389
1999999999-556
4568-987

...do I use the rtrim function ?...what would the syntax look like ?

Thank you

View 3 Replies View Related

Replication Fails When Table Name Has Single Hyphen

Dec 7, 2006

Hey,

I have SQL Server 2000 DB that was converted via DTS from Acccess 97. Replication fails for any table with a single hypen in the table name. If I copy one of these tables to a name using an underscore rather than a hyphen, then it replicates successfully.

Below are errror messags from agent with -Outputverboselevel set to 2. I have also seen 'Agent error code 20082', in which case the replication command is incomplete.

Any ideas?

Thanks,

Bill Coulter



[12/7/2006 1:22:40 PM]172.23.150.51.engdata: {CALL sp_MSupd_br1-16 (NULL,?,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,?,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,?,0x0200020000)}
Parameterized values for above command(s): {{N'00000000001010000100', N'000000000000000000', N'730535L1205C'}}
Agent message code 20046. Syntax error or access violation
[12/7/2006 1:22:40 PM]OUSBID02.distribution: {call sp_MSadd_distribution_history(57, 6, ?, ?, 27, 27, 2.32, 0x01, 1, ?, 1, 0x00, 0x01)}
Adding alert to msdb..sysreplicationalerts: ErrorId = 18,
Transaction Seqno = 0000108b000028f2000400000000, Command ID = 1
Message: Replication-Replication Distribution Subsystem: agent OUSBID02-engdata-172.23.150.51-57 failed. Syntax error or access violation[12/7/2006 1:22:40 PM]OUSBID02.distribution: {call sp_MSadd_repl_alert(3, 57, 18, 14151, ?, 1, N'OUSBID02', N'engdata', N'172.23.150.51', N'engdata', ?)}
ErrorId = 18, SourceTypeId = 1
ErrorCode = ''
ErrorText = '{CALL sp_MSupd_br1-16 (NULL,N'00000000001010000100',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,N'000000000000000000',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,N'730535L1205C',0x0200020000)} '
[12/7/2006 1:22:40 PM]OUSBID02.distribution: {call sp_MSadd_repl_error(18, 0, 1, ?, N'', ?)}

Category:COMMAND
Source: Failed Command
Number:
Message: {CALL sp_MSupd_br1-16 (NULL,N'00000000001010000100',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,N'000000000000000000',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,N'730535L1205C',0x0200020000)}
ErrorId = 18, SourceTypeId = 4
ErrorCode = '37000'
ErrorText = 'Syntax error or access violation'
[12/7/2006 1:22:40 PM]OUSBID02.distribution: {call sp_MSadd_repl_error(18, 0, 4, ?, N'37000', ?)}

Category:ODBC
Source: xxx.xx.xx.xx
Number: 37000
Message: Syntax error or access violation

View 8 Replies View Related

SQL Server 2012 :: Hyphen Delimited String Manipulation

Oct 19, 2015

I am having a field 'Flight Route that holds hyphen delimited character sequences.

E.g. : ABC-BCD-DEF-EFG.

My requirement is like this:

If the flight route is:

ABC-BCD-BCD-DEF make it ABC-BCD-DEF
ABC-ABC-BCD-DEF make it ABC-BCD-DEF

i.e. 'whenever a sequence repeats,only one appearance of that sequence should be displayed.The field Flight Route has to be updated with this replaced string.

View 6 Replies View Related

Problem With Hyphen In Full Text Catalog Search

Jul 23, 2005

Hi All,we have a problem with the Full Text Catalog Search.We use the following SQL Statement for matching companies from a table:select company, lastname, firstname, pkcustomers, fkcustomers,location, title, fkFunktionen, TypeOfPositionfrom customerswhere (fkcustomers = 0 or fkcustomers is null)and active = 1and pkCustomers in (select [KEY] from CONTAINSTABLE(Customers, Company,'"*SEARCHTERMS*"'))order by company ascThe search so far is working perfect.Now the problem: There are two companies in the table called "i-fabrik"and "b-wise". There´s no way to find these two companies. I find outthat the search is successful if there are more than three letters infront of the hyphen (for exampe iii-fabrik or bbb-wise). How can thatbe? Why exactly 3 letters?I hope somebody can help me.Best regardsMarkus Weber

View 1 Replies View Related

T-SQL (SS2K8) :: Find String Before Character When Character Appears Multiple Times

May 17, 2015

I have a table that contains file paths as

ServernamefolderAfilenameA
ServernameFolderBFilenameB

and I need a query to return

ServernamefolderA
ServernameFolderB

I tried

SELECT DISTINCT left(Source, charindex('', Source)- 0) AS String
FROM Table

But that removes everything after the first and I need it to return all data before the last

View 5 Replies View Related

T-SQL (SS2K8) :: Replace Multiple Occurrences Of Same Character With Single Character

Aug 6, 2015

I have the following scenario, The contents of main file are like :

ServerCentral|||||forum|||||||||||||||is||||||the||best
so||||||be|||||on||||||||||||||||||||||||||||||||||||||||||||it

And I need the output in the following form:

ServerCentral=forum=is=the=best
so=be=on=it

The logic being that multiple and consecutive occurrences of the special character, here - pipe , should be replaced by a single special character.

View 5 Replies View Related

Select Part Of Character String Based On A Character

Apr 15, 2004

I have data in a column that starts with 1-4 characters followed by a dash then followed by an number of characters (ex: EU-Surgery).

How do I select everything to the right of the dash when the number of characters to the left of the dash varies?

View 3 Replies View Related

Ignoring A Column In During DTS

Nov 1, 2004

I'm importing from an Excel spreadsheet into an SQL Table using DTS.

Two things:

1. I don't want anything imported into Column 1 of the table as this has been designed to automatically increment (creating a primary key). I haven't worked out how to do this.

2. How can I get the DTS package to ignore the top 2 rows of the Excel spreadsheet (header information)?

An answer to one will be great but both will be tremendous!!

View 1 Replies View Related

Query Ignoring Filter?

Feb 29, 2008

All,

So I have this query that is ignoring my date filter and for the life of me I can't figure out why. Was hoping some guru could explain it to me. Here goes:

This query ignores my date filter:

SELECT
rcv.Name AS MachineName,
r.JobId,
j.Name AS JobName,
r.CreateTime AS JCreateTime,
rsv.Name AS JResultStatus,
rpv.Path + rpv.Name AS ResourcePool,
rcvv.ResourceConfigurationVal AS Dimension

FROM
dbo.Result_View AS r
INNER JOIN dbo.ResourceConfiguration_View AS rcv ON r.ResourceConfigurationId = rcv.Id
INNER JOIN dbo.Job_View AS j ON r.JobId = j.Id
INNER JOIN dbo.ResultStatus_View AS rsv ON r.ResultStatusId = rsv.Id
INNER JOIN dbo.Resource_View AS rv ON rcv.ResourceId = rv.Id
INNER JOIN dbo.ResourcePool_View AS rpv ON rv.ResourcePoolId = rpv.Id
RIGHT JOIN dbo.ResourceConfigurationValue_View AS rcvv ON rv.LatestResourceConfigurationId = rcvv.ResourceConfigurationId
LEFT JOIN dbo.Dimension_View AS d ON rcvv.DimensionId = d.Id

WHERE
(r.CreateTime > DATEADD(DAY, -15, GETDATE()))
AND
(rcv.Name LIKE 'PNP%')
AND
(d.Id = 859)
OR
(d.Id = 860)

If I comment out the last two joins and associated select/filters, all of the sudden the date filter works again. From everything I have read, the joins are supposed to be processed BEFORE the filters are applied in the virtual table. My DB goes back a number of years and contains millions of records. W/O the date filter, the query takes a very, very long time to run.

Any ideas on why this would happen?

Thanks,

Allen

View 5 Replies View Related

Ignoring Source Field

Sep 8, 2005

Hi,

View 1 Replies View Related

Return Left-most Character From 8 Character String

Oct 1, 2014

I'd like to return the left-most character from an 8 character string & the third from the left character too.

Like this ABC00123 returns AC

$query = "SELECT LEFT(uninum,3), RIGHT(uninum,5), clmarea, Date FROM tblunimov";
$result = mysql_query($query) or die(mysql_error());

echo "<div class='tblstyle1'>";
echo "<table class='tblstyle1'>";
echo "<tr><th>ini</th><th>item</th><th>area</th><th>date</th></tr>";
while($row = mysql_fetch_array($result)){

[Code] ....

View 5 Replies View Related

SqlDataSource Select Is Ignoring My Filter

Sep 25, 2007

I am using the SqlDataSource to access the dB from my page. Basically this is what I do with it ds.SelectParameters.Clear();
ds.SelectParameters("Id", TypeCode.Int32, id.ToString());

DataSourceSelectArguments dssa = new DataSourceSelectArguments();
dssa.MaximumRows = 1;
dssa.AddSupportedCapabilities(DataSourceCapabilities.Page);

DataView dv = (DataView)ds.Select(dssa);
if (dv.Count > 0)
{
// collect the information
string title = (string)dv[index].Row.ItemArray[0];
}
And the SelectCommand attribute of the SqlDataSource is set in design mode to "SELECT * from vw_Items ORDER BY Category".
So, since I am trying to retrieve just the item with the given Id I was expecting just one record but when I step through I see that the data view has a count of 9 (all records in the table) !!!
What am I doing wrong here? why can't it return just one? as per the select statement which after adding the parameter should be something like "SELECT * FROM vw_Items WHERE ID = 5 ORDER BY Category 

View 1 Replies View Related

Ignoring A Parameter Value In A Stored Procedure

Jun 2, 2006

If you have a table called Person and has ID, Age, Gender and Name. And you have a stored procedure:
CREATE PROCEDURE [dbo].[GetName]@Age TINYINT,@Gender TINYINTASBEGIN    SELECT Name FROM Person   WHERE Age = @Age AND Gender = @Gender END
You want some times to send @Age as null to get all ages (or in other words, you are not concerned with the age) or @Gender as null to get all genders.
A way to do that is to build your query string dynamically and execute it with EXEC command. However, this is a bad solution because you are losing most of the SP benefits and writting longer and more complicated procedures, specially that you have a lot of parameters!
Another solution that I thought of is having your select like this:    SELECT Name FROM Person   WHERE Age = ISNULL(@Age,Age) AND Gender = ISNULL(@Gender, Gender)
However, I noticed that when the value of the column is NULL, you will get false results, obviously because you are using = operator in comparing a value with null while you should be using IS operator, so this method did not work.
I am wondering if any one has a good solution for this.
Adam Tibi

View 2 Replies View Related

Search By Ignoring Special Characters

Dec 14, 2011

In our schools we have a number of East-European, Turkish, Scandinavian, ... students. Their names contain "special" characters, like Ö, Ü, Ø, ... Our users want to be able to search for student names without having to enter those special characters. Most often they don't know the exact spelling of the names and they get "no match found" messages as a result.

They want to have persons with the name Ösgür, Osgueld, ... in the result set after entering "osgu" in the search field.

What is the best way to do this? I was thinking about using another collation near the LIKE, but I don't know if that would work and how it should be done. The Database collation is Latin1_General_CI_AS.

View 4 Replies View Related

Ignoring Numeric & Alphanumeric Values

Apr 2, 2008

Hi,
I am using SQL Server 2000. In database i am having one column named Address which contains full address of the customer. While searching i want to ignore starting numeric or alphanumeric values. Kinly guide how I can ignore numeric or alphanumeric values while searching the data.

View 8 Replies View Related

Files Ignoring Permission Inheritence

Feb 29, 2008

Hi,

This may be a silly question out of ignorance, but I'm working in an environment where I am a DBA for a server, but I'm not a local admin on the windows server for the first time, so sorry if it is

Anyway, I have set up some traces that are writing to a file stored in a directory I have full control on. However, the trace files themselves are not inheriting the folder permissions, even though the folder is configured to do so. The only logins with access are the Local System account, the SQL Server service account local group, and the local administrators group.

Is this something that SQL Server does on its own, or would this have to be something the system admins have set up with group policy or something? If its SQL Server, is there some configuration setting I can change to get it to stop doing that so I can stop bugging the admins to give me access every time I run a trace?

Thanks,

Larry

View 3 Replies View Related

Transact SQL :: Select Seems To Be Ignoring WHERE Conditions

Apr 23, 2015

SQL Version:  2008 (not r2)
Problem:  My Select statement seems to be unaffected by some of the conditions in the WHERE Clause.  For instance

JCCD.Mth >= cutoffs.FiscalYear_FirstMonth (value '20130101') AND JCCD.Mth <= @WIPMonthCurrent (value '20130101')AND LTRIM(RTRIM(JCCD.Job)) = '71-' (see output and code below)
SQL Code:
declare @WIPMonthCurrent date  = '20130101'
SELECT  
     JCCD.JCCo, JCCD.Job, JCCD.Mth, JCCD.Source, sum(JCCD.ActualCost) AS CostToDate

[code]....

View 5 Replies View Related

Delete From A Table Ignoring A Foreign Key

Dec 6, 2007

Hi,

I am looking to delete a single row from a relatively small table. Unfortunately, there is a foreign key relationship between this table and a much much larger table. The checking of this foreign key when I am deleting this row seems to significantly impact the performance of the operation. Previously there was an index on this larger table that helped this query run. This index has been dropped to improve the performance of a more frequently executed operation.

Is there a way I can use a hint or something to stop SQL checking this foreign key when deleting the row? I am certain that there are no associated rows in the larger table.

I have read elsewhere that I could disable the foreign key, perform the delete, then enable the foreign key. This delete statement is not a one off process and could happen in the normal operation of the application so I don't really know what the implications of doing this are.

Any suggestions would be appreciated.

Thanks

Rich

View 1 Replies View Related

SQL Query Ignoring Null Values In Joins-- Help

Aug 2, 2006

I would like to populate a grid with data from 2 different tables.
Table1: [PK]id(int), name(nvarchar), areaID(int)
Table2: [PK][FK]areaID(int), areaDescription(nvarchar)

My cerrent query is:
SELECT Table1.id, Table1.name, Table2.areaDescription FROM Table1 INNER JOIN Table2 ON Table1.areaID = Table2.areaID

However, sometimes the areaID in Table1 will only be populated at a later stage and therefore will be NULL in Table1. Table2 is used as a lookup table when inserting into Table1. This query therefore ommits any records in Table1 which do not have an areaID. I would like to view ALL records(ones without an areaID as well) as they would be populated in the grid and selected to be updated on web forms because they are incomplete and then subsequently assigned an areaID.

Any help with this query would be much appreciated...

View 2 Replies View Related

Bulk Insert Ignoring Uniqueness Constraint?

Aug 16, 2012

I"m trying to use a BULK INSERT command to insert data into a table from a file. There is a UNIQUE Index that is being violated and the BULK INSERT fails.

I do not want to drop or disable the index, however, i also do not want to load 'duplicate' records so i keep the CHECK_CONSTRAINTS parameter.

Is there a way to have the duplicate records outputed to the ERRORFILE ?

View 10 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved