Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 I have a problem in function

Author  Topic 

vedjha
Posting Yak Master

228 Posts

Posted - 2010-02-04 : 12:05:52
I have to count whole users and display it
i have write query as :



declare @count int
declare @uid varchar(10)
set @uid=''
declare @i int
set @count=0
set @i=1

select @count= count(*) from emp
select @uid=eid from emp order by eid
begin
while(@i<=@count)
begin

print @uid
set @i=@i+1
end
end


help me


http://kiransoftech.com

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-04 : 12:10:54
sorry your query doesnt make sense. what are you trying to do inside loop? as of now, it just prints a random id value in emp table repeatedly for count value number of times
Go to Top of Page

vedjha
Posting Yak Master

228 Posts

Posted - 2010-02-04 : 12:15:17
no ,
firstly I have to count whole data and display data one by one

http://kiransoftech.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-04 : 12:16:51
why count for displaying all the data . wont this be enough?

select eid from emp order by eid
Go to Top of Page

vedjha
Posting Yak Master

228 Posts

Posted - 2010-02-04 : 12:24:09
yes, i know this query but want to do with it function
actually my case is :

Find Users one by one and do transaction in another Table
so counting whole data and display data one by one

http://kiransoftech.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-04 : 12:26:58
but if at all possible go for set based approach. one by one processing will be slow. what will be transaction perfomed for each user?
Go to Top of Page

vedjha
Posting Yak Master

228 Posts

Posted - 2010-02-04 : 12:35:53
Yes It will be slow process. but i want to know the Steps , how to process using Function

http://kiransoftech.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-04 : 12:40:42
quote:
Originally posted by vedjha

Yes It will be slow process. but i want to know the Steps , how to process using Function

http://kiransoftech.com


which function? i cant see function in posted code
Go to Top of Page
   

- Advertisement -