Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem specifying file when creating db through osql

Status
Not open for further replies.

gny

Programmer
Jun 3, 2001
116
SE
I'm trying to create a new db, specifying the FILENAME. This works great, except i need to do it through osql. When I do, SQL Server seems to ignore the FILENAME and creates the db in the default data folder.
Does anyone have any ideas?

Code:
SET @sSql = 	'CREATE DATABASE ' +
				+ @sDB_Namn + '
			ON
			(
				NAME = ' + @sDB_Namn + ',
				FILENAME=''' + @sPath + '\' + @sDbFileName + '''
			)
			LOG ON
			(
				NAME = ' + @sDB_Namn + '_Log,
				FILENAME=''' + @sPath + '\' + @sLogFileName + '''
			)'
	PRINT @sSql
	SET @sCommand = 'isql -U ' + @sPriviligedLogin + ' -P ' + @sPriviligedPassword + ' -Q "' + @sSql + '"'
	EXEC master..xp_cmdshell @sCommand
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top