Shrink my .mdf file in SQL Server? I have a 10 GB .mdf file with 250 mb .LDF.

I want to shrink the 10 GB .mdf (if possible)

I read about the dbcc command, but I read it in context of shrinking the .LDF (into any size desired using truncate).

However I want to shrink the .MDF file without loosing data.

What is the precise command for it ?
Simply answer:

DBCC SHRINKFILE('DB filename', 10240)


OR for MDF file

DBCC SHRINKFILE(1, 10240)


But if you have more than 10240 Mb of data in MDF file - it woun't help, then you have to add extra file to DB - where to move extra data from MDF file.

From BOL:


  DBCC SHRINKFILE 
  
  Shrinks the size of the specified data or log file for the current database or empties a file by moving the data from the specified file
  to other files in the same filegroup, allowing the file to be removed
  from the database. You can shrink a file to a size that is less than
  the size specified when it was created. This resets the minimum file
  size to the new value.


How to know filenames in DB:

SELECT file_Id, name FROM sys.database_files


Shrinking data files always affects performance - it makes it worse, so you really need to have a REASON to do that.