Friday, February 24, 2012
How to retrieve data using a search?
Is there any way in which i can retirve data using input parameters?you're thinking of the way a dialog box pops up in microsoft access?
no, in sql server you have to do this with application code|||yes , u r right, i was thinking teh way exactly as it can be done in access?
can u pls send me a sample code of writing an application code?
Thanx in advance|||not me, no, maybe someone else
i'm not a programmer|||so its beeen a big ask in retrieving data of a particular choice in MS SQL?|||No. It's pretty easy. Is it a big ask to figure it out yourself?
We don't even know what interface you are using. VB? Access mdb? Access adp? DotNet? C#?
You expect people to not only do your work for you, but to guess what you want? That's a pretty big ask.|||But i am using webassitant wizard to get the reports on the Intranet. and VB is our front end.
where i have an option for reports tab on the VB front end where it fetches data from the webassistant wizard.
every other report works fine, Only thing i am trouble designing in reports is to search in a particular field. as i am new to this developing part in SQL any ones help in solving the search with input parameters would be much appreciated.
Thanx in advance
VEE Yes|||Ummmmm... post your question in a forum for whatever front-end application your using (I was unable to decipher anything other than VB from your description).
You're on the wrong forum, but you might get lucky from a passer-by understanding what you are experiencing. If you don't want to wait around for a ride, then go directly to the right forum, do not pass Go and do not collect $200.|||Just a guess at what you want, but you should probably write a stored procedure on your SQL Server database that takes your search terms as parameters and returns the dataset to your application.|||CAn any one help me with a stored procedure to write to take an input parameters to search and retrieve data?|||Remember two things...
only use this code to benefit man
and
Soylent Green is PEOPLE!!!!!!!!!
/*
this script creates a db, a table, and a stored procedure.
the table shows the level of my malaise
which steadily grows from crappy to the ultimate level
rdjabarov
the proc asks for a parameter to return query rows.
*/
create database crappyDB
go
use Crappydb
go
create table CrappyTable
(
col1 int
,col2 varchar(20)
)
go
insert into crappytable select 1, 'crappy'
union select 2, 'really crappy'
union select 3, 'extra crappy'
union select 4, 'totally crappy'
union select 5, 'RDJabarov'
go
select * from crappytable
go
create procedure Pcrappyproc
@.col1 int
as
select col2 as 'rate my malaise' from crappytable
where col1 = @.col1
go
exec Pcrappyproc 5
go
--drop database crappydb|||brilliant code
especially col2's column alias
:)|||shhhhhhhh
i get no pleasure from doing it....plus it gets him all riled up. :D|||Oh, like THAT is so difficult... ;)|||...select 5, 'RDJabarov'...So you have time to post silly things like this, but you don't have the time to send your resume?
How's VA?|||sent it hours ago dude.
How to retreive set of rows from stored procedure
hi,
i am new to SQL. i have created a stored procedure which gets a input parameter "Category" and it selects datas which falls under this category. when i run this procedure it returns only the last row. it doesnt retreive the entire set of rows. which method should i follow to solve my problem.. i want all the rows which comes under the category to be returned ....
MY PROCEDURE
CREATE PROCEDURE [dbo].[Items_Category_sorted]
(
@.Category varchar(10),
@.ProductID Char(10) OUTPUT,
@.Name Char(50) OUTPUT,
@.UnitPrice Numeric(9) OUTPUT,
@.Stock Numeric(9) OUTPUT
)
AS
BEGIN
SET NOCOUNT ON;
SELECT @.ProductID=ProductID,
@.Name=Name,
@.UnitPrice=UnitPrice,
@.Stock =Stock
From
ProductDetails
Where
Category=@.Category
END
As you're using output parameters, you can only have one value per parameter and this will be set to values in the last row returned by your query.
To return a recordset of multiple values, try:
CREATE PROCEDURE [dbo].[Items_Category_sorted]
(
@.Category varchar(10)
)
AS
BEGIN
SET NOCOUNT ON;
SELECT ProductID,
Name,
UnitPrice,
Stock
From
ProductDetails
Where
Category=@.Category
END
Hope this helps!