-1

I need to find a T-SQL query in SQL Server 2008 that will tell me how much disk space will be needed for a given dataset in tempdb BEFORE I actually run a select into statement with a given query in order to create a new table.

Example:

select * 
   into newtable 
from bighugetablewithlotsofjoins

So I need to know how much space will be needed by the data returned from bighugetablewithlotsofjoins before I create newtable

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
TuSabesTuSabes
  • 61
  • 1
  • 10
  • why? why do you need to know how much disk space is needed? It doesn't really make sense. DB systems should have ample storage anyway – Ahmed ilyas Feb 08 '14 at 13:45
  • Our volume of data is growing extremely fast and doing something like this would help us to do some tests – TuSabesTuSabes Feb 08 '14 at 13:53
  • I don't think you can get that information without actually running the query. –  Feb 08 '14 at 14:02
  • You should not be running a database on a volume that is running out of space. File fragmentation is not good for a a database. Get an SSD drive for #temp. – paparazzo Feb 08 '14 at 15:26

1 Answers1

0

run sp_spaceused yourtablename for each table in the join, then calculate the total space required for the worst case scenario (eg. if there are cartesians you'll have to multiply instead of adding)

Jayvee
  • 10,670
  • 3
  • 29
  • 40