question

mchoc-8723 avatar image
0 Votes"
mchoc-8723 asked TomPhillips-1744 answered

those two points ":" (Tr:)

Hello, I have a question, I can't find documentation.

Basically, what is the use of those two points ":" (Tr:)


ALTER PROCEDURE [dbo].test
(
@test [int]
)
AS
BEGIN
SET NOCOUNT ON
set @test = '2';
Tr:
select @test as Test;
END

sql-server-transact-sql
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ErlandSommarskog avatar image
0 Votes"
ErlandSommarskog answered ErlandSommarskog edited

That defines a label. In this procedure the label is not used, but labels are used with the GOTO command. Here is a demo:

CREATE PROCEDURE gotodemo @i int AS
IF @i > 0 
   GOTO Here
ELSE
   GOTO There
RETURN
Here:
   PRINT 'We did come here'
   RETURN
There:
   PRINT 'Now we are over there'
go
EXEC gotodemo 23
EXEC gotodemo -87
go
DROP PROCEDURE gotodemo

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

mchoc-8723 avatar image
0 Votes"
mchoc-8723 answered

Thank you very much, I did not know it was goto.
Thanks for the explanation.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TomPhillips-1744 avatar image
0 Votes"
TomPhillips-1744 answered
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.