473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

selective sql request

Sam
Hi,
I've got the following Stored Procedure

CREATE PROCEDURE pr_Admin_GetCtrlFields
--Get the control fields, detail or flow according to the ModeID
parameter
@QueryID int,
@ModeID int
AS

SELECT FieldID, FieldName, EntryInfo, ControlTypeID,ViewFieldTypeID,
ViewTable, ViewField,
F.SortOrder, InsertField, UpdateField, FieldTabId, ModeId
FROM Fields F, Queries

WHERE F.QueryID = @QueryID
AND ControlTypeID <> NULL
AND ModeID = @ModeID
ORDER BY F.SortOrder ASC
GO
[Fields] and [Queries] are linked by a field called {QueryID}.
[Queries] contain a field called {RootTable}, and what I want to do is:

If ViewTable is NULL then I select {RootTable} as ViewTable, otherwise
I select ViewTable as I'm currentely doing it.

So how can I introduce this condition in my Select statement?

Thx

Jul 23 '05 #1
3 1094
COALESCE(viewtable, roottable) AS viewtable

--
David Portas
SQL Server MVP
--

Jul 23 '05 #2
Sam
Thx !

Jul 23 '05 #3
Sam (sa**************@voila.fr) writes:
Hi,
I've got the following Stored Procedure

CREATE PROCEDURE pr_Admin_GetCtrlFields
--Get the control fields, detail or flow according to the ModeID
parameter
@QueryID int,
@ModeID int
AS

SELECT FieldID, FieldName, EntryInfo, ControlTypeID,ViewFieldTypeID,
ViewTable, ViewField,
F.SortOrder, InsertField, UpdateField, FieldTabId, ModeId
FROM Fields F, Queries

WHERE F.QueryID = @QueryID
AND ControlTypeID <> NULL


Beware! This is most certainly not what you want. This condition
will never evaulate to TRUE. Use IS NOT NULL instead.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mike Connor | last post by:
I am having trouble getting Conditional Folder creation & File insertion to work using VS .Net in a Deployment Project for a C# app. I am displaying a generic Textbox Dialog under the User...
4
by: SP | last post by:
Hi I have a problem with a customer's XML being submitting to me in a non-well-format XML. They said that there are 18 other partners who has been able to tweak the XML to make it work. So I...
1
by: Solitus | last post by:
I have databinding problem with a repeater <ItemTemplate> <tr> <!-- fixed content --> </tr> <tr> <!-- optional content --> </tr> </ItemTemplate>
4
by: Michael Kujawa | last post by:
I am using the following to create an SQL statement using the names and values from request.form. The loop goes through each item in request.form The issue comes in having an additional "and" at...
4
by: alex.hatzisavas | last post by:
Dear all, I'm trying to do a selective deletion from an 'Archive' table based on dates. Here is the setup: Table 'Archive' has a date field ( ). Another table ('Cutoffs') defines the Low...
1
by: aman909 | last post by:
Hello, I have a stock control system for fabric that is produced. The stock control has contains details of every colour of fabric that is produced. We have about 40 to 50 different colours. Im...
2
by: MDANH2002 | last post by:
Hi From VB.NET I want to simulate the POST request of the following HTML form <html> <title>HTTP Post Testing</title> <body> <form action=http://www.example.com/postdata ...
5
by: chromis | last post by:
Hi there, I've recently been updating a site to use locking on application level variables, and I am trying to use a commonly used method which copies the application struct into the request...
0
by: arindams | last post by:
I've a form where an webrowser contains a html file. I want to copy a selective portion of the html content and paste that content in an excel 2007 file where it will be pasted as a normal text (not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.