• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
敬YES
Now Or Never
博客园    首页       联系   管理    订阅  订阅
2009年10月12日
SQL:改变数据库所有者为dbo:
摘要: declare tb cursor local forselect 'sp_changeobjectowner ''['+replace(user_name(uid),']',']]')+'].['+replace(name,']',']]')+']'',''dbo'''from sysobjects where xtype in('U','V','P','TR','FN','IF','TF') ... 阅读全文
posted @ 2009-10-12 15:40 敬YES 阅读(373) 评论(0) 推荐(0)
SQL:清空数据库所有数据
摘要: 使用游标逐个清空表declare tempCursor cursor forselect name from sysobjects where type='U'--获取数据库中所有表名:‘U’表示用户表open tempCursordeclare @tbName varchar(50)fetch next from tempCursorinto @tbNamewhile @@fetch_status=0begin exec('truncate table '+ @tbName )fetch next from tempCursorinto @tbNameend close tempCursor 阅读全文
posted @ 2009-10-12 15:38 敬YES 阅读(2171) 评论(3) 推荐(0)
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3