0

Hello 1 and all
I have created a stored procedure for table X. X contains the fields B,C,D,E,F,G. B is a primary key with data type int. I am giving the stored procedure as follows:

Create Proc [dbo].[spXSelect]
@B int=null
as
Begin
If @B  is Null 
Begin
Select Ident_Current('X') as 'Identity'
Select *From X 
End
 If @B  is Not Null 
Begin
Select *From X where B=@B
End
End

In want to retrieve only the columns D and E in .net programming. Is it possible. Please help me thanx in advance.

4
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by happyns
0

That code doesn't make sense to me... What are you trying to accomplish and more often than not people use the Ident_current to guess the next record id, but if two people retrieve the ident current then they both post data... one of them will have the wrong identity.

Also if @B is null you are returning 2 cursors, a 1col 1 row, and * from X.

0

Hi ,

I need more explanation :

1- How many parameters you want to send?
2- How did you declare Primary key, is it incremental ?
3- What result you want?
4- Where You want to use it?

0

Hi Dear,
Please fins the changes in you storedprocedure,

Create Proc [dbo].[spXSelect]
@B int=null
as
Begin
If @B is Null 
Begin
Select Ident_Current('X') as 'Identity'
Select D,E From X 
End
If @B is Not Null 
Begin
Select D,E From X where B=@B
End
End
0

@Bandar.M.A Yes dude it is incremental. I want to retrieve only the columns D and E using VB.Net.
@jaiswarvipin I was told not to modify the stored procedure. As of the query used in not null parameter they are saying that using Select *From X where B=@B I can retrieve specified columns . But none of them are able to give me correct reply.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.