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.

Recommended Answers

All 5 Replies

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.

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?

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

@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.

Once again thanks for ur response

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.