Monday, July 4, 2011

For loop in sql serever

Hi Friend

pelase check the how to loop the and insert data into db using the for loop in sql server (For multiple values )

DECLARE @CNT INT
DECLARE @Q NVARCHAR(1000)

SET @CNT = 110001
WHILE(@CNT <= 113500)
BEGIN
SET @Q = 'insert into plate_numbers values('+ CAST (@CNT AS NVARCHAR) + ')'
-- PRINT @Q
EXEC sp_executesql @Q
SET @CNT = @CNT + 1
END


Regards,
Bhaskar

7 comments:

Samrat chakravarthy said...

Hi Uday.. I was going through your hydcarpool website and found it interesting. I have a requirement and would like to know if you could help me with that. You can contact me on 9392166006 or mail me at srikanth.v5guys@gmail.com

micle said...

Great article, its very useful

We can submit our .net related article links on http://www.dotnettechy.com to get more traffics.

James Williamz said...

Hello

Great information about loop in sql server and I think this information will be helpful for me about loop.

James williams
error 1310

Jimmy Alex said...

Hello

Great information in this post and I think this information in this post will be helpful for me.

Jimmy Alex
Uniblue

taylorlautner1984 said...

THANKS FOR SHARING THIS POST.
affordable web design

ALEX Roads said...

Hi...

Nice post and really it contain a lot of information which help me in future prospects.
ALEX Roads
error1316 win 7
Thanks for sharing this useful information.

ANGELA White said...

I get a lot of information from this post and also bookmarked this.

ANGELA White,
speed up my pc 2012
Thanks for sharing