Showing posts with label ive. Show all posts
Showing posts with label ive. Show all posts

Wednesday, March 28, 2012

How to Connect to SQL Server 2005 enterprise version

I've just installed sql server 2005 enterprise on my Windows XP Professional
SP2 machine.
I can't find a way to connect with it.
I'm totaly new to SQL Server and have installed it to learn about it.
I can' t even find out if it is running or not.
When I do a
c:>netstat -a
I can't find the port number 1433 in the list.
I've checked the services but can't find the name there
Thanks in advance,
Willy
This may help. It's a new tutorial I wrote for the coming web release of
Books Online.
Getting Started with the Database Engine
Welcome to the Getting Started with the Database Engine tutorial. This
tutorial is intended for users who are new to SQL Server 2005 and who have
installed Developer, Express, or Evaluation Edition on a computer running
Windows XP Professional Service Pack 1 (SP1).This brief tutorial helps you
get started using the Database Engine.
What You Will Learn
This tutorial shows you how to connect to the Database Engine using SQL
Server Management Studio or Management Studio Express, on both the local
computer and from another computer.
This tutorial is divided into two lessons:
Lesson 1: Connecting to the Database Engine
In this lesson, you will learn how to connect to the Database Engine and
enable additional people to connect.
Lesson 2: Connecting from Another Computer
In this lesson, you will learn how to connect to the Database Engine from a
second computer, including enabling protocols, configuring ports, and
configuring firewall settings.
Requirements
This lesson has no knowledge prerequisites.
Your system must have the following installed to use this tutorial:
a.. Internet Explorer 6.0 or later.
b.. Either SQL Server Management Studio or Management Studio Express.
Lesson 1: Connecting to the Database Engine
When you install the SQL Server 2005 Database Engine, the tools that are
installed depend upon the edition and your setup choices. This lesson
reviews the principal tools, and shows you how to connect and perform a
basic function (authorizing more users).
This lesson contains the following topics:
a.. Tools for Getting Started
b.. Connecting with Management Studio
c.. Authorizing Additional Connections
Tools for Getting Started
The SQL Server 2005 Database Engine ships with a variety of tools. This
topic describes the first tools you will need, and helps you select the
right tool for the job. All tools can be accessed from the Start menu.
Generally, tools such as SQL Server Management Studio are not installed by
default. You must select the tools as part of the client components during
setup. For complete description of the tools described below, search for
them in Books Online. SQL Server 2005 Express Edition contains only a subset
of the tools.
Basic Tools
a.. SQL Server Management Studio is the principal tool for administering
the Database Engine and writing Transact-SQL code. It is hosted in the
Visual Studio shell. It is not included in SQL Server 2005 Express Edition
or SQL Server 2005 Mobile Edition.
b.. SQL Server Management Studio Express is a free, limited version of SQL
Server Management Studio, intended for use with SQL Server 2005 Express
Edition and for users who want the basic features of Management Studio in a
lightweight tool.
c.. SQL Server Surface Area Configuration installs with SQL Server and
lets you enable the server protocols, configure services to start
automatically, and enable some optional features of the Database Engine.
d.. SQL Server Configuration Manager installs with both SQL Server and the
client tools. It lets you enable server protocols, configure protocol
options such as TCP ports, configure server services to start automatically,
and configure client computers to connect in your preferred manner.
Sample Database
SQL Server 2005 includes a sample database called AdventureWorks. This
database is not installed by default. If you wish to experiment with the
AdventureWorks database, you must select it using the Setup program. Most
examples described in Books Online use the AdventureWorks database. For more
information, see Running Setup to Install AdventureWorks Sample Databases
and Samples.
To start SQL Server Management Studio
1. On the Start menu, point to All Programs, point to Microsoft SQL
Server 2005, and then click SQL Server Management Studio.
To start SQL Server Surface Area Configuration or SQL Server Configuration
Manager
1. On the Start menu, point to All Programs, point to Microsoft SQL
Server 2005, point to Configuration Tools, and then click either SQL Server
Surface Area Configuration or SQL Server Configuration Manager.
Connecting with Management Studio
It is easy to connect to the Database Engine from tools running on the same
computer if you know the name of the instance, and if you are connecting as
a member of the Administrators group on the computer. The following
procedures must be performed on the same computer that hosts SQL Server.
To determine the name of the Database Engine instance
1. Log into Windows as a member of the Administrators group, and open
either Management Studio or Management Studio Express Edition.
The Connect to Server dialog box opens.
2. Click Cancel.
3. If Registered Servers is not displayed, on the View menu, click
Registered Servers.
4. With Database Engine selected on the Registered Servers toolbar,
right-click Database Engine, and then click Update Local Server
Registration. All instances of the Database Engine installed on the computer
are displayed. This includes instances of SQL Server 2000. Management Studio
can connect and manage instances of SQL Server 2000 as well as SQL Server
2005. The default instance is unnamed and is shown as the computer name. A
named instance displays as the computer name followed by a backward slash
(\) and then the name of the instance. For SQL Server 2005 Express Edition,
the instance is named <computer_name>\sqlexpress unless the name was changed
during setup.
To verify that the Database Engine is running
1. In Registered Servers, if the name of your instance of SQL Server
has a green dot with a white arrow next to the name, the Database Engine is
running and no further action is necessary.
2. If the name of your instance of SQL Server has a red dot with a
white square next to the name, the Database Engine is stopped. Right-click
the name of the Database Engine, and then click Start. After a confirmation
dialog box, the Database Engine should start and the circle should turn
green.
To connect to the Database Engine
1. On the File menu, click Connect Object Explorer.
The Connect to Server dialog box opens. The Server type box displays the
type that was last used.
2. Select Database Engine.
3. In the Server name box, type the name of the Database Engine
instance.
4. Click Connect.
Authorizing Additional Connections
Now that you have connected to SQL Server as an administrator, one of your
first tasks is to authorize other users to connect. You do this by creating
a login and authorizing that login to access a database as a user. Logins
can be either Windows Authentication logins, which use your Windows
credentials, or SQL Server Authentication logins, which store the
authentication information in SQL Server and are independent of your network
credentials. Use Windows Authentication whenever possible.
Create a Windows Authentication login
1. In the previous task, you connected to the Database Engine using
Management Studio. In Object Explorer, expand your server instance, expand
Security, right-click Logins, and then click New Login.
The Login - New dialog box appears.
2. On the General page, in the Login name box, type a Windows login in
the format <domain>\<login>.
3. In the Default database box, select AdventureWorks if available.
Otherwise select master.
4. On the Server Roles page, if the new login is to be an
administrator, click sysadmin, otherwise leave this blank.
5. On the User Mapping page, select Map for the AdventureWorks
database if it is available. Otherwise select master. Note that the User box
is populated with the login. When closed, the dialog box will create this
user in the database.
6. In the Default Schema box, type dbo to map the login to the
database administrator schema.
7. Accept the default settings for the Securables and Status boxes and
click OK to create the login.
Note:
This is basic information to get you started. SQL Server provides a
rich security environment, and security is obviously an important aspect of
database operations. For more information about security, read the security
sections of Books Online, starting with Security Considerations for
Databases and Database Applications.
Lesson 2: Connecting from Another Computer
To enhance security, the Database Engine of SQL Server 2005 Developer,
Express, and Evaluation Editions cannot be accessed from another computer
when initially installed. This lesson shows you how to enable the protocols,
configure the ports, and configure the Windows Firewall for connecting from
other computers.
This lesson contains the following topics:
a.. Enabling Protocols
b.. Configuring a Fixed Port
c.. Opening Ports in the Firewall
d.. Connecting to the Database Engine from Another Computer
e.. Connecting Using the SQL Server Browser Service
Enabling Protocols
To enhance security, SQL Server 2005 Express Edition Developer Edition and
Evaluation Edition install with only limited network connectivity.
Connections to the Database Engine can be made from tools running the same
computer, but not from other computers. If you are planning to do your
development work on the same computer as the Database Engine, you're done.
Management Studio or Management Studio Express Edition will connect to the
Database Engine using the shared memory protocol, which is already enabled.
If you plan to connect to the Database Engine from another computer, you
must enable a protocol, such as TCP/IP.
How to enable TCP/IP connections from another computer
1. Start SQL Server Surface Area Configuration, and click Surface Area
Configuration for Services.
2. In the Surface Area Configuration for Services and Connections box,
the View by Instance box lists the instances of the Database Engine
installed on the computer. The default instance (an unnamed instance) is
listed as MSSQLSERVER. If you installed a named instance, the name you
provided is listed. SQL Server 2005 Express Edition installs as SQLEXPRESS
unless you changed the name during setup. In the View by Instance box,
expand the instance you wish to configure, expand Database Engine, and then
click Remote Connections.
3. Click Local and remote connections, click Using TCP/IP only, then
click OK and close the tool.
Configuring a Fixed Port
To enhance security, Windows XP Professional Service Pack 2 (SP2) turns on
the Windows Firewall. When SQL Server 2005 Developer, Express, or Evaluation
Edition is running on Windows XP Professional, and you wish to connect to it
from another computer, you must open a communication port in the firewall.
The default instance of the Database Engine listens on port 1433, so you do
not need to configure a fixed port, but named instances including SQL Server
2005 Express Edition listen on dynamic ports. Before you can open a port in
the firewall, you must first configure the Database Engine to listen on a
specific port; otherwise the Database Engine may listen on a different port
each time it is started.
Configure SQL Server to listen on a specific port
1. In SQL Server Configuration Manager, expand SQL Server 2005 Network
Configuration, and then click on the server instance you wish to configure.
2. In the right pane, double-click TCP/IP.
3. In the TCP/IP Properties dialog box, click the IP Addresses tab.
4. In the TCP Port box of the IPAll section, type an available port
number. For this tutorial, we will use 1500.
5. Click OK to close the dialog box, and click OK to the warning that
the service must be restarted.
6. In the left pane, click SQL Server 2005 Services.
7. In the right pane, right-click the instance of SQL Server, and then
click Restart. When the Database Engine restarts, it will listen on port
1500.
Opening Ports in the Firewall
Firewall systems prevent unauthorized access to computer resources. To
enhance security, Windows XP Professional Service Pack 2 (SP2) turns on
Windows Firewall. To connect to SQL Server from another computer, you must
open a port in the firewall.
Important:
Opening ports in your firewall can leave your server exposed to
malicious attacks. Be sure to understand firewall systems before opening
ports. For more information, see Security Considerations for a SQL Server
Installation.
After configuring the Database Engine to use a fixed port, follow the
following instructions to open that port in your Windows Firewall. (You do
not need to configure a fixed port for the default instance, because it is
already fixed on port 1433.)
To open a port in Windows Firewall
1. On the Start menu, click Control Panel.
2. In Control Panel, click Network and Internet Connections, and then
open Windows Firewall.
3. In Windows Firewall, click the Exceptions tab, and then click Add
Port.
4. In the Add a Port dialog box, in the Name box, type SQL Server
<instanceName>.
5. In the Port number box, type the port number of the Database Engine
instance. Use 1433 for the default instance. Type 1500 if you are
configuring a named instance and configured a fixed port in the previous
task. Verify that TCP is selected, and then click OK.
Connecting to the Database Engine from Another Computer
Now that you have configured the Database Engine to listen on a fixed port,
and have opened that port in the firewall, you can connect to SQL Server
from another computer.
When the SQL Server Browser service is running on the server computer, and
when the firewall has opened UDP port 1434, the connection can be made using
the computer name and instance name. To enhance security, our example does
not use the SQL Server Browser service.
To connect to the Database Engine from another computer
1. On a second computer containing the SQL Server 2005 client tools,
log in with an account authorized to connect to SQL Server, and open
Management Studio.
2. In the Connect to Server dialog box, confirm Database Engine in the
Server type box.
3. In the Server name box, type tcp: to specify the protocol, followed
by the computer name, a comma, and the port number. To connect to the
default instance, the port 1433 is implied and can be omitted, so type
tcp:<computer_name>. In our example for a named instance, type
tcp:<computer_name>,1500.
4. In the Authentication box, confirm Window Authentication, and then
click Connect.
Connecting Using the SQL Server Browser Service
The SQL Server Browser service listens for incoming requests for SQL Server
resources and provides information about SQL Server instances installed on
the computer. When the SQL Server Browser service is running, users can
connect to named instances by providing the computer name and instance name,
instead of the computer name and port number. Because SQL Server Browser
receives unauthenticated UDP requests, it is not always turned on during
setup. For a description of the service and an explanation of when it is
turned on, see SQL Server Browser Service.
To use the SQL Server Browser, you must follow the same steps as the
previous task in this lesson, and open UDP port 1434.
This concludes this brief tutorial on basic connectivity. For more
information about configuring server and client connectivity, see Database
Engine Connectivity How-to Topics.
Rick Byham
MCDBA, MCSE, MCSA
Lead Technical Writer,
Microsoft, SQL Server Books Online
This posting is provided "as is" with
no warranties, and confers no rights.
"Willy Verbiest" <willy.verbiest@.telenetnospam.be> wrote in message
news:Oo4ff.51028$Uj3.2801801@.phobos.telenet-ops.be...
> I've just installed sql server 2005 enterprise on my Windows XP
> Professional SP2 machine.
> I can't find a way to connect with it.
> I'm totaly new to SQL Server and have installed it to learn about it.
> I can' t even find out if it is running or not.
> When I do a
> c:>netstat -a
> I can't find the port number 1433 in the list.
> I've checked the services but can't find the name there
> Thanks in advance,
> Willy
>

Monday, March 19, 2012

how to configure SQL server 2000 Agent Mail to use outlook express

Hi,
I've read with SP3, SQL Agent Mail can be set up to use outlook express to
send out job notifications. On our SQL server 2000, I logged on as the
service account which runs both SQL server and SQL server agent. I was able
to send mail manually from outlook express. But how should I make SQL Agent
use outlook express? I've searched google but was not able to find any step
by step instruction on that. I checked the properties of SQL Server Agent.
Under the General tab, the Mail session is grayed out. I think that's
correct because outlook express doesn't have a profile. No other mail
configurations are available.
I'd appreciate if anybody can shed some light or provide some pointers.
Thanks,
Bing
Outlook Express does not provide the MAPI interface necessary for SQL Mail
and SQL Agent Mail. Only Outlook provides that functionality.
Personally, I do not use the built-in mail components. I use
xp_smtp_endmail from www.sqldev.net. XP_smtp_sendmail is a smtp connector
for SQL. It is not a drop-in replacement, but with a little scripting, you
an duplicate the functionality without the instability and headaches of the
MAPI-based built-in components.
Note that SQL 2005 uses its own SMTP connector called Database Mail.
Geoff N. Hiten
Senior Database Administrator
Microsoft SQL Server MVP
"bing" <bing@.discussions.microsoft.com> wrote in message
news:875C2067-DAF3-47B0-9A0A-C0DDA5636D4B@.microsoft.com...
> Hi,
> I've read with SP3, SQL Agent Mail can be set up to use outlook express to
> send out job notifications. On our SQL server 2000, I logged on as the
> service account which runs both SQL server and SQL server agent. I was
> able
> to send mail manually from outlook express. But how should I make SQL
> Agent
> use outlook express? I've searched google but was not able to find any
> step
> by step instruction on that. I checked the properties of SQL Server
> Agent.
> Under the General tab, the Mail session is grayed out. I think that's
> correct because outlook express doesn't have a profile. No other mail
> configurations are available.
> I'd appreciate if anybody can shed some light or provide some pointers.
> Thanks,
> Bing
|||Thanks much for the response. I haven't done any stored procedure scripting
in SQL server 2000 environment. I'll check how the scripts you mentioned
work. On this SQL 2000 server, outlook is not installed.
Bing
"Geoff N. Hiten" wrote:

> Outlook Express does not provide the MAPI interface necessary for SQL Mail
> and SQL Agent Mail. Only Outlook provides that functionality.
> Personally, I do not use the built-in mail components. I use
> xp_smtp_endmail from www.sqldev.net. XP_smtp_sendmail is a smtp connector
> for SQL. It is not a drop-in replacement, but with a little scripting, you
> an duplicate the functionality without the instability and headaches of the
> MAPI-based built-in components.
> Note that SQL 2005 uses its own SMTP connector called Database Mail.
> --
> Geoff N. Hiten
> Senior Database Administrator
> Microsoft SQL Server MVP
>
>
> "bing" <bing@.discussions.microsoft.com> wrote in message
> news:875C2067-DAF3-47B0-9A0A-C0DDA5636D4B@.microsoft.com...
>

Friday, March 9, 2012

How to compare values in different rows?

Hi


I’ve a table like this (in SQL Server 2000).

v1 v2
2 8
7 10
11 15

13 17

v1 value of a row must be grater than v2 value of previous row, other wise I need to display that row, in above example, I need to display 2nd & 4th rows.

please advise

Thanks

In order to best get this to work you need another row to explicitly sequence the data -- such as ROW_ID or something. The otherwise, you can use Transact SQL extensions, but without an explicit sequence of some kind, the results will be volatile / unpredictable. It would probably be best to avoid the extensions and stick to a CTE here if you can.

Code Snippet

declare @.ex table(id int, v1 int, v2 int)
insert @.ex
select 1, 2, 8 union all
select 2, 7, 10 union all
select 3, 11,15 union all
select 4, 13,17
--select * from @.ex

select a.id, a.v1, a.v2
from @.ex a
join @.ex b
on a.id - 1 = b.id
and a.v1 <= b.v2

/*
id v1 v2
-- -- --
2 7 10
4 13 17
*/

|||

Do you have a field in the table that will indicate what is the 'previous row'? (Something like an IDENTITY field, or datetime of entry, etc.)

|||

The Table is

ID v1 v2
1 2 8
2 7 10
3 11 15

4 13 17

|||

Here it is,

Code Snippet

Create Table #data (

[ID] INT ,

[v1] INT ,

[v2] INT

);

Insert Into #data Values('1','2','8');

Insert Into #data Values('2','7','10');

Insert Into #data Values('3','11','15');

Insert Into #data Values('4','13','17');

Select

Down.*

from

#data Up

Join #data down On Up.Id = Down.Id-1

Where

Up.V2>=down.V1

|||

As long as you have that ID field, you can use the query

Code Snippet

CREATE TABLE prevRowTest (

ID INT,

v1 INT,

v2 INT

)

INSERT INTO prevRowTest VALUES (1,2,8)

INSERT INTO prevRowTest VALUES (2,7,10)

INSERT INTO prevRowTest VALUES (3,11,15)

INSERT INTO prevRowTest VALUES (4,13,17)

SELECT prt.ID, prt.v1, prt.v2

FROM prevRowTest prt JOIN

prevRowTest prev ON prt.id = (prev.ID + 1)

WHERE prt.v1 <= prev.v2

|||

Thanks a lot.

I got my Answer

With Regards

Vijay

Friday, February 24, 2012

how to combine text data rows into single row?

Hi!!!!

Need some quick help on SQL.....DTS packages.

I’ve loaded data from text files into a table which is in the following format.....

Seq_No

Row_No

Data

1

1

ABC

2

2

DEF

3

3

GHI

4

4

JKL

5

1

MNO

6

2

PQR

7

3

STU

8

4

VWX

Every four lines correspond to one single logical record. So, all the data in every 4 rows have to be combined into one big string which’ll then be loaded into one col of another temporary table .....structure below.....

Record_No

Data

1

ABCDEFGHIJKL

2

MNOPQRSTUVWX

I’m looking for a way to achieve this WITHOUT using Cursors (as it’ll slow down performance)......

Any suggestions will be highly appreciated.

what data type is the Data column?|||

One way is to use the CLR Aggregate function for string concatenation shown in the BOL

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

and then run a query like this

select ((Seq_No-1) / 4)+1 as Record_No, dbo.Concatenate(Data) as Data
into dest
from source
group by ((Seq_No-1) / 4)+1
go

select * from dest
go

|||

hi pramy,

please refer to this post

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=586833&SiteID=1

regards

|||

hi Derek,

thanks for ur reply. the data type is of varchar.

|||

pramy, you still need help on this issue? if not please mark an answer.

thanks,

derek

|||

hi all,

thanks for ur response.

Derek, i've got the solution for my problem and the query is as given below.

select 'data' = convert(varchar(100),(a.data)+''+(b.data)+''+(c.data)+''+(d.data))

from test_data a,test_data b,test_data c,test_data d

where ((b.seqno=a.seqno+1 and b.rowno=a.rowno+1)and(c.seqno=b.seqno+1 and c.rowno=b.rowno+1)and(d.seqno=c.seqno+1 and d.rowno=c.rowno+1))

how to combine text data rows into single row?

Hi!!!!

Need some quick help on SQL.....DTS packages.

I’ve loaded data from text files into a table which is in the following format.....

Seq_No

Row_No

Data

1

1

ABC

2

2

DEF

3

3

GHI

4

4

JKL

5

1

MNO

6

2

PQR

7

3

STU

8

4

VWX

Every four lines correspond to one single logical record. So, all the data in every 4 rows have to be combined into one big string which’ll then be loaded into one col of another temporary table .....structure below.....

Record_No

Data

1

ABCDEFGHIJKL

2

MNOPQRSTUVWX

I’m looking for a way to achieve this WITHOUT using Cursors (as it’ll slow down performance)......

Any suggestions will be highly appreciated.

what data type is the Data column?|||

One way is to use the CLR Aggregate function for string concatenation shown in the BOL

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

and then run a query like this

select ((Seq_No-1) / 4)+1 as Record_No, dbo.Concatenate(Data) as Data
into dest
from source
group by ((Seq_No-1) / 4)+1
go

select * from dest
go

|||

hi pramy,

please refer to this post

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=586833&SiteID=1

regards

|||

hi Derek,

thanks for ur reply. the data type is of varchar.

|||

pramy, you still need help on this issue? if not please mark an answer.

thanks,

derek

|||

hi all,

thanks for ur response.

Derek, i've got the solution for my problem and the query is as given below.

select 'data' = convert(varchar(100),(a.data)+''+(b.data)+''+(c.data)+''+(d.data))

from test_data a,test_data b,test_data c,test_data d

where ((b.seqno=a.seqno+1 and b.rowno=a.rowno+1)and(c.seqno=b.seqno+1 and c.rowno=b.rowno+1)and(d.seqno=c.seqno+1 and d.rowno=c.rowno+1))