Call now: (800) 766-1884  


 SQL Server Tips
 SQL Server Training

 SQL Server Consulting
 SQL Server Support
 SQL Server Remote DBA

 SQL Server Scripts
 Scripts Menu




  SQL Server Tips by Gama and Naughter


This XP_PLAYSOUNDFILE XP allows a specific wave file on the file system to be played. Internally it uses the “PlaySound” SDK function. To play a wave file using this function, we use the “SND_FILENAME” flag in the call to the “PlaySound” function. This XP takes 3 parameters. The first parameter is the filename of the wave file to play. The second parameter, which is optional, is a Boolean flag that specifies if the sound should be played synchronously or not. If this flag is true, then the XP will not return until the sound file has completed playing. This internally will correspond to the SND_SYNC flag that gets passed to the “PlaySound” function. If this parameter is not specified then the sound is played asynchronously. This means that playing of the sound file is queued and the XP function returns immediately before the sound has completed playing. The third and last parameter to this XP specifies if the sound file should be played continuously in a loop. Playing of the sound will only stop when the XP_STOPSOUND XP is called (or another sound is played).


This function is quite similar to the XP_PLAYSOUNDFILE XP except that instead of playing a specific file, it plays a sound as specified in the Sound control panel applet. This list of Sound aliases varies from machine to machine depending on the applications installed and version of the operating system. To specify that you want to play a sound alias, you use the “SND_ALIAS” flag instead of “SND_FILENAME” when calling the “PlaySound” function. Assuming you have a “Windows Logon” sound notification setup in the control panel, you could then use the following TSQL code to play this sound:

EXEC master..XP_PLAYSOUNDALIAS 'WindowsLogon', 0, 0

As with XP_PLAYSOUNDFILE, this XP takes an additional 2 optional parameters, which specifies if the sound should be played synchronously and if the sound should be played continuously.

The above book excerpt is from:

Super SQL Server Systems
Turbocharge Database Performance with C++ External Procedures

ISBN: 0-9761573-2-2
Joseph Gama, P. J. Naughter  


Burleson Consulting Remote DB Administration







Burleson is the America's Team

Note: The pages on this site were created as a support and training reference for use by our staff of DBA consultants.  If you find it confusing, please exit this page.

Errata?  SQL Server technology is changing and we strive to update our SQL Server support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:and include the URL for the page.

Burleson Consulting
SQL Server database support


Copyright © 1996 -  2013 by Vaaltech Web Services. All rights reserved.

Hit Counter