I think that would work. Kinda like putting water into a "vessel" that you
don't know where it is, or how big it is, or what shape it is.
-----Original Message-----
From: Piyush Dhangar
[mailto:mssqldba-ezmlmshield-x75172907.[Email address protected]
Sent: Tuesday, October 31, 2006 11:25 AM
To: LazyDBA Discussion
Subject: RE: how to use a table variable in place of cursor
Sorry for the incomplete question.
Can I do something like not defining the table definition and just as we do
select into tbl_nm
Can we do
Select into tbl_variable
?
Thanks & Regards
Piyush Dhangar
NIIT LTD, 85, Sec. 32, Gurgaon 122001
Ph: +91-124-4293241
-----Original Message-----
From: Mahtab [mailto:mssqldba-ezmlmshield-x38989235.[Email address
protected]
Sent: Wednesday, October 25, 2006 4:48 PM
To: LazyDBA Discussion
Subject: Re: how to use a table variable in place of cursor
Try This
declare @RowCnt int
declare @MaxRows int
declare @Email nvarchar(255)
declare @rc int
set nocount on
select @RowCnt = 1
declare @Import table
(
rownum int IDENTITY (1, 1) Primary key NOT NULL ,
Email nvarchar(255)
)
insert into @Import (Email) values ('[Email address protected]
insert into @Import (Email) values ('[Email address protected]
select @MaxRows=count(*) from @Import
while @RowCnt <= @MaxRows
begin
select @rc=0
select @Email = Email
from @Import
where rownum = @RowCnt
print @Email
Select @RowCnt = @RowCnt + 1
end
----- Original Message -----
From: "Piyush Dhangar "
<mssqldba-ezmlmshield-x57937723.[Email address protected]
To: "LazyDBA Discussion" <[Email address protected]
Sent: Tuesday, October 24, 2006 2:45 PM
Subject: how to use a table variable in place of cursor
> Dear All
>
>
>
> Can anyone tell me how can I use table variable to loop through the
records
> as I would do using a cursor.
>
>
>
> Thanks & Regards
>
> Piyush Dhangar
>
>
>
> NIIT LTD, 85, Sec. 32, Gurgaon 122001
>
> Ph: +91-124-4293241
>
>
>
> ----------------------------------------------------------------------
> DISCLAIMER
>
> This email and any files transmitted with it are confidential and are
solely for the use of the individual or entity to which it is addressed. Any
use, distribution, copying or disclosure by any other person is strictly
prohibited. If you receive this transmission in error, please notify the
sender by reply email and then destroy the message. Opinions, conclusions
and other information in this message that do not relate to official
business of the company shall be understood to be neither given nor endorsed
by NIIT Ltd. or NIIT Technologies Ltd. Any information contained in this
email, when addressed to Clients is subject to the terms and conditions in
governing client contract.
>
>
>
> ---------------------------------------------------------------------
> TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
> To post a dba job: http://jobs.lazydba.com
> To subscribe : http://www.LazyDBA.com
> To unsubscribe: http://www.lazydba.com/unsubscribe.html
>
>
>
> __________ NOD32 1.1576 (20060602) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
>
>
---------------------------------------------------------------------
TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
----------------------------------------------------------------------
DISCLAIMER
This email and any files transmitted with it are confidential and are solely
for the use of the individual or entity to which it is addressed. Any use,
distribution, copying or disclosure by any other person is strictly
prohibited. If you receive this transmission in error, please notify the
sender by reply email and then destroy the message. Opinions, conclusions
and other information in this message that do not relate to official
business of the company shall be understood to be neither given nor endorsed
by NIIT Ltd. or NIIT Technologies Ltd. Any information contained in this
email, when addressed to Clients is subject to the terms and conditions in
governing client contract.
---------------------------------------------------------------------
TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
MS Sql Server LazyDBA home page