Showing posts with label setup. Show all posts
Showing posts with label setup. Show all posts

Monday, March 19, 2012

CREATE RULE for a Default Type

Hi all,
Using: SQL Server 2000 SP3A Enterprise Edition
I have setup a table that holds application information. One of the fields
holds the Applications Version Information.
I have created a default type called Version of nvarchar and length 43.
Version information is made up of 2, 3 or 4 parts, Major, Minor, Build and
Revision (Major.Minor[.Build[.Revision]]). Each part can hold up to 10 digits
up to 2,147,483,647 (int without comas). That makes 4 blocks of 10 plus up t
o
3 seperators (being the .) makes 43 the max length.
What I want to do is create a rule that will only allow a valid version
number to be stored in the field. I had something like this:
@.value LIKE '[0-9].[0-9]' OR @.value LIKE '[0-9].[0-9].[0-9]' OR @.value LIKE
'[0-9].[0-9].[0-9].[0-9]'
This will not allow 1.10.8903.56 as [0-9] specifies single characters only.
Is there quick way to do the validation as a rule without having to type
loads of LIKE statements for every possibility?Use a CHECK constraint rather than a RULE. Rules and user-defined types
are supported for backwards compatibility. Constraints are more much
easier to maintain and code.
In this case I think you'll find it easier to exclude the values you
don't want:
CREATE TABLE YourTable
(... , version VARCHAR(43) NOT NULL
CHECK (version NOT LIKE '[^.0-9]'
AND (version LIKE '%.%'
OR version LIKE '%.%.%'
OR version LIKE '%.%.%.%')))
David Portas
SQL Server MVP
--|||Oops. That should be:
CREATE TABLE YourTable
(version NVARCHAR(43) NOT NULL
CHECK (version NOT LIKE '%[^.0-9]%'
AND (version LIKE '%.%'
OR version LIKE '%.%.%'
OR version LIKE '%.%.%.%')))
David Portas
SQL Server MVP
--|||Hi,
Thanks for quick response to my question!
All working okay now!
Just 1 other question! Why use a Check instead of a Rule? I was using the
rule on the default type to save me typing the Check for every field as I
have many tables that contain this Version type field. Your code works both
as a Check and Rule.
Cheers
Paul|||Yes it will work as a Check and a Rule. User-defined types, defaults
and rules are designated as backwards compatibility features so they
won't necessarily be fully supported in future versions of SQL Server.
Books Online recommends using the ANSI/ISO standard alternatives, CHECK
and DEFAULT constraints, instead.
User-defined types are difficult to maintain because of the convoluted
syntax and binding - you have to remove all references and unbind
before you can make a change - a big problem if your type is used in
many columns. Constraints are declarative, unbound and much more
flexible.
CHECK constraints can also be used by the optimizer (although that's
unlikely to be useful with the constraint used here). I don't think the
optimizer can take advantage of Rules, although I confess I don't
recall where I've seen that documented so someone may correct me on
that point.
Finally, I suspect fewer SQL Server professionals will continue to use
and remember the old syntax in future so those who inherit your code
will probably be more productive if they don't have to cope with the
legacy stuff.
I think those are enough reasons not to use User-defined Types and
Rules. You want to save yourself some typing? Just cut-and-Paste the
CHECK constraint in Query Analyzer - that's no more work than pasting
the name of a user-defined type.
David Portas
SQL Server MVP
--|||Hi,
Thanks again for your information, very useful.
I have updated to use Check instead of Rule, was just trying to do the easy
way but as you pointed out sometimes the easy way can become problamatic in
the future.
Cheers again for your help.
Paul|||If you use a datamodeling tool (I use ERwin) you probably can do much the
same thing in the model, but generating them out as CHECK constraints. They
have domains that you can use in the model but only generate them as CHECKS.
Not sure if other tools have this, but it is a really feature of ERwin.
----
Louis Davidson - drsql@.hotmail.com
SQL Server MVP
Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design -
http://www.apress.com/book/bookDisplay.html?bID=266
Blog - http://spaces.msn.com/members/drsql/
Note: Please reply to the newsgroups only unless you are interested in
consulting services. All other replies may be ignored :)
"Dr. Paul Caesar - CoullByte (UK) Limited"
< DrPaulCaesarCoullByteUKLimited@.discussio
ns.microsoft.com> wrote in message
news:667A4E1E-64D2-4030-A25E-399B07E3C9B8@.microsoft.com...
> Hi,
> Thanks again for your information, very useful.
> I have updated to use Check instead of Rule, was just trying to do the
> easy
> way but as you pointed out sometimes the easy way can become problamatic
> in
> the future.
> Cheers again for your help.
>
> Paul

Thursday, March 8, 2012

create new sql server instance

is possible to create new sql server instance without using the setup disk?
No.
A new istance is a full install and then you need to apply the appropriate
SP to the instance.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Oren101" wrote:

> is possible to create new sql server instance without using the setup disk?
|||No, that won′t work.
"Oren101" wrote:

> is possible to create new sql server instance without using the setup disk?
|||Hi,
No.
New SQL Server instance is totally independant of exiting SQL Server. So you
need to use the SETUP program to install.
But you could create multiple databases in existing instance.
Thanks
Hari
SQL Server MVP
"Oren101" <Oren101@.discussions.microsoft.com> wrote in message
news:E9AEA272-5D78-4D66-974D-273CF5990E70@.microsoft.com...
> is possible to create new sql server instance without using the setup
> disk?

create new sql server instance

is possible to create new sql server instance without using the setup disk?No.
A new istance is a full install and then you need to apply the appropriate
SP to the instance.
Regards
--
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Oren101" wrote:
[vbcol=seagreen]
> is possible to create new sql server instance without using the setup disk?[/vbcol
]|||No, that won′t work.
"Oren101" wrote:
[vbcol=seagreen]
> is possible to create new sql server instance without using the setup disk?[/vbcol
]|||Hi,
No.
New SQL Server instance is totally independant of exiting SQL Server. So you
need to use the SETUP program to install.
But you could create multiple databases in existing instance.
Thanks
Hari
SQL Server MVP
"Oren101" <Oren101@.discussions.microsoft.com> wrote in message
news:E9AEA272-5D78-4D66-974D-273CF5990E70@.microsoft.com...
> is possible to create new sql server instance without using the setup
> disk?

create new sql server instance

is possible to create new sql server instance without using the setup disk?No.
A new istance is a full install and then you need to apply the appropriate
SP to the instance.
Regards
--
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Oren101" wrote:
> is possible to create new sql server instance without using the setup disk?|||No, that won´t work.
"Oren101" wrote:
> is possible to create new sql server instance without using the setup disk?|||Hi,
No.
New SQL Server instance is totally independant of exiting SQL Server. So you
need to use the SETUP program to install.
But you could create multiple databases in existing instance.
Thanks
Hari
SQL Server MVP
"Oren101" <Oren101@.discussions.microsoft.com> wrote in message
news:E9AEA272-5D78-4D66-974D-273CF5990E70@.microsoft.com...
> is possible to create new sql server instance without using the setup
> disk?

Wednesday, March 7, 2012

Create Multi-server environment in the SQL 2005- need HELP

I tried to setup a master-target server for the multi-server
environment
I tried the step in the microsoft support page already, but I keep
getting stucked with Create master wizard's third and fourth step.
This is my scenario: I have computer A and B connected in my network.
All of the SQLServer and SQL Agent in both machines uses a windows
authentications.
Both machines can communicate well already.
So, in the Create Master Server Wizard at Computer A I do:
-> Next
-> Next (leave all values blank for the email, pager and net send
address)
-> Add Connection to Computer B with windows authentication
-> Check compatibility success (meaning that the login successful as
well), then close
-> I check the "create a new login if necessary and assign it rights to
the MSX", then next
-> Finish
In the 3rd step: "Ensure the agent startup account for 'Computer B' has
rights to login as a target server", I got this error message:
===================================================================================== TITLE: Microsoft.SqlServer.Smo
--
Create failed for Login '.\TargetAdmin'.
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Login&LinkId=20476
--
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or
batch. (Microsoft.SqlServer.ConnectionInfo)
--
Windows NT user or group '.\TargetAdmin' not found. Check the name
again. (Microsoft SQL Server, Error: 15401)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=15401&LinkId=20476
--
BUTTONS:
OK
--
==========================================================================================================
In the fourth step: "Enlist 'Computer B' to 'Computer A', I got this
error message:
========================================================================================================== TITLE: Microsoft.SqlServer.Smo
--
MSX enlist failed for JobServer '155.64.154.169'.
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=MSX+enlist+JobServer&LinkId=20476
--
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or
batch. (Microsoft.SqlServer.ConnectionInfo)
--
The enlist operation failed (reason: SQLServerAgent Error: Unable to
connect to MSX 'SYMANTEC-6VBB5C'.) (Microsoft SQL Server, Error: 22026)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=22026&LinkId=20476
--
BUTTONS:
OK
--
==========================================================================================================
Need help deperately >,<Are your servers domain members?
It looks like you have a problem with login from one server to other.
Accordint to the error messge '.\TargetAdmin' is a local account.
"ipramono@.gmail.com" wrote:
> I tried to setup a master-target server for the multi-server
> environment
> I tried the step in the microsoft support page already, but I keep
> getting stucked with Create master wizard's third and fourth step.
> This is my scenario: I have computer A and B connected in my network.
> All of the SQLServer and SQL Agent in both machines uses a windows
> authentications.
> Both machines can communicate well already.
> So, in the Create Master Server Wizard at Computer A I do:
> -> Next
> -> Next (leave all values blank for the email, pager and net send
> address)
> -> Add Connection to Computer B with windows authentication
> -> Check compatibility success (meaning that the login successful as
> well), then close
> -> I check the "create a new login if necessary and assign it rights to
> the MSX", then next
> -> Finish
> In the 3rd step: "Ensure the agent startup account for 'Computer B' has
> rights to login as a target server", I got this error message:
> =====================================================================================> TITLE: Microsoft.SqlServer.Smo
> --
> Create failed for Login '.\TargetAdmin'.
> For help, click:
> http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Login&LinkId=20476
> --
> ADDITIONAL INFORMATION:
> An exception occurred while executing a Transact-SQL statement or
> batch. (Microsoft.SqlServer.ConnectionInfo)
> --
> Windows NT user or group '.\TargetAdmin' not found. Check the name
> again. (Microsoft SQL Server, Error: 15401)
> For help, click:
> http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=15401&LinkId=20476
> --
> BUTTONS:
> OK
> --
> ==========================================================================================================> In the fourth step: "Enlist 'Computer B' to 'Computer A', I got this
> error message:
> ==========================================================================================================> TITLE: Microsoft.SqlServer.Smo
> --
> MSX enlist failed for JobServer '155.64.154.169'.
> For help, click:
> http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=MSX+enlist+JobServer&LinkId=20476
> --
> ADDITIONAL INFORMATION:
> An exception occurred while executing a Transact-SQL statement or
> batch. (Microsoft.SqlServer.ConnectionInfo)
> --
> The enlist operation failed (reason: SQLServerAgent Error: Unable to
> connect to MSX 'SYMANTEC-6VBB5C'.) (Microsoft SQL Server, Error: 22026)
> For help, click:
> http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=22026&LinkId=20476
> --
> BUTTONS:
> OK
> --
> ==========================================================================================================> Need help deperately >,<
>

Create Multi-server environment in the SQL 2005- need HELP

I tried to setup a master-target server for the multi-server
environment
I tried the step in the microsoft support page already, but I keep
getting stucked with Create master wizard's third and fourth step.
This is my scenario: I have computer A and B connected in my network.
All of the SQLServer and SQL Agent in both machines uses a windows
authentications.
Both machines can communicate well already.
So, in the Create Master Server Wizard at Computer A I do:
-> Next
-> Next (leave all values blank for the email, pager and net send
address)
-> Add Connection to Computer B with windows authentication
-> Check compatibility success (meaning that the login successful as
well), then close
-> I check the "create a new login if necessary and assign it rights to
the MSX", then next
-> Finish
In the 3rd step: "Ensure the agent startup account for 'Computer B' has
rights to login as a target server", I got this error message:
========================================
====================================
=========
TITLE: Microsoft.SqlServer.Smo
--
Create failed for Login '.\TargetAdmin'.
For help, click:
http://go.microsoft.com/fwlink?Prod...in&LinkId=20476
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or
batch. (Microsoft.SqlServer.ConnectionInfo)
Windows NT user or group '.\TargetAdmin' not found. Check the name
again. (Microsoft SQL Server, Error: 15401)
For help, click:
http://go.microsoft.com/fwlink?Prod...01&LinkId=20476
BUTTONS:
OK
--
========================================
====================================
==============================
In the fourth step: "Enlist 'Computer B' to 'Computer A', I got this
error message:
========================================
====================================
==============================
TITLE: Microsoft.SqlServer.Smo
--
MSX enlist failed for JobServer '155.64.154.169'.
For help, click:
http://go.microsoft.com/fwlink?Prod...er&LinkId=20476
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or
batch. (Microsoft.SqlServer.ConnectionInfo)
The enlist operation failed (reason: SQLServerAgent Error: Unable to
connect to MSX 'SYMANTEC-6VBB5C'.) (Microsoft SQL Server, Error: 22026)
For help, click:
http://go.microsoft.com/fwlink?Prod...26&LinkId=20476
BUTTONS:
OK
--
========================================
====================================
==============================
Need help deperately >,<Are your servers domain members?
It looks like you have a problem with login from one server to other.
Accordint to the error messge '.\TargetAdmin' is a local account.
"ipramono@.gmail.com" wrote:

> I tried to setup a master-target server for the multi-server
> environment
> I tried the step in the microsoft support page already, but I keep
> getting stucked with Create master wizard's third and fourth step.
> This is my scenario: I have computer A and B connected in my network.
> All of the SQLServer and SQL Agent in both machines uses a windows
> authentications.
> Both machines can communicate well already.
> So, in the Create Master Server Wizard at Computer A I do:
> -> Next
> -> Next (leave all values blank for the email, pager and net send
> address)
> -> Add Connection to Computer B with windows authentication
> -> Check compatibility success (meaning that the login successful as
> well), then close
> -> I check the "create a new login if necessary and assign it rights to
> the MSX", then next
> -> Finish
> In the 3rd step: "Ensure the agent startup account for 'Computer B' has
> rights to login as a target server", I got this error message:
> ========================================
==================================
===========
> TITLE: Microsoft.SqlServer.Smo
> --
> Create failed for Login '.\TargetAdmin'.
> For help, click:
> http://go.microsoft.com/fwlink?Prod...in&LinkId=20476
> --
> ADDITIONAL INFORMATION:
> An exception occurred while executing a Transact-SQL statement or
> batch. (Microsoft.SqlServer.ConnectionInfo)
> --
> Windows NT user or group '.\TargetAdmin' not found. Check the name
> again. (Microsoft SQL Server, Error: 15401)
> For help, click:
> http://go.microsoft.com/fwlink?Prod...01&LinkId=20476
> --
> BUTTONS:
> OK
> --
> ========================================
==================================
================================
> In the fourth step: "Enlist 'Computer B' to 'Computer A', I got this
> error message:
> ========================================
==================================
================================
> TITLE: Microsoft.SqlServer.Smo
> --
> MSX enlist failed for JobServer '155.64.154.169'.
> For help, click:
> http://go.microsoft.com/fwlink?Prod...er&LinkId=20476
> --
> ADDITIONAL INFORMATION:
> An exception occurred while executing a Transact-SQL statement or
> batch. (Microsoft.SqlServer.ConnectionInfo)
> --
> The enlist operation failed (reason: SQLServerAgent Error: Unable to
> connect to MSX 'SYMANTEC-6VBB5C'.) (Microsoft SQL Server, Error: 22026)
> For help, click:
> http://go.microsoft.com/fwlink?Prod...26&LinkId=20476
> --
> BUTTONS:
> OK
> --
> ========================================
==================================
================================
> Need help deperately >,<
>

Tuesday, February 14, 2012

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.