| Author |
Topic |
|
FDumestani
Starting Member
1 Post |
Posted - 2007-09-27 : 06:04:21
|
| Hi, How can I generate rows automatically?The number of rows is generated according to an input from the user!Thanks, |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-09-27 : 06:28:29
|
quote: Originally posted by FDumestani Hi, How can I generate rows automatically?The number of rows is generated according to an input from the user!Thanks,
Why do you want to do this?MadhivananFailing to plan is Planning to fail |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-09-27 : 07:12:49
|
Why ask why? [Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-09-28 : 02:07:50
|
quote: Originally posted by DonAtWork Why ask why? [Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp
To know why OP wants to do it MadhivananFailing to plan is Planning to fail |
 |
|
|
renu
Starting Member
47 Posts |
Posted - 2007-09-28 : 02:25:13
|
| declare @v int,@v1 varchar(1000)set @v=2set @v1='select top '+ cast(@v as varchar(100)) +' * from tablename'exec(@v1) |
 |
|
|
renu
Starting Member
47 Posts |
Posted - 2007-09-28 : 02:25:49
|
| is this u expect |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-09-28 : 03:02:00
|
quote: Originally posted by renu declare @v int,@v1 varchar(1000)set @v=2set @v1='select top '+ cast(@v as varchar(100)) +' * from tablename'exec(@v1)
If that is the case, you can avoid dynamic sql declare @v intset @v=2Set Rowcount @vselect * from tablenameSet Rowcount 0 MadhivananFailing to plan is Planning to fail |
 |
|
|
renu
Starting Member
47 Posts |
Posted - 2007-09-28 : 04:35:18
|
| ya its more simple |
 |
|
|
|