Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 14th, 2004, 01:45 AM
Authorized User
 
Join Date: Oct 2004
Location: , , Philippines.
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default creating stored procedure

hi guys,
how can i create one stored procedure that have one parameter that will find the field (received) that is null or not null

i have the sql that works but i want is one Sp only for these
thanx

Reply With Quote
  #2 (permalink)  
Old October 14th, 2004, 02:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

You got to use dynamic sql then. construct the sql statement that takes the field parameter and then use EXEC function to execute that.
Code:
Create proc ProcName (@FIELDNAME varchar(100))
as
    Declare @strSql varchar(100)
    @strSql = "Select * from tablename where @FIELDNAME is NULL"
    Exec(@strSql)
    Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #3 (permalink)  
Old October 14th, 2004, 08:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

create procedure dbo.spGetNullOption

as

declare @IsNull int

select @IsNull = ISNULL(count(received), 0) from table1 where received is NOT NULL

'returns bit value
if (@IsNull > 0)
  return 1
else
  return 0

Brian
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating variables in a Stored procedure miamikk SQL Language 1 June 4th, 2007 03:02 AM
Creating stored procedure with trigger (HOWTO ..) AzlanAziz SQL Language 0 January 16th, 2007 04:34 AM
Creating Charts Using Stored Procedure srinivasparimi SQL Server 2005 1 August 7th, 2006 06:45 AM
Problem creating Stored Procedure vivekshah SQL Server 2000 4 May 28th, 2006 11:33 PM
Creating a stored procedure marthaj SQL Server ASP 8 June 10th, 2003 06:08 AM



All times are GMT -4. The time now is 02:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.