删除 T

编程入门 行业动态 更新时间:2024-10-25 03:24:57
本文介绍了删除 T-SQL 中的非数字字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在使用函数 sp_spaceused 来获取数据库中所有表的详细信息.index_size 列是 VARCHAR 返回完整的KB",但我想以 MB 显示.我只需要知道如何去除 KB,剩下的我可以做!:D

I'm using the function sp_spaceused to get the details of all the tables in a DB. The index_size column is VARCHAR returned complete with ' KB' on the end, however I want to to display in MB. All I need to know is how to strip out the KB, I can do the rest! :D

更新:我不认为这与建议的另一个问题重复,因为我正在寻找该线程中给出的仅 SQL 解决方案.

UPDATE: I don't feel this is a duplicate of the other question suggested as I was looking for a SQL only solution, which was given in this thread.

推荐答案

REPLACE(column, 'KB', '').不需要 LEN 和其他东西

REPLACE(column, 'KB', ''). No need for LEN and other stuff

在 SQL 2005 上,这将为您提供保留"值:

On SQL 2005, this will give you the "reserved" value:

SELECT
    SUM(au.total_pages) / 128.0 AS UsedMB
FROM
    sys.allocation_units au

更多的调查应该允许您从目录视图中读取索引与数据空间

Some more investigation should allow you to read index vs data space out of the catlog views too

这篇关于删除 T-SQL 中的非数字字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-28 07:24:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1169711.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!