Saturday, February 25, 2012

Creating a database

When creating a database using OSQL -E -I CreateDatabase.sql
I have the following in my input file:
CREATE TABLE admin
(
ID char(7),
Pwd varchar(32)
)
GO
How could I make it so that Pwd does not allow nulls and has a default value
of 'Password'?
hi Terry,
Terry Olsen wrote:
> When creating a database using OSQL -E -I CreateDatabase.sql
> I have the following in my input file:
> CREATE TABLE admin
> (
> ID char(7),
> Pwd varchar(32)
> )
> GO
> How could I make it so that Pwd does not allow nulls and has a
> default value of 'Password'?
SET NOCOUNT ON
USE tempdb
CREATE TABLE dbo.Admin (
ID varchar(7) NOT NULL ,
Pwd varchar(32) NOT NULL DEFAULT 'Password'
)
INSERT INTO dbo.Admin VALUES ('Andrea' , DEFAULT )
SELECT * FROM dbo.Admin
DROP TABLE dbo.Admin
--<--
ID Pwd
-- --
Andrea Password
please have a look at
http://msdn.microsoft.com/library/de...eate2_8g9x.asp
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.12.0 - DbaMgr ver 0.58.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply

No comments:

Post a Comment