Click here to Skip to main content
15,893,486 members
Home / Discussions / Database
   

Database

 
QuestionHow to drop builtin\administrators account from sql server Pin
Developer61125-Aug-07 22:39
Developer61125-Aug-07 22:39 
AnswerRe: How to drop builtin\administrators account from sql server Pin
Mark Churchill26-Aug-07 18:07
Mark Churchill26-Aug-07 18:07 
GeneralRe: How to drop builtin\administrators account from sql server Pin
Developer61126-Aug-07 19:35
Developer61126-Aug-07 19:35 
GeneralRe: How to drop builtin\administrators account from sql server Pin
Burnsys229-Aug-07 4:35
Burnsys229-Aug-07 4:35 
Questionoutput to struct Pin
ginjikun25-Aug-07 6:53
ginjikun25-Aug-07 6:53 
AnswerRe: output to struct Pin
Christian Graus26-Aug-07 0:30
protectorChristian Graus26-Aug-07 0:30 
QuestionProblem with piece of code Pin
ChrisFarrugia25-Aug-07 6:12
ChrisFarrugia25-Aug-07 6:12 
AnswerRe: Problem with piece of code Pin
Colin Angus Mackay25-Aug-07 6:51
Colin Angus Mackay25-Aug-07 6:51 
ChrisFarrugia wrote:
I have this stored procedure on which I would like to apply if statements at the where clause. But it seems that sql is finding errors associated with the if statements. Can anyone please guide me on what is wrong. Maybe it is not possible to use if statemnts in where clauses?


You can't use IF statements in WHERE clauses. IF statements stand alone and do not form part of another statement (in this case the SELECT statement)

Your best bet is to put the IF statement around the SELECT

IF ((@category<>0) AND @brand=0) 
BEGIN
    SELECT equipment_id, equipment_modelNumber, equipment_description, category, brand, 
           link, equipment_small_image, equipment_largr_image 
    FROM Gen_Equipment 
    INNER JOIN Gen_Equipment_Categories
    INNER JOIN Gen_Equipment_Brand
    INNER JOIN Gen_Equipment_Link
    ON (Gen_Equipment.equipment_category=Gen_Equipment_Categories.category_id)
    ON (Gen_Equipment.equipment_brand=Gen_Equipment_Brand.brand) 
    ON (Gen_Equipment.equipment_link=Gen_Equipment_Link.link_id) 
    WHERE Gen_Equipment.equipment_category=@category 
    ORDER BY Gen_Equipment.equipment_category
END
ELSE
BEGIN
    SELECT equipment_id, equipment_modelNumber, equipment_description, category, brand, 
           link, equipment_small_image, equipment_largr_image 
    FROM Gen_Equipment 
    INNER JOIN Gen_Equipment_Categories
    INNER JOIN Gen_Equipment_Brand
    INNER JOIN Gen_Equipment_Link
    ON (Gen_Equipment.equipment_category=Gen_Equipment_Categories.category_id)
    ON (Gen_Equipment.equipment_brand=Gen_Equipment_Brand.brand) 
    ON (Gen_Equipment.equipment_link=Gen_Equipment_Link.link_id) 
    WHERE equipment_brand=@brand
END 



-- Always write code as if the maintenance programmer were an axe murderer who knows where you live.

Upcoming FREE developer events:
* Glasgow: Agile in the Enterprise Vs. ISVs, Mock Objects, SQL Server CLR Integration, Reporting Services, db4o ...
* Reading: SQL Bits


My website

QuestionAlternate of listbox.itemdata property Pin
RaveRare24-Aug-07 23:51
RaveRare24-Aug-07 23:51 
GeneralRe: Alternate of listbox.itemdata property Pin
John-ph25-Aug-07 0:41
John-ph25-Aug-07 0:41 
AnswerRe: Alternate of listbox.itemdata property Pin
Rupesh Kumar Swami25-Aug-07 23:38
Rupesh Kumar Swami25-Aug-07 23:38 
QuestionBest practices to save, edit, insert, view records on a Complex form vb.net Pin
RaveRare24-Aug-07 22:09
RaveRare24-Aug-07 22:09 
AnswerRe: Best practices to save, edit, insert, view records on a Complex form vb.net Pin
Christian Graus24-Aug-07 22:49
protectorChristian Graus24-Aug-07 22:49 
GeneralRe: Best practices to save, edit, insert, view records on a Complex form vb.net Pin
RaveRare24-Aug-07 22:53
RaveRare24-Aug-07 22:53 
GeneralRe: Best practices to save, edit, insert, view records on a Complex form vb.net Pin
Christian Graus25-Aug-07 0:43
protectorChristian Graus25-Aug-07 0:43 
GeneralRe: Best practices to save, edit, insert, view records on a Complex form vb.net Pin
Widgets26-Aug-07 17:30
Widgets26-Aug-07 17:30 
Questionencrypt password and user name Pin
prasadbuddhika24-Aug-07 18:52
prasadbuddhika24-Aug-07 18:52 
AnswerRe: encrypt password and user name Pin
Rami Said Abd Alhalim25-Aug-07 2:49
Rami Said Abd Alhalim25-Aug-07 2:49 
QuestionAuto generate field value.., Pin
HemMagesh24-Aug-07 18:06
HemMagesh24-Aug-07 18:06 
AnswerRe: Auto generate field value.., Pin
Christian Graus24-Aug-07 18:23
protectorChristian Graus24-Aug-07 18:23 
AnswerRe: Auto generate field value.., Pin
Senu Gandhi24-Aug-07 22:47
Senu Gandhi24-Aug-07 22:47 
Questiontrigger to client Pin
pian_christian24-Aug-07 16:55
pian_christian24-Aug-07 16:55 
AnswerRe: trigger to client Pin
Christian Graus24-Aug-07 18:22
protectorChristian Graus24-Aug-07 18:22 
AnswerRe: trigger to client Pin
Rami Said Abd Alhalim25-Aug-07 2:52
Rami Said Abd Alhalim25-Aug-07 2:52 
GeneralRe: trigger to client Pin
pian_christian26-Aug-07 15:15
pian_christian26-Aug-07 15:15 

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.