It cannot be used in functions. getdate ()
For example:
Create Function Gettoday
(
)
Returns Datetime
As
Begin
Return Convert ( Char ( 10 ), Getdate (), 120 )
End
The following error is reported:
Server: Message 443, level 16, status 1, process gettoday, Row 7
The 'getdate' is incorrectly used in the function '.
No way. You can only use the parameter to bring in getdate () Create Function Gettoday
(
@ Now Datetime
)
Returns Datetime
As
Begin
Return Convert ( Char ( 10 ), @ Now , 120 )
End
We recommend that you obtain the table records of all tables and the SQL statements that use space.
Exec Sp_msforeachtable
@ Precommand = N '
Create Table ##(
Id int identity,
Table Name sysname,
Number of fields int,
Number of records int,
Reserved space nvarchar (10 ),
Use space varchar (10 ),
Index space varchar (10 ),
Unused space varchar (10 )) ' ,
@ Command1 = N ' Insert ## (Table Name, number of records, reserved space, used space, index space, unused space) exec sp_spaceused '' ? ''
Update ## set field COUNT = (select count (*) from syscolumns where id = object_id ( '' ? '' ) Where id = scope_identity () ' ,
@ Postcommand = N ' Select * from # order by ID drop table ## '