Friday, July 31, 2009

Problem creating a simple Query with SQL Server 2005?

I am trying to create a simple database:





but it gives me an error while executing the query.





CREATE DATABASE ApressFinancial ON PRIMARY


( NAME = N'ApressFinancial',


FILENAME = N'C:\Program Files\Microsoft SQL


Server\MSSQL.1\MSSQL\DATA\ApressFinanc... , SIZE = 3072KB ,


MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )


LOG ON


( NAME = N'ApressFinancial_log',


FILENAME = N'C:\Program Files\Microsoft SQL


Server\MSSQL.1\MSSQL\DATA\ApressFinanc... ,


SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)


COLLATE SQL_Latin1_General_CP1_CI_AS


GO

















Msg 5133, Level 16, State 1, Line 1


Directory lookup for the file "C:\Program Files\Microsoft SQL


Server\MSSQL.1\MSSQL\DATA\ApressFinanc... failed with the operating system error 123(The filename, directory name, or volume label syntax is incorrect.).


Msg 1802, Level 16, State 1, Line 1


CREATE DATABASE failed. Some file names listed could not be created. Check related errors.





WHAT SHOULD I DO GUYS?

Problem creating a simple Query with SQL Server 2005?
You need to use a correct file name. The path you have there is not valid, which is exactly what the error message is telling you. you're asking it to create a file named "Apre..." and that's not a valid file name.





Why aren't you using the Management Studio to do this? Knowing the syntax is cool, but this is one thing I almost never do using SQL. I almost always create new databases used the GUI tools.





[Edit]


No, the file name is wrong. That's what the error message is telling you. It's possible that you have an unclosed quotation mark, or a missing comma, but if Yahoo is going to jack up the code, then there's no way to tell. The error message is telling you that the file system can't find the file (Directory lookup failed) and it's giving you additional information from the operating system, which said "The filename, directory name, or volume label syntax is incorrect."





That pretty much means what it says. The file can't be found because the path name is incorrect. This could be a permissions issue, but I doubt it. In that case, usually it gives a message saying something about permissions, but this is telling you it can't find the file. That's pretty clear, I think.





(This is not one of those cases where the error message is saying the wrong thing. It's telling you exactly what happened.)
Reply:CREATE DATABASE [ApressFinancial] ON PRIMARY


( NAME = N'ApressFinancial', FILENAME = N'G:\Temp\ApressFinancial.mdf' , SIZE = 3072KB , FILEGROWTH = 1024KB )


LOG ON


( NAME = N'ApressFinancial_log', FILENAME = N'G:\Temp\ApressFinancial_log.ldf' , SIZE = 2048KB , FILEGROWTH = 10%)


GO
Reply:Use Enterprise Manager to Create the Database.





**** NEW COMMENT IN REPLY ***


Make sure you are using the sa account and password. That account owns every object.


No comments:

Post a Comment