SQL Server DB Table space

  • Hi friends,

    declare @path varchar(1000)

    declare @Reslt varchar(2000)

    declare @find varchar(2000)

    set @path = 'D:\tablespace'+'_'+ convert(char(8),getdate(),112) +'.xls'

    begin

    exec @Reslt = sp_LargestTables

    set @find = 'echo '+ @Reslt + ' >>'+ @path

    exec master..xp_cmdshell @find

    end

    The above script working fine , and when executed this script

    xls file also created, but main problem is output not storing xls file.

    Stored procedure to find table space for particular database

    sp result like Table name,rowcount and size(KB)

    Please give me correct one. thanks

  • Your exec returns a single value, not a result set.

    You probably want to run this from SQLCMD or another client utility, not xp_cmdshell.

  • You can try Excel's "Get External data" feature to retrive the data into excel sheet.

    1) Open an excel sheet

    2) Go to "Data" menu

    3) Go to "Import External data" menu

    4) Click "Import Data" option

  • hi thushar,

    Actualy what i want, this table script procdure retun value like

    Table name,how much rows and total size of table, so i could get 3 result set.

    The above script i want execute the in jobs every 1 day. so after that result has been stored in 3 colum in xls sheet. so tell me how to data stored in xls sheet when jobs completed.

  • hi jones,

    please tell me how to execute script in sqlcmd, thaks

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply