Click here to Skip to main content
15,887,596 members
Home / Discussions / Database
   

Database

 
GeneralRe: Add a new IDENTITY Pin
Elina Blank10-Jul-06 4:04
sitebuilderElina Blank10-Jul-06 4:04 
GeneralRe: Add a new IDENTITY Pin
TheEagle11-Jul-06 1:36
TheEagle11-Jul-06 1:36 
GeneralRe: Add a new IDENTITY Pin
Elina Blank11-Jul-06 2:32
sitebuilderElina Blank11-Jul-06 2:32 
QuestionORDER BY question Pin
leckey7-Jul-06 6:51
leckey7-Jul-06 6:51 
AnswerRe: ORDER BY question Pin
Jerry Hammond8-Jul-06 4:54
Jerry Hammond8-Jul-06 4:54 
GeneralRe: ORDER BY question Pin
Paul Conrad8-Jul-06 19:54
professionalPaul Conrad8-Jul-06 19:54 
GeneralRe: ORDER BY question Pin
Jerry Hammond9-Jul-06 3:22
Jerry Hammond9-Jul-06 3:22 
GeneralRe: ORDER BY question Pin
leckey10-Jul-06 3:17
leckey10-Jul-06 3:17 
Sorry for wording my question poorly. The part number is indeed unique. What I am looking for is if the user enters a part number that already exists in the database, the dropdown list populates with the part type first, then the remaining part type choices alphabetically. If the part does not exist, just order alphabetically. I had a friend help me last week and got this:

CREATE PROCEDURE [dbo].[GetPartDescriptions2]<br />
<br />
@PartType varchar (60)<br />
<br />
 AS<br />
<br />
SELECT PartTypes.ID, PartTypes.description,<br />
CASE when PartTypes.ID = @PartType then 1<br />
else PartTypes.ID<br />
end as order_by<br />
from PartTypes INNER JOIN parts p on p.PartTypeID = PartTypes.ID<br />
<br />
ORDER BY order_by<br />
<br />
But I was getting confused and the bolded parts are not right. I am passing in the part number so it should be something like this:<br />
<br />
<code>CREATE PROCEDURE [dbo].[GetPartDescriptions3] <br />
@PartNumber varchar (60)<br />
<br />
 AS<br />
<br />
SELECT PartTypes.ID, PartTypes.description, Parts.PartNumber, Parts.PartTypeID<br />
CASE when PartTypes.ID = Parts.PartTypeID then 1<br />
else PartTypes.ID<br />
end as order_by<br />
from PartTypes INNER JOIN parts p on p.PartTypeID = PartTypes.ID<br />
<br />
ORDER BY order_by<br />
GO


But enterprise manager doesn't like that. Asked my friend and she sent me this:

You could get the Part Type by

Declare @PartTypeId int

select @PartTypeId = PartTypeId
from PartTypes where Partnumber = @PartNumber


I'm now having trouble figuring out where to stick this new select statement in the entire code.



GO
GeneralRe: ORDER BY question Pin
Paul Conrad10-Jul-06 6:33
professionalPaul Conrad10-Jul-06 6:33 
Questiondynamic query in SQL Server 2000 Pin
SomeGuyThatIsMe7-Jul-06 4:50
SomeGuyThatIsMe7-Jul-06 4:50 
AnswerRe: dynamic query in SQL Server 2000 Pin
Eric Dahlvang7-Jul-06 5:57
Eric Dahlvang7-Jul-06 5:57 
GeneralRe: dynamic query in SQL Server 2000 Pin
SomeGuyThatIsMe7-Jul-06 6:04
SomeGuyThatIsMe7-Jul-06 6:04 
Questionsound & video Pin
md_refay7-Jul-06 4:09
md_refay7-Jul-06 4:09 
AnswerRe: sound & video Pin
Not Active7-Jul-06 4:17
mentorNot Active7-Jul-06 4:17 
AnswerRe: sound & video Pin
Scott Serl7-Jul-06 6:05
Scott Serl7-Jul-06 6:05 
QuestionBEGIN and END Pin
Brendan Vogt7-Jul-06 0:25
Brendan Vogt7-Jul-06 0:25 
AnswerRe: BEGIN and END Pin
Mike Dimmick7-Jul-06 2:54
Mike Dimmick7-Jul-06 2:54 
GeneralRe: BEGIN and END Pin
Frank Kerrigan7-Jul-06 3:16
Frank Kerrigan7-Jul-06 3:16 
QuestionSQL query problem, thanks Pin
zouchao11126-Jul-06 20:42
zouchao11126-Jul-06 20:42 
AnswerRe: SQL query problem, thanks Pin
Glen Harvy6-Jul-06 22:27
Glen Harvy6-Jul-06 22:27 
GeneralRe: SQL query problem, thanks Pin
zouchao11127-Jul-06 3:32
zouchao11127-Jul-06 3:32 
GeneralRe: SQL query problem, thanks [modified] Pin
Glen Harvy7-Jul-06 11:53
Glen Harvy7-Jul-06 11:53 
GeneralRe: SQL query problem, thanks Pin
zouchao11127-Jul-06 20:41
zouchao11127-Jul-06 20:41 
QuestionHow to access xml tag in sql server column Pin
CandyMe6-Jul-06 19:39
CandyMe6-Jul-06 19:39 
AnswerRe: How to access xml tag in sql server column Pin
Colin Angus Mackay6-Jul-06 20:29
Colin Angus Mackay6-Jul-06 20:29 

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.