Showing posts with label express. Show all posts
Showing posts with label express. Show all posts

Thursday, March 29, 2012

CREATE TABLE template, Management Studio Express

I accidentally overwrote the CREATE TABLE template in SQL Server Management Studio Express. Could someone please post the original template?

FYISmile

-- =========================================
-- Create table template
-- =========================================
USE <database, sysname, AdventureWorks>
GO

IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_table>', 'U') IS NOT NULL
DROP TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table>
GO

CREATE TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table>
(
<columns_in_primary_key, , c1> <column1_datatype, , int> <column1_nullability,, NOT NULL>,
<column2_name, sysname, c2> <column2_datatype, , char(10)> <column2_nullability,, NULL>,
<column3_name, sysname, c3> <column3_datatype, , datetime> <column3_nullability,, NULL>,
CONSTRAINT <contraint_name, sysname, PK_sample_table> PRIMARY KEY (<columns_in_primary_key, , c1>)
)
GO

CREATE TABLE Template

I accidentally altered the CREATE TABLE template from SQL Server Management Studio Express. Now I don't have the original. Could somebody please post CREATE TABLE template.

-- =========================================

-- Create table template

-- =========================================

USE <database, sysname, AdventureWorks>

GO

IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_table>', 'U') IS NOT NULL

DROP TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table>

GO

CREATE TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table>

(

<columns_in_primary_key, , c1> <column1_datatype, , int> <column1_nullability,, NOT NULL>,

<column2_name, sysname, c2> <column2_datatype, , char(10)> <column2_nullability,, NULL>,

<column3_name, sysname, c3> <column3_datatype, , datetime> <column3_nullability,, NULL>,

CONSTRAINT <contraint_name, sysname, PK_sample_table> PRIMARY KEY (<columns_in_primary_key, , c1>)

)

GO

|||

Or the simplified version:

Create Table MyTable(FirstField varchar(50), SecondField int)

or...

when in doubt >> Right Click in Management Studio to create a new table manually

Adamus

|||

Thanks, joeydj,

johncelmer

sql

Tuesday, March 27, 2012

create table permission denied

Hi,

i run an asp.net application which uses sql server express.
i defined a login 'aspnet' (IIS 5.0) and for the specific database, an user
'aspnet' with following roles:
db_datareader and db_datawriter.

Now, any user who uses that application must also be able to create
programmatically tables in that database. My question is: which role do i
have to give to user 'aspnet'?

I use Studio Management express.

Thanks
Tartuffe

The answer depends on which version of SQL Server you are using, since SQL Server 2005 dramatically enhanced permissions in the database. Which version?

Also, must the user be able to create ANY table in the database, or only a specific table? I think the former, but please confirm.

Don

|||

Hi, thanks for replying.

I use sql server 2005 express with Studio Management express.

Each windows-account in the domain in our organization who starts the application creates automatically (in code-behnd) a table with his personal (unique) number in the organization (e.g. L0564).

This happens only the first time he starts the application. So each member has his own table.

We use IIS 5.1, so the account which runs under asp.net is ASPNET. For another application, i defined a login in Studio Management and then for the database of that application, i defined a user 'aspnet' with following roles: db_reader and db_writer (i didn't use schema's because it's not very clear to me ..). This works, but there was no need to cerate a table.

I did the same for this new application +I db_owner and then it works. But i think it's probably too many privileges ... So: my question is: which privileges to give to 'aspnet' and how to do that in Studio Management?

Thanks

|||

You need the dbowner... only then you will be able to do the specific operations like creating tables and other things. DBWrite and Read will allow you to do simple updates insert and deletes.

|||

Thanks. I'll try.

If you don't mind, .. what if the ASPNET account must also be able to create databases? Is it suffisant with db_owner only?

|||

Yes i think so .. it doesn't matter which account it is .. till the time you map correct roles

|||

i tried with db_owner and Aspnet can create tables programmatically.

But Aspnet cannot create a new database with only db_owner.

|||

you need to be sysadmin for thatSurprise

|||

Thanks

sql

Sunday, March 25, 2012

Create table

Hi,
How would I create a table programmatically in a database. I am using C#
2005 Express edition.
For example I want to create a table named tblHours in a database
dbEmployees with the columns hours worked (integer), hourly pay (currency),
etc...
TIA
Roy
How about looking up "create table" in BOL?
ms-help://MS.SQLCC.v9/MS.SQLMobile.v3.en/SSMProg3/html/143cad25-5c1d-4c96-bd8b-6a95dbfb1b00.htm
Mike
Mentor
Solid Quality Learning
http://www.solidqualitylearning.com
"Roy Gourgi" <royng@.videotron.ca> wrote in message
news:5rEuf.56416$DQ4.1492398@.weber.videotron.net.. .
> Hi,
> How would I create a table programmatically in a database. I am using C#
> 2005 Express edition.
> For example I want to create a table named tblHours in a database
> dbEmployees with the columns hours worked (integer), hourly pay
> (currency),
> etc...
>
> TIA
> Roy
>
>

Create table

Hi,
How would I create a table programmatically in a database. I am using C#
2005 Express edition.
For example I want to create a table named tblHours in a database
dbEmployees with the columns hours worked (integer), hourly pay (currency),
etc...
TIA
Roy>> create a table programmatically in a database.. <<
You do not do that at all. First, you write a data model of your real
world, then you implement in a schema. Your real world does not change
on the fly. If the model needs to add, alter or remove tables , you do
it with other tools, such as QA. Never in a front end program.
You might also want stop putting silly prefixes in front of data
element names (see ISO-11179).|||What do you mean "programatically?" If you mean permanently then you need
to get the Management Studio Express from
(http://msdn.microsoft.com/sql/express/)
If you mean you want to formulate a table based on some input (hopefully for
temporary usage) you just simply formulate a CREATE TABLE statement and
execute it in ADO.NET. Do you know how to execute a SQL Statement?
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"Roy Gourgi" <royng@.videotron.ca> wrote in message
news:snEuf.56318$DQ4.1489316@.weber.videotron.net...
> Hi,
> How would I create a table programmatically in a database. I am using C#
> 2005 Express edition.
> For example I want to create a table named tblHours in a database
> dbEmployees with the columns hours worked (integer), hourly pay
> (currency), etc...
>
> TIA
> Roy
>|||What's wrong with prefixes? If you have dozens or hundreds of tables and
views, it is useful to distinguish them at a glance in stored procedure for
example.
Peter|||Nothing, the guy doesn't understand the term KISS (Keep It Simple Sweet).
Table prefixes are useful for segmenting code, personally, i don't use tbl_
type prefixes, but i do use vw_ because if and when I use views in code I
can quickly see that I am using a view in a query and then can more quickly
understand that there is further logic underneath that might be causing a
performance problem.
I prefix stored procedures using logical segmentation, for instance
events_sel; research_sel etc... groups objects together in the database to
make life (and development/maintanence) easier.
Tony.
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"Rogas69" <rogas69@.no_spamers.o2.ie> wrote in message
news:%23ZSEWRSEGHA.916@.TK2MSFTNGP10.phx.gbl...
> What's wrong with prefixes? If you have dozens or hundreds of tables and
> views, it is useful to distinguish them at a glance in stored procedure
> for example.
> Peter
>|||"Tony Rogerson" <tonyrogerson@.sqlserverfaq.com>:
news:eGy3wlTEGHA.3200@.tk2msftngp13.phx.gbl...
> Nothing, the guy doesn't understand the term KISS (Keep It Simple Sweet).
> Table prefixes are useful for segmenting code, personally, i don't use
> tbl_ type prefixes, but i do use vw_ because if and when I use views in
> code I can quickly see that I am using a view in a query and then can more
> quickly understand that there is further logic underneath that might be
> causing a performance problem.
> I prefix stored procedures using logical segmentation, for instance
> events_sel; research_sel etc... groups objects together in the database to
> make life (and development/maintanence) easier.
> Tony.
> --
> Tony Rogerson
> SQL Server MVP
> http://sqlserverfaq.com - free video tutorials
>
> "Rogas69" <rogas69@.no_spamers.o2.ie> wrote in message
> news:%23ZSEWRSEGHA.916@.TK2MSFTNGP10.phx.gbl...
>
This is something newer
For me KISS stands for "keep it simple, stupid"
--
Andrey Odegov
avodeGOV@.yandex.ru
(remove GOV to respond)|||Celko has strong opinions and rarely is gentle with his advice (look past
that for some good advice much of the time, but as with all advice, there
are plenty of opinions.)
Personally, I don't like any type based prefixes on anything :) I do
something like this with stored procedures, functions etc (seperated by a $
(dollar sign) like table$action or purchaseOrder$delete, or something along
these lines.
On programming objects, I don't think either way is a big deal. I don't
prefix stuff with an indication if it is a procedure or a view, etc., but
either way is fine. I do feel that prefixes on tables, views and columns
look bad because the user is often presented these names, and they don't
need to know which are tables and which are views, and a programmer can tell
based on context. And since I always look at lists of objects in the
context of what they are:
select table_schema, table_name, table_type
from information_schema.tables
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"Rogas69" <rogas69@.no_spamers.o2.ie> wrote in message
news:%23ZSEWRSEGHA.916@.TK2MSFTNGP10.phx.gbl...
> What's wrong with prefixes? If you have dozens or hundreds of tables and
> views, it is useful to distinguish them at a glance in stored procedure
> for example.
> Peter
>

Create table

Hi,
How would I create a table programmatically in a database. I am using C#
2005 Express edition.
For example I want to create a table named tblHours in a database
dbEmployees with the columns hours worked (integer), hourly pay (currency),
etc...
TIA
RoyHow about looking up "create table" in BOL?
ms-help://MS.SQLCC.v9/MS.SQLMobile.v3.en/SSMProg3/html/143cad25-5c1d-4c96-bd8b-6a95dbfb1b00.htm
--
Mike
Mentor
Solid Quality Learning
http://www.solidqualitylearning.com
"Roy Gourgi" <royng@.videotron.ca> wrote in message
news:5rEuf.56416$DQ4.1492398@.weber.videotron.net...
> Hi,
> How would I create a table programmatically in a database. I am using C#
> 2005 Express edition.
> For example I want to create a table named tblHours in a database
> dbEmployees with the columns hours worked (integer), hourly pay
> (currency),
> etc...
>
> TIA
> Roy
>
>

Create table

Hi,
How would I create a table programmatically in a database. I am using C#
2005 Express edition.
For example I want to create a table named tblHours in a database
dbEmployees with the columns hours worked (integer), hourly pay (currency),
etc...
TIA
RoyHow about looking up "create table" in BOL?
ms-help://MS.SQLCC.v9/MS.SQLMobile.v3.en/SSMProg3/html/143cad25-5c1d-4c96-bd
8b-6a95dbfb1b00.htm
Mike
Mentor
Solid Quality Learning
http://www.solidqualitylearning.com
"Roy Gourgi" <royng@.videotron.ca> wrote in message
news:5rEuf.56416$DQ4.1492398@.weber.videotron.net...
> Hi,
> How would I create a table programmatically in a database. I am using C#
> 2005 Express edition.
> For example I want to create a table named tblHours in a database
> dbEmployees with the columns hours worked (integer), hourly pay
> (currency),
> etc...
>
> TIA
> Roy
>
>

Wednesday, March 21, 2012

Create SQL Server developer version database in app_data folder

Hi

I am trying to create a sql server database in the app_data folder of visual studio 2005. It keeps telling me I need the express version. Can I not use the developer version

Thanks

By default installation, SQL Server 2005 Developer version stores its databases' files in places like this (in my computer):C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data

The express version can save a data file in app_data folder to work with visual studio 2005 or VWD. You need different connection strings to access your database.

Here is a sample section of connection strings in a web.config file to access databases (developer version):

<connectionStrings>

<addname="MSDN_forumConnectionString"connectionString="Data Source=localhost;Initial Catalog=MSDN_forum;Integrated Security=True"

providerName="System.Data.SqlClient" />

<addname="NorthwindConnectionString"connectionString="Data Source=(local);Initial Catalog=Northwind;Integrated Security=True"

providerName="System.Data.SqlClient" />

</connectionStrings>

|||

Hi

Thankyou for your response. I have no problem connecting to a sql server deveoper version . The problem I have is when I right click app_data foler and add new item & choose databse I get the following error

Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly.

I dont want to use the Express version but the developer version. Hope this make it a bit more clear

Thanks

|||

Hi,

Just as Limno said, if you want to create your database in app_data folder of Visual Studio 2005, you have to install the SQL Server Express edition because other editions of SQL Server does not support attaching database files automatically at runtime.

Thanks.

|||

Many thanks for your answer. I have now installed sql server express

Create SQL database with C#

Hi,

I am trying to:
1. Create a SQL database (I am working with SQL 2005 Express)
2. with a C# code
3. when the user is not the computer administrator.

I have managed to create the database file (code below). I am not sure
it is the right way.
Can you take a look please?
I would like to either create a password for these database or a
special user so only my
software will be able to control it (change data). How do I do that?

tmpConn.ConnectionString = "Data Source=(local); DATABASE =
master;Integrated Security=True; user instance=true";
sqlCreateDBQuery = " CREATE DATABASE " + DBParam.DatabaseName +
" ON
PRIMARY "
+ " (NAME = " +
DBParam.DataFileName +", "
+ " FILENAME = '" +
DBParam.DataPathName +"', "
+ " SIZE = 5MB,"
+ " FILEGROWTH =" +
DBParam.DataFileGrowth +") "
+ " LOG ON (NAME =" +
DBParam.LogFileName +", "
+ " FILENAME = '" +
DBParam.LogPathName + "', "
+ " SIZE = 1MB, "
+ " FILEGROWTH =" +
DBParam.LogFileGrowth +") ";
SqlCommand myCommand = new SqlCommand(sqlCreateDBQuery, tmpConn);
try
{
tmpConn.Open();
MessageBox.Show(sqlCreateDBQuery);
myCommand.ExecuteNonQuery();
MessageBox.Show("Database has been created successfully!",
"Create
Database", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString(), "Create Database",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
finally
{
tmpConn.Close();
}orenbt78 (orenbt78@.googlemail.com) writes:

Quote:

Originally Posted by

I have managed to create the database file (code below). I am not sure
it is the right way.
Can you take a look please?


I guess that if the database gets created that it works. The only thing
to consider is maybe the initial sizes. 5 MB is a quite small database.
Then again, I don't really know what you will put into it.

Quote:

Originally Posted by

I would like to either create a password for these database or a
special user so only my
software will be able to control it (change data). How do I do that?


You could use an application role. You add users to the database without
any privileges, and then the application users sp_setapprole to set the
application role, to which you have granted all necessary rights.
To activate the application role, you need a password.

But note that this does not prevent users from side-stepping your tool,
it just makes it more difficult. If you give users the password, they
can use sp_setapprole from Mgmt Studio. If you don't give them the
password, you need to hide in the application, in which case be found
for anyone who wants. Or the connection can eavesdropped. (The password
can obfusticated on the wire, but that does not help.)

And in any case, anyone can just copy the database files and attach
them on a server where they have admin rights and do whatever you want
with it.

So while you cannot prevent this, the application role can still serve
the purpose to tell people to keep out, or the warranty will be voided.
But this latter is something you also include in a license agreement.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Monday, March 19, 2012

Create reports with SQL Express

Is it possible to create reports with Sql Express edition i.e. like you can with SQL full edition? If not are there any other add on free tools that allow you to do this?

Thanks

See this link here for the SQL Server toolkit:

http://msdn2.microsoft.com/en-us/library/ms365166.aspx


Jens K. Suessmeyer.

http://www.sqlserver2005.de

Sunday, March 11, 2012

Create Package in SQL Server Management Studio Express?

Our server currently has the following components installed for SQL Server 2005: 1. SQL Server Management Studio Express and 2. Configuration Tools (SQL Server Configuration Manager, SQL Server Error and Usage Reporting, and SQL Server Service Area Configuration).

Is there a way to setup a package using the software currently installed (if not, what needs to be installed in order to setup a package)?

I'm looking to schedule running an executible, it was fairly easy with SQL Server 2000 (using DTS), but I'm unsure how to set this up using the software we currently have installed.

It looks like you are using SQL Sever 2005 express?

Sorry but SSIS doesn't come with express, you'll need Standard edition or better:

see the section, "Integration and Interoperability":

http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx

|||P.S. Installing standard edition tools seems to do the trick (be sure to install Integration Services).

Thursday, March 8, 2012

Create new database in SQL Server 2005 Express Edition

Hello,

I use the SQL Server 2005 Express Edition. I want to create a new database, but I cant find where and how.
Can anyone provide me with starter's tips and/or a good tutorial?

Thanks!

If you're using the VS 2005, then simply right-click on your Project (from Solution Explorer), Add New Item, and choose Sql Database.|||Or if you don't have a project yet, you can do it from within the server explorer as well.|||

I use Visual Web Developer Express 2005. With this I was also able to create a new database.
I can add tables, views etc.
But no triggers...do you guys have an idea how I can add a new trigger?!??

Create new database by the help of app_data folder without sql server express

I am using sql server 2005 developer edition with service pack 1
I have uninstalled sql express.
How Could I create new database by the help of app_data folder without sql server express.
That is when i right click on app_data folder and try to make a new database it give me the following error.

Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL: http://go.microsoft.com/fwlink/?LinkId=49251

I don't want's to install sql server express and want's the functinality of creating a new database via App_Data folder.What Can do ?

You could do as the error message suggests, and install SQL Server Express 2005 or just not create a SQL Server Express database at all. Error messages don't lie (at least not most of the time).

Ryan

|||

In the interest of helping me through my learning curve, I think I understand the problem. Let me try to explain it, in the hope that if I'm wrong, someone can further enlighten me:

1. SQL Server is intended for 'Enterprise' use, complete with full security and all of the stuff that goes with Enterprise usage. All databases must be attached to an SQL Server instance and are subject to all of the controls that are imposed by that instance. You would use the Server Explorer or the management tools that come with SQL server to set up the database and make sure that it was attached to the server.

2. SQL Express is intended for small environments. Although it is similar to SQL Server, it is not subject to the same controls, nor can it support the same high volume usage. It is intended for use in a development environment, where an individual database can then be ported to SQL Server and for small applications that do not require an 'Enterprise' database solution. When you right click and create the database, you are actually creating a database that is not attached to an SQL Server instance. If you do this, then run SSME (the management tool for SQL Express), the database that you created is not displayed, unless you attach it.

They are different products for different purposes. It might be worth asking Microsoft to add functionality to create a database in SQL Server using the same type of process, but there are a lot of issues that go with that. Those issues do not exist in the typical SQL Express environment.

Hope this helps, and if I have made an error, hopefully someone will correct it, since I am still going through the learning curve - and it's a really steep one.

Regards,

Flavelle

Friday, February 17, 2012

Create database within SSIS package

I want to create a package that imports data from a Visual Foxpro database to SQL Server 2005 Express database. I used the wizard in BI Development Studio (similar to the DTS in SQL Server 2000) to create a package and noticed that the SQL statements created in the Preparation SQL Task only has code for creating tables. I want to make the package such that it first creates the destination database before creating all the related tables in it! When I tried to edit the SQL code to include DROP DATABASE and/or CREATE DATABASE statements, these were rejected.

Is it possible to do this or do I have to first create the database outside the package and then call the package? I want to make this a seamless process for clients who do not have the know-how of SQL Server database administration.

HELP!!!!!!

Can't you just run a CREATE DATABASE DDL statement in a execute sql task?

|||

Peter K wrote:

Can't you just run a CREATE DATABASE DDL statement in a execute sql task?

yes. i'm afraid that the import/export wizard won't be sufficient to solve this problem.

CREATE DATABASE permission denied in database ''master''. (Microsoft SQL Server, Error: 262)

How exactly do I correct this problem on Vista?

TITLE: Microsoft SQL Server Management Studio Express

Create failed for Database 'kkl'. (Microsoft.SqlServer.Express.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Database&LinkId=20476

ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)

CREATE DATABASE permission denied in database 'master'. (Microsoft SQL Server, Error: 262)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=262&LinkId=20476

I have ensured that I am logged into the system as Admin but cannot find where on the Server, I assign my login to the dbcreator group.

I have gone into Security >> Server Roles >> dbcreator. of which I am not a member. On a different system, where all works, however, I am not a member of this group either.

Any suggestions on how to kill this one?

Thanks in Advance.

Klaus

and this fixed my problem:

http://msdn2.microsoft.com/en-us/library/bb326612.aspx

Tuesday, February 14, 2012

Create Database on a Virtual Drive (Created with subst) Failed

When I try to add a (SQL Server 2005 Express Edition) database to my project (I'v tried a windows application and an ASP.NET application) in Visual Studio 2005 Professional Edition; It fails with an error like this :
"create database failed. some file names listed could not be created (...)"
but when I open the project from the real path It works.
Is this a bug? Is there any solution? (In many situations there is a need for working with virtual drives. There must be some work around ...)

Thanks

SQL Server does not recognize OS level 'mapped' drives.

You must use a 'actual' drive, or a SAN/NAS lun(drive).

Create database in SQL Server 2005 and Attaching it in SQL Express

Hi,

I've created a database in sql server 2005, but now I need to detach this database and attach it in sql express. Is this possible? I keep getting an error that my database is readonly. Any help would be greatly appreciated.

thanks in advance.

Yes, it is possible.

Sometimes, when the database file is detached, the OS changes the file permissions.

Using Windows Explorer, check the file properties, and remove the Read Only checkmark if one is present. Then re-attach.

|||

or you can use Backup/Restore method. Restore the database with MOVe option. Check Restore syntax in BOL

Madhu

Create database from code

Hi, I want to create a database setup on a server. I've scripted my database from sql server express. I've tested the code in the query window and it worked. When i pasted the same code in a sqlcommand command text...the debuger threw an sql exception...saying the sintax is wrong near keywords GO, USE, some forgein keys, and so on. Here is a chunk of the script.

USE [master]
GO
/****** Object: Database [estate_management] Script Date: 09/13/2006 09:19:32 ******/
CREATE DATABASE [estate_management] ON PRIMARY
( NAME = N'estate_management', FILENAME = N'D:\MSSQL\estate_management.mdf' , SIZE = 2048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'estate_management_log', FILENAME = N'D:\MSSQL\estate_management_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
COLLATE SQL_Latin1_General_CP1_CI_AS

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[admin]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[admin](
[admin_id] [int] IDENTITY(1,1) NOT NULL,
[log_in_id] [varchar](20) NOT NULL,
[password] [varchar](50) NOT NULL,
CONSTRAINT [PK__admin__07020F21] PRIMARY KEY CLUSTERED
(
[admin_id] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, FILLFACTOR = 1) ON [PRIMARY],
CONSTRAINT [IX_admin] UNIQUE NONCLUSTERED
(
[admin_id] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END

Thanks for your time.

You'd better set the database file size to larger value, to host a copy of the model database. Except this, your script works fine when I tested it under sqlcmd, both on SQL2000 and SQL2005 the database can be created successfully.