• I created a stored procedure you can use.

    Sample data:

    use tempdb;

    IF OBJECT_ID('tempdb.dbo.demo') IS NOT NULL DROP TABLE dbo.demo;

    CREATE TABLE dbo.demo (col1 varchar(1000), col2 varchar(1000));

    WITH tally(n) AS (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM sys.all_columns)

    INSERT INTO dbo.demo

    SELECTCAST(REPLICATE(NEWID(),20) AS varchar(1000)),

    CAST(REPLICATE(NEWID(),10) AS varchar(1000))

    FROM tally WHERE n<=1000;

    The stored proc:

    USE tempdb --I'm using by tempdb, pick another db and update the proc accordingly

    GO

    CREATE PROC dbo.sp_spaceused2

    (@table varchar(100),-- the table you want to examine

    @cols varchar(1000))-- the columns

    --(acceptable values: single value, multiple values seperated by comma, or "*")

    AS

    BEGIN

    DECLARE @sql varchar(4000)='SELECT '+@cols+' INTO dbo.table_column FROM '+@table;

    IF OBJECT_ID('tempdb..table_column') IS NOT NULL DROP TABLE tempdb..table_column;

    EXEC(@sql);

    EXEC sp_spaceused 'tempdb.dbo.table_column';

    END

    Examples:

    EXEC dbo.sp_spaceused2 'dbo.demo','col1' --col1 only

    EXEC dbo.sp_spaceused2 'dbo.demo','col2' --col2 only

    EXEC dbo.sp_spaceused2 'dbo.demo','col1,col2' --col1 and col2

    EXEC dbo.sp_spaceused2 'dbo.demo','*' --all columns (same as sp_spaceused)

    I through this together real quick; make sure to test.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001