I am trying to grow a database using the following the code below. However I get the following error. How do I check for size (3600MB) and grow it if necessary?
USING MyDatabase ALTER DATABASE MyDatabase MODIFY FILE (NAME = MyDatabase_data, SIZE = 3600MB)
Error: MODIFY FILE failed. Specified size is less than or equal to current size.
UPDATE: I am not using Auto Grow due to the heavy traffic. Due to the setup I have here (long unrelated story) I need to make the change using code. However, if this code runs more than once I get the error described above. I need to check the size first before attempting the change again.
The size of the DB will be shown by
looking at the code for sp_spaceused (I happen to be looking at a SQL 2000 server, but same/similar would be true for SQL2005 / SQL2008)
and the relevant code is:
so from that you could save the size to a variable and compare again the size you were trying to set: