分享

Userful sql

 Jeln 2011-01-31

ch as a constraint, default, log, rule, and stored procedure.
select * from sys.sysobjects where name like '%tx_coupons_to_registrations%' and xtype = 'P'

--Contains a row for each object that is a SQL language-defined module. Objects of type P, RF, V, TR, FN, IF, TF, R, and D have an associated SQL module.
select top 10 * from sys.sql_modules where definition like '%tx_coupons_to_registrations%'

OPTION(MAXDOP 1) at the end of SELECT statement on production. This limits process on a single CPU, and process on other CPU's would not be affected in an event of heavy process is requested. 

E.g select top 1 * from [TABLE] OPTION(MAXDOP 1)

 

There is no need to add "WITH(NOLOCK)" to all the tables. Add "set transaction isolation level read uncommitted" to the top of the sql.

 

Delete statement:

DELETE FROM TABLE

FROM TABLE t WITH(NOLOCK)

JOIN TABLE1 t1 WITH(NOLOCK) on t.id=t1.id

 

 

 
 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多