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.
| Author |
Topic |
|
lou610
Starting Member
2 Posts |
Posted - 2012-08-22 : 08:56:43
|
| i am a student studying SQL database management and i was asked to print a pattern containing length and width can someone help me please it is highly importantthe pattern must look like this@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@i know i need to use a while loop but need the help thank you in advanceLourens |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-08-22 : 09:01:28
|
Well..... if you are using SQL Server 2008 and later, you can do thisprint replicate('@', 10)go 4 KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
YuvarajKrishna
Starting Member
4 Posts |
Posted - 2012-08-22 : 10:26:01
|
| Hi lou610 Try once thisCREATE PROC PrintPattern ( @length int , @width int)AS--Declaring VariablesDECLARE @Var NVARCHAR(MAX) = ''DECLARE @i INT = 0WHILE @i < @width BEGIN SET @Var = @Var+'@' SET @i = @i+1ENDSET @i = 0WHILE @i < @length BEGIN PRINT @Var SET @i = @i+1ENDYuvaraj |
 |
|
|
xhostx
Constraint Violating Yak Guru
277 Posts |
Posted - 2012-08-22 : 10:29:06
|
quote: Originally posted by khtan Well..... if you are using SQL Server 2008 and later, you can do thisprint replicate('@', 10)go 4 KH[spoiler]Time is always against us[/spoiler]
Just want to mention that this statement can also be executed unde SQL Server2005--------------------------Joins are what RDBMS's do for a living |
 |
|
|
lou610
Starting Member
2 Posts |
Posted - 2012-08-22 : 12:48:10
|
| Thank you but i was just told that the length and width is stored in my database how do i do it then?Lourens |
 |
|
|
|
|
|