Question : comments in code

What are some general good principles to know/follow when commenting a code.

as an example, how would you rearrange the coding part to make it easy to following and understand in the following:

thanks
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:
UPDATE tablename A

/* 
Line of comment Line of comment Line of comment Line of comment 
Line of comment Line of comment Line of comment Line of comment 
Line of comment Line of comment Line of comment Line of comment 
Line of comment Line of comment Line of comment Line of comment 
*/

SET Col1 = 'XYZ,
/*
Line of comment Line of comment Line of comment Line of comment 
Line of comment Line of comment Line of comment Line of comment 
*/

Col2 = 'ABC'
		
/*
Line of comment Line of comment Line of comment Line of comment 
Line of comment Line of comment Line of comment Line of comment 
*/

Col3 = 123,	

/*
Line of comment Line of comment Line of comment Line of comment 
Line of comment Line of comment Line of comment Line of comment 
*/

Col4 = 789		

/*
Line of comment Line of comment Line of comment Line of comment 
Line of comment Line of comment Line of comment Line of comment 
*/

WHERE 

/*
Line of comment Line of comment Line of comment Line of comment 
Line of comment Line of comment Line of comment Line of comment 
*/

	EXISTS 	
			(
			SELECT QUERY
			) B

WHERE 

/*
Line of comment Line of comment Line of comment Line of comment 
Line of comment Line of comment Line of comment Line of comment 
*/

--CONDITIONS

A.id = B.id

/*
Line of comment Line of comment Line of comment Line of comment 
Line of comment Line of comment Line of comment Line of comment 
*/

Answer : comments in code

It purely depends upon the Coding Standard defined in your Organization.
If you follow the Comments options available in SSMS or Visual Studio, then it would do a line comment by default

If you want to comment a block of code, then block comment will look good..
Random Solutions  
 
programming4us programming4us