Click here to Skip to main content
15,891,033 members
Home / Discussions / Database
   

Database

 
GeneralRe: Is it posible to make several relations between two tables in SQL query ? Pin
Stanciu Vlad17-Apr-10 5:42
Stanciu Vlad17-Apr-10 5:42 
QuestionProcedure is using server resource but unmanaged how to managed that... Pin
Sasmi_Office16-Apr-10 23:35
Sasmi_Office16-Apr-10 23:35 
AnswerRe: Procedure is using server resource but unmanaged how to managed that... Pin
dan!sh 17-Apr-10 3:44
professional dan!sh 17-Apr-10 3:44 
GeneralRe: Procedure is using server resource but unmanaged how to managed that... Pin
Sasmi_Office17-Apr-10 4:19
Sasmi_Office17-Apr-10 4:19 
GeneralRe: Procedure is using server resource but unmanaged how to managed that... Pin
dan!sh 17-Apr-10 5:45
professional dan!sh 17-Apr-10 5:45 
AnswerRe: Procedure is using server resource but unmanaged how to managed that... Pin
Ashfield17-Apr-10 6:12
Ashfield17-Apr-10 6:12 
QuestionSort Results ignoring symbols like ! ? * " Pin
AlexeiXX316-Apr-10 16:14
AlexeiXX316-Apr-10 16:14 
AnswerRe: Sort Results ignoring symbols like ! ? * " [modified] Pin
Andy_L_J16-Apr-10 18:03
Andy_L_J16-Apr-10 18:03 
Ok, I did this:

DECLARE @Table AS Table(
    ID Int,
    [Name] nVarChar(50))
    
INSERT @Table(ID, Name)
  VALUES(1, '"The less you talk..."') 
INSERT INTO @Table
  SELECT 2, 'The long and...'
INSERT INTO @Table
  SELECT 3, '-ABC of Math'
INSERT INTO @Table
  SELECT 4, '*Something Else'


          
SELECT * FROM @Table
ORDER BY (SELECT CASE WHEN (UNICODE(SUBSTRING(Name,1,1))< 123)
                      THEN UNICODE(SUBSTRING(Name, 2,1))
                      ELSE Name End) ASC


Result:

ID      Name
-----------------------------
3	-ABC of Math
4	*Something Else
1	"The less you talk..."
2	The long and...


The results match what you specified, but what if there is more than one 'special' character at the beginning of the string?

EDIT:

If you add more data you will find the following:

DECLARE @Table AS Table(
    ID Int,
    [Name] nVarChar(50))
    
INSERT @Table(ID, Name)
  VALUES(1, '"The less you talk..."') 
INSERT INTO @Table
  SELECT 2, 'The long and...'
INSERT INTO @Table
  SELECT 3, '-ABC of Math'
INSERT INTO @Table
  SELECT 4, '*Something Else'
INSERT INTO @Table
  SELECT 4, '? A Question'
INSERT INTO @Table
  SELECT 4, '#Regions'
INSERT INTO @Table
  SELECT 4, 'Sometimes you are right.'
INSERT INTO @Table
  SELECT 4, 'Little creatures'

          
SELECT * FROM @Table
ORDER BY (SELECT CASE WHEN (UNICODE(SUBSTRING(Name,1,1))< 123)
                      THEN UNICODE(SUBSTRING(Name, 2,1)) 
                      ELSE Name  End
              ) ASC


Result:
ID	Name
-------------------------------
4	? A Question
3	-ABC of Math
4	#Regions
4	*Something Else
1	"The less you talk..."
2	The long and...
4	Little creatures
4	Sometimes you are right.


This may not be ideal...
I don't speak Idiot - please talk slowly and clearly

'This space for rent'

Driven to the arms of Heineken by the wife
modified on Saturday, April 17, 2010 12:18 AM

GeneralRe: Sort Results ignoring symbols like ! ? * " Pin
AlexeiXX316-Apr-10 18:35
AlexeiXX316-Apr-10 18:35 
GeneralRe: Sort Results ignoring symbols like ! ? * " Pin
Andy_L_J16-Apr-10 19:02
Andy_L_J16-Apr-10 19:02 
AnswerRe: Sort Results ignoring symbols like ! ? * " Pin
Eddy Vluggen17-Apr-10 0:37
professionalEddy Vluggen17-Apr-10 0:37 
Questionhow to read data from pdf file Pin
raghvendrapanda16-Apr-10 1:37
raghvendrapanda16-Apr-10 1:37 
QuestionProblem with attaching a copy of DB which is recieved from another server Pin
ArtemCh15-Apr-10 8:40
ArtemCh15-Apr-10 8:40 
AnswerRe: Problem with attaching a copy of DB which is recieved from another server Pin
ArtemCh15-Apr-10 9:07
ArtemCh15-Apr-10 9:07 
QuestionREADPAST SP Pin
Amr M. K.14-Apr-10 22:04
Amr M. K.14-Apr-10 22:04 
QuestionSystem.Security.SecurityException while accessing report Pin
nizamuddin73314-Apr-10 19:26
nizamuddin73314-Apr-10 19:26 
AnswerRe: System.Security.SecurityException while accessing report Pin
nizamuddin73314-Apr-10 23:21
nizamuddin73314-Apr-10 23:21 
QuestionIncorrect syntax near the keyword 'WITH' Pin
icanmakeiteasy14-Apr-10 19:06
icanmakeiteasy14-Apr-10 19:06 
JokeMessage Removed Pin
14-Apr-10 23:50
Michel Godfroid14-Apr-10 23:50 
GeneralRe: Incorrect syntax near the keyword 'WITH' Pin
David Skelly15-Apr-10 1:58
David Skelly15-Apr-10 1:58 
GeneralRe: Incorrect syntax near the keyword 'WITH' Pin
Michel Godfroid15-Apr-10 2:19
Michel Godfroid15-Apr-10 2:19 
AnswerRe: Incorrect syntax near the keyword 'WITH' Pin
WoutL15-Apr-10 2:20
WoutL15-Apr-10 2:20 
GeneralRe: Incorrect syntax near the keyword 'WITH' Pin
icanmakeiteasy9-May-10 20:35
icanmakeiteasy9-May-10 20:35 
QuestionIs it possible to specify multiple text data filters in SQL profiler 2005? Pin
Jon_Boy14-Apr-10 6:36
Jon_Boy14-Apr-10 6:36 
Questionhow to enter the records from one table to another table at the same time Pin
developerit13-Apr-10 22:51
developerit13-Apr-10 22:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.