tsql - Hidden Features of SQL Server -
what hidden features of sql server?
for example, undocumented system stored procedures, tricks things useful not documented enough?
answers
thanks great answers!
stored procedures
- sp_msforeachtable: runs command '?' replaced each table name (v6.5 , up)
- sp_msforeachdb: runs command '?' replaced each database name (v7 , up)
- sp_who2: sp_who, lot more info troubleshooting blocks (v7 , up)
- sp_helptext: if want code of stored procedure, view & udf
- sp_tables: return list of tables , views of database in scope.
- sp_stored_procedures: return list of stored procedures
- xp_sscanf: reads data string argument locations specified each format argument.
- xp_fixeddrives:: find fixed drive largest free space
- sp_help: if want know table structure, indexes , constraints of table. views , udfs. shortcut alt+f1
snippets
- returning rows in random order
- all database user objects last modified date
- return date only
- find records date falls somewhere inside current week.
- find records date occurred last week.
- returns date beginning of current week.
- returns date beginning of last week.
- see text of procedure has been deployed server
- drop connections database
- table checksum
- row checksum
- drop procedures in database
- re-map login ids correctly after restore
- call stored procedures insert statement
- find procedures keyword
- drop procedures in database
- query transaction log database programmatically.
functions
- hashbytes()
- encryptbykey
- pivot command
misc
- connection string extras
- tablediff.exe
- triggers logon events (new in service pack 2)
- boosting performance persisted-computed-columns (pcc).
- default_schema setting in sys.database_principles
- forced parameterization
- vardecimal storage format
- figuring out popular queries in seconds
- scalable shared databases
- table/stored procedure filter feature in sql management studio
- trace flags
- number after
go
repeats batch - security using schemas
- encryption using built in encryption functions, views , base tables triggers
in management studio, can put number after go end-of-batch marker cause batch repeated number of times:
print 'x' go 10
will print 'x' 10 times. can save tedious copy/pasting when doing repetitive stuff.
Comments
Post a Comment