Click here to Skip to main content
15,892,059 members
Home / Discussions / Database
   

Database

 
QuestionThe question about DataView.Filter Pin
dreamwinter11-Sep-05 19:24
dreamwinter11-Sep-05 19:24 
AnswerRe: The question about DataView.Filter Pin
miah alom12-Sep-05 3:13
miah alom12-Sep-05 3:13 
QuestionHelp !!! Pin
WDI10-Sep-05 22:14
WDI10-Sep-05 22:14 
AnswerRe: Help !!! Pin
Colin Angus Mackay11-Sep-05 0:34
Colin Angus Mackay11-Sep-05 0:34 
GeneralRe: Help !!! Pin
WDI11-Sep-05 0:49
WDI11-Sep-05 0:49 
GeneralRe: Help !!! Pin
Colin Angus Mackay11-Sep-05 1:46
Colin Angus Mackay11-Sep-05 1:46 
QuestionStored Procedure - Verification Pin
phokojoe10-Sep-05 2:35
phokojoe10-Sep-05 2:35 
AnswerRe: Stored Procedure - Verification Pin
Colin Angus Mackay10-Sep-05 5:04
Colin Angus Mackay10-Sep-05 5:04 
Okay, I'm having a bit of trouble understanding what you want because the terminology you are using is inconsistent with the domain.

What do you mean by "variable"? Do you mean a column in the table?

By "input a parameter", do you mean you want to take as a parameter to the stored procedure the name of a column that you want to search?

You use the word "variables" a second time, but this time I'm thinking that "row" may be the correct interpretation for this instance. Do you mean you want to return the rows in the table that have a null value in some column (as specified by the user)?

Printing is not really a recommended action for a database server to take. It can be done, but it makes for messy applications.

Your last part on married couples is more of a business rule rather than a check of the OMR.

I am wondering if these checks cannot be made before the data from the OMR gets to the data. Or is this a senario where a lot of bad data has already gone into the database and you need to find it?

Answering your question as best I can

CREATE PROCEDURE dbo.SearchForNull
@columnName sysname
AS
DECLARE @dynamicSql nvarchar(4000);

IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS
              WHERE TABLE_NAME = 'MyTable'
              AND COLUMN_NAME = @columnName)
BEGIN
    -- The column does not exist
    RETURN;
END

SET @dynamicSql = '"SELECT id FROM MyTable WHERE ['+@columnName+'] IS NULL';
EXEC(@dynamicSql);
GO


This stored procedure will return a set containing the id of any row that has a null value for the supplied @columnName. The check of the INFORMATION_SCHEMA.COLUMNS table is important as it helps prevent an error or attack if someone has managed to put in a dodgy column name (either accidentally or maliciously).

Does this help?


My: Blog | Photos

"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious


GeneralRe: Stored Procedure - Verification Pin
phokojoe10-Sep-05 23:56
phokojoe10-Sep-05 23:56 
GeneralRe: Stored Procedure - Verification Pin
Colin Angus Mackay11-Sep-05 0:15
Colin Angus Mackay11-Sep-05 0:15 
GeneralRe: Stored Procedure - Verification Pin
Colin Angus Mackay11-Sep-05 0:21
Colin Angus Mackay11-Sep-05 0:21 
GeneralRe: Stored Procedure - Verification Pin
phokojoe11-Sep-05 22:11
phokojoe11-Sep-05 22:11 
GeneralRe: Stored Procedure - Verification Pin
Colin Angus Mackay12-Sep-05 1:55
Colin Angus Mackay12-Sep-05 1:55 
QuestionFree Databases Pin
Robert M Greene9-Sep-05 16:56
Robert M Greene9-Sep-05 16:56 
QuestionSQL Restore Mystery Pin
mjackson119-Sep-05 13:06
mjackson119-Sep-05 13:06 
AnswerRe: SQL Restore Mystery Pin
Rahul Walavalkar13-Sep-05 0:11
Rahul Walavalkar13-Sep-05 0:11 
QuestionTimeout Expired The timeout period elapsed prior to completion Pin
Jaffer Mumtaz9-Sep-05 1:22
Jaffer Mumtaz9-Sep-05 1:22 
AnswerRe: Timeout Expired The timeout period elapsed prior to completion Pin
OMalleyW9-Sep-05 1:51
OMalleyW9-Sep-05 1:51 
AnswerRe: Timeout Expired The timeout period elapsed prior to completion Pin
miah alom9-Sep-05 5:39
miah alom9-Sep-05 5:39 
GeneralRe: Timeout Expired The timeout period elapsed prior to completion Pin
Andy Brummer9-Sep-05 5:57
sitebuilderAndy Brummer9-Sep-05 5:57 
GeneralRe: Timeout Expired The timeout period elapsed prior to completion Pin
miah alom9-Sep-05 6:12
miah alom9-Sep-05 6:12 
GeneralRe: Timeout Expired The timeout period elapsed prior to completion Pin
Andy Brummer9-Sep-05 11:28
sitebuilderAndy Brummer9-Sep-05 11:28 
AnswerRe: Timeout Expired The timeout period elapsed prior to completion Pin
OMalleyW9-Sep-05 6:48
OMalleyW9-Sep-05 6:48 
GeneralRe: Timeout Expired The timeout period elapsed prior to completion Pin
miah alom9-Sep-05 7:04
miah alom9-Sep-05 7:04 
GeneralRe: Timeout Expired The timeout period elapsed prior to completion Pin
OMalleyW9-Sep-05 7:34
OMalleyW9-Sep-05 7:34 

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.