-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday3.sql
More file actions
64 lines (36 loc) · 952 Bytes
/
day3.sql
File metadata and controls
64 lines (36 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
1
declare @sir nvarchar(max) = 'vasile'
set @sir = '1234456789012342123123123213123123'
select @sir = @sir + ' dasdasdasd'
--elect @sir
----loop sample
declare @limit int = 10
declare @counter int =1 ;
while @counter<= @limit
begin
print @counter
if @counter = 2
begin
break
end
set @counter = @counter +1
end
-----variabila de tip tabel
declare @tbl table ( id int primary key identity, firstname nvarchar(100))
insert @tbl values ('gogog')
select * from @tbl
------
----parcurgerea secventiala folosind cursor
----parcurgerea secventiala folosind bucla while
declare @tbl table ( id int primary key identity, firstname nvarchar(100))
declare @id int = 1
declare @maxId int
insert into @tbl values ('vasile1')
insert into @tbl values ('vasile2')
insert into @tbl values ('vasile3')
set @maxId = (select max(id) from @tbl)
while @id<= @maxId
begin
select * from @tbl where id = @id
set @id = @id +1
end