Declare @ t_chartsideaitem1 table (xdata char (20) null, ydata char (20) null)
Insert into @ t_chartsideaitem1
(Xdata, ydata)
Values ('bu9876', 'creating ')
Select * From @ t_chartsideaitem1
Query column-to-row display:
Begin
Declare @ sql1 varchar (8000 ),
@ Sql2 varchar (8000 ),
@ Sql3 varchar (8000)
Set @ sql1 = 'select'
Set @ sql2 = 'select'
Set @ sql3 = 'select'
Select @ sql1 = @ sql1 + ''' + convert (varchar (50), Field 1) + ''' as ['+ convert (varchar (50), Field 1) + '],',
@ Sql2 = @ sql2 + ''' + convert (varchar (50), × Field 2) + ''' as ['+ convert (varchar (50), Field 1) + '],',
@ Sql3 = @ sql3 + ''' + convert (varchar (50), Field 3) + ''' as ['+ convert (varchar (50), Field 1) + '],'
From table
Set @ sql1 = left (@ sql1, Len (@ sql1)-1)
Set @ sql2 = left (@ sql2, Len (@ sql2)-1)
Set @ sql3 = left (@ sql3, Len (@ sql3)-1)
Exec (@ sql1 + 'Union '+ @ sql2 + 'Union' + @ sql3)
End
Date:
Convert (varchar (10), getdate (), 120)
In this way, varchar (10) defines the length of the field you want. Of course, different lengths cannot be returned. If we only need the date part, set 10 to the date length. If it is set to 19, the time part can be read.
Now we will introduce the last generation of parameters, namely the generation parameters and instance effect descriptions.
Parameters
Result
100
05 8 2006 pm
101
05/08/2006
102
2006.05.08
103
08/05/2006
104
08.05.2006
105
08-05-2006
106
08 05 2006
107
05 08,200 6
108
21:30:51
109
05 8 2006 9:31:11
110
05-08-2006
111
2006/05/08
112
20060508
113
08 05 2006 21:31:59
114
21: 33: 06: 503
120
21:33:38
Alternative subquery:
Statement:
Select *,
(Select top 1 grades from t_assessment where companyid = C. companyid order by assessmentid DESC) as pgrades,
(Select (sum (score) + 60) from t_honesty where auditdate> = (select top 1 assessmentdate from t_assessment where companyid = C. companyid order by assessmentid DESC) and auditdate <= getdate () and companyid = C. companyid and status = 2) as score
From t_company C inner join t_user U on C. user_id = U. user_id where u. usertype = 0