Showing posts with label contains. Show all posts
Showing posts with label contains. Show all posts

Wednesday, March 28, 2012

Query (count) question

I am somewhat new to SQL and I have a simple question (I think)... I have a field called results that contains several numbers seperated by columns, such as 3,6,16,22 etc.

I want to write a query that answers how many of each number occurs from the range.

Example:

Select (total) results where id = 6 and results = 16

so the query would have to search within the string results for all the records retrieved and count the instances

how would I do this?


I'd do the following. First you'll need a numbers table as in

http://sqlserver2000.databases.aspfaq.com/why-should-i-consider-using-an-auxiliary-numbers-table.html

now create a view on your table that splits out the numbers


create view SplitResults
as
select id,
cast(substring(results,
Number,
charindex(',',
results + ',',
Number) - Number) as int) as results
from MyTable
inner join Numbers on Number between 1 and len(results) + 1
and substring(',' + results, Number, 1) = ','
GO

Finally, run a query on the view to get your results


select count(*)
from SplitResults
where id=6 and results=16

|||Thanks, I new it was simple

Query - House and Persons

I've got a a table House and a table Person
A house is contains 1 or 2 persons
If a house contains 2 persons the first person must be the one
alphabetically smaller

It gives me this query :

select *
from Person as FirstPerson
join (select IDHouse,IDPerson,Name From Person) as SecondPerson on FirstPerson.IDHouse = Second.IDHouse
join (select IDFoyer,NumberOfPersons from House) as TheHouse on FirstPerson.IDFoyer = TheHouse.IDHouse
where
(TheHouse.NumberOfPersons = '2' and
(FirstPerson.Name < SecondPerson.Name and FirstPerson.IDPerson <> SecondPerson.IDPerson) or
(First.Name = SecondPerson.Name and FirstPerson.IDPerson > SecondPerson.IDPerson)) or
(TheHouse.NumberOfPersons = '1')

How can I can it better ?The result must be

FirstPerson.Name, SecondPerson.Name, TheHouse.IDHouse

one row for each House|||briing up mey thread|||select min(FirstPersons.Name) FirstPerson,
min(SecondPersons.Name) SecondPerson,
FirstPersons.HouseID
from Persons FirstPersons
left outer join Persons SecondPersons
on FirstPersons.IDHouse = SecondPersons.IDHouse
and SecondPersons.Name > FirstPersons.Name
group by FirstPersons.HouseID

You will need to link in the house table if you want to include houses with no people in them.

blindman|||What about this?

create table house(id int)
go
create table person(id int,houseid int,pname varchar(10))
go
insert house values(1)
insert house values(2)
insert house values(3)
insert person values(1,1,'a')
insert person values(2,1,'b')
insert person values(3,2,'c')
insert person values(4,3,'d')
insert person values(5,3,'e')
go

select (select top 1 pname from person where houseid=h.id order by pname) as fperson
,isnull((select top 1 pname from person where houseid=h.id
and id not in (select top 1 id from person where houseid=h.id order by pname)),'nobody') as sperson
,id
from house h|||Exactly. A "house" is a thing and a "person" is a thing and a "person" occupies no more than one "house."

You don't want a number_of_persons field in the "house" table nor do you want any field in that table named "occupant_id."

A more generalized schema would have a table such as occupancy which lists house_id and person_id to reflect a "many to many" relationship between people and houses. This would also allow you to reflect the history of occupancy as a person moves. The question is, what does your application require. Outside of college textbooks, there are no graven slabs of stone being handed down from any mountainside...|||I've been tricked, I've simplified too much the problem

I can't use (Select top 1), Group by or Min() because I have about 20 columns in the Select
But I've kept the idea of adding a clause on a Left Outer Join

Select First.LastName,First.FirstName,Second.ClientType,T heHouse.City,...
From Person as First
Left outer join (Select IDPerson,FirstName,LastName,IDHouse From Person) as Second
On First.IDHouse = Second.IDHouse and
(First.LastName + First.FirstName + First.IDPerson <
Second.LastName + Second.FirstName + Second.IDPerson)
Join (Select IDHouse,City,NbPersons From House) as TheHouse
On First.IDHouse = TheHouse.IDHouse
Where
(TheHouse.NbOfPersons = '2' and Second.IDPers is not null) Or
(TheHouse.NbOfPersons = '1')

But it seems that replacing the <Inner Join> by a <Left outer join>
to select the second person gives me slower stats

Why ?|||An inner join is faster, but wil exclude houses with only one resident.

blindman|||Will a composite index on
<LastName + FirstName + IDPerson>

be faster than separate indexes on those columns

?|||Of course it will!|||I've put an composite index on those columns but
the query doesn't seem to need or use it

When I look at the "plan" of the query there is no mention of
the composite index

I've created this index by selecting all three columns
and naming it VousConjoint

I this Ok and why there is no use of my index ?|||Of course it won't!

Placing a composite index on the LastName, FirstName, and IDPerson fields won't help because you are actually joining on the concatenated of these three strings. This is not a good idea, because not only is it slow and unable to take advantage of a composite index, but the sorting logic can give erroneous results if two people have similiar last names. For instance, someone named John Brown should come before someone name Abe Browning in an alphabetical sort by last name, but the reverse occurs when sorting on the concatenated strings "BrownJohn" and "BrowningAbe".

To be accurate you should sort and compare on the values separately.

blindman

P.S. Adding a comma between your concatenated fields may fix the problem in your logic:

Where (First.LastName + ',' + First.FirstName + ',' + First.IDPerson < Second.LastName + ',' + Second.FirstName + ',' + Second.IDPerson)|||Try this strategy:

Add a calculated field to your Persons table that concatenates your LastName + ',' + FirstName + ',' + PersonID, and then index that field. Then this query should get you the information you want:

select House.*, Person1.*, Person2.*
from House
inner join
(select IDHouse,
Min(PrimaryResidents.FullName) PrimaryFullName,
Min(SecondaryResidents.FullName) SecondaryFullName
from Persons PrimaryResidents
left outer join Persons SecondaryResidents
on PrimaryResidents.HouseID = SecondaryResidents.HouseID
and PrimaryResidents.FullName < SecondaryResidents.FullName) Residents
on House.HouseID = Residents.HouseID
inner join Persons Person1 on Residents.PrimaryFullName = Person1.FullName
left outer join Persons Person2 on Residents.SecondaryFullName = Person2.FullName

blindman|||the calculated field must be a new column in the table person ?|||Yes.|||than I can't the structure of the table doesn't depend on me
too much programs are related to the SQL Server database
and there's also the replication + the big DB2 database structure

each time I demand a modification on the structure
the boss begins hillbilly talking|||Adding a calculated field should not be a big deal. It's not much different than adding an index.

Another alternative might be to create an indexed view that contains your concatenated values. There are restrictions on what types of views can be indexed, but I think yours would qualify. Theoretically you would not even need to reference the view in your query. The optimizer should know about it's existence and include it as a resource automatically.

Otherwise, run the query without the index and tell your boss why his policies result in slow execution times. Try to use short, simple words and phrases so that he will understand.

blindman|||i've read one indexes on views and tried it with no satisfying results
but i'm going to re-read BOL to see if i've missed something

just for info this is a part of the real query
SYBASE Version

=======================================
select '' as Prescripteur,
String(LeFoyer.BLOQUE) as ServiceClientBloquant,'0' as Entite,
String(LeFoyer.IDFoyer) as IDFoyer,
LeFoyer.SSSECTR as SStr,
LeFoyer.PTFAPC as PTFAPC,
LeFoyer.PersPTF as PersPTFFoyer,
LeFoyer.Voie,
LeFoyer.CpltAdr as ComplementAdresse,
LeFoyer.CDPOST as CodePostal,
LeFoyer.BurDist as Commune,
Trim(LeFoyer.Commune) as BureauDistributeur,
TypeEntite(LeFoyer.Typclpr) as TypeFoyer,
String(Premiere.IDPers) as IDVous,
Trim(Premiere.Nom) as NomVous,
Trim(Premiere.Prenom) as PrenomVous,
Premiere.Typclpr as TypeVous,
Premiere.PersPTF as PersPTFVous,
Premiere.MarchEntr as MarcheVous,
Conjoint(LeFoyer.NbPersPrinc,String(Deuxieme.IDPer s)) as IDConjoint,
Conjoint(LeFoyer.NbPersPrinc,Trim(Deuxieme.Nom)) as NomConjoint,
Conjoint(LeFoyer.NbPersPrinc,Trim(Deuxieme.Prenom) ) as PrenomConjoint,
Conjoint(LeFoyer.NbPersPrinc,Deuxieme.Typclpr) as TypeConjoint,
Conjoint(LeFoyer.NbPersPrinc,Deuxieme.PersPTF) as PersPTFConjoint,
Conjoint(LeFoyer.NbPersPrinc,Deuxieme.MarchEntr) as MarcheConjoint,
(if LeFoyer.NbPersPrinc = '001' then NomComplet(NomVous,PrenomVous) else NomComplet(NomVous,PrenomVous) || ' / ' ||
NomComplet(NomConjoint,PrenomConjoint) endif) as Foyer,
(if MarcheVous = '1' or MarcheConjoint = '1' then 1 else 0 endif) as MarcheFoyer,
(if Premiere.TYPCLPR = '04' then null else Premiere.DTNPAI endif) as DTNPAIVous,
(if LeFoyer.NbPersPrinc = '001' then null else(if Deuxieme.TYPCLPR = '04' then null else Deuxieme.DTNPAI endif) endif) as DTNPAIConjoint,
(if IsNull(LeFoyer.BurDist,'',LeFoyer.BurDist) = IsNull(Premiere.BurDist,'',Premiere.BurDist) and IsNull(LeFoyer.Voie,'',LeFoyer.Voie) =
IsNull(Premiere.Voie,'',Premiere.Voie) and IsNull(LeFoyer.Commune,'',LeFoyer.Commune) = IsNull(Premiere.Commune,'',Premiere.Commune) and
IsNull(LeFoyer.CpltAdr,'',LeFoyer.CpltAdr) = IsNull(Premiere.CpltAdr,'',Premiere.CpltAdr) and IsNull(LeFoyer.CdPost,'',LeFoyer.CdPost) =
IsNull(Premiere.CdPost,'',Premiere.CdPost) then DTNPAIVous else null endif) as NPAIParVous,
(if IsNull(LeFoyer.BurDist,'',LeFoyer.BurDist) = IsNull(Deuxieme.BurDist,'',Deuxieme.BurDist) and IsNull(LeFoyer.Voie,'',LeFoyer.Voie) =
IsNull(Deuxieme.Voie,'',Deuxieme.Voie) and IsNull(LeFoyer.Commune,'',LeFoyer.Commune) = IsNull(Deuxieme.Commune,'',Deuxieme.Commune) and
IsNull(LeFoyer.CpltAdr,'',LeFoyer.CpltAdr) = IsNull(Deuxieme.CpltAdr,'',Deuxieme.CpltAdr) and IsNull(LeFoyer.CdPost,'',LeFoyer.CdPost) =
IsNull(Deuxieme.CdPost,'',Deuxieme.CdPost) then DTNPAIConjoint else null endif) as NPAIParConjoint,
(if NPAIParVous is null then(if NPAIParConjoint is null then null else NPAIParConjoint endif)
else(if NPAIParConjoint is null then NPAIParVous else(if NPAIParVous > NPAIParConjoint then
NPAIParVous else NPAIParConjoint endif) endif)
endif) as NPAI,
LeFoyer.TYPCLPR,LeFoyer.PERSPTF,LeFoyer.SSSECTR,Le Foyer.CODDEV,LeFoyer.MNTRVFR,LeFoyer.MNTRVEU,LeFoy er.ORIGINE,LeFoyer.NBENFNT,
LeFoyer.NM1RCMDT,LeFoyer.NM2RCMDT,LeFoyer.PN1RCMDT ,LeFoyer.PN2RCMDT from
dbo.V74PERS0 as Premiere join
(select IDPers,Nom,Prenom,Qualite,Typclpr,IDFoyer,PERSPTF, (if TYPCLPR = '04' then null else DTNPAI endif) as DTNPAI,Voie,Commune,Burdist,CpltAdr,
CdPost,MARCHENTR from dbo.V74PERS0 where Typpers || Suptechn = '10') as Deuxieme(IDPers,Nom,Prenom,Qualite,Typclpr,IDFoyer ,PERSPTF,DTNPAI,Voie,
Commune,Burdist,CpltAdr,CdPost,MARCHENTR) on Premiere.IDFoyer = Deuxieme.IDFoyer join
(select TypSup,IDFoyer,Voie,Commune,BurDist,CDPOST,Typclpr ,CpltAdr,PersPTF,SSSECTR,NBPERSPRINC,BLOQUE,PTFAPC ,CODDEV,MNTRVFR,MNTRVEU,ORIGINE,NBENFNT,NM1RCMDT,
NM2RCMDT,PN1RCMDT,PN2RCMDT from dbo.V74FOYE0) as LeFoyer(TypSup,IDFoyer,Voie,Commune,BurDist,CDPOST ,Typclpr,CpltAdr,PersPTF,SSSECTR,
NBPERSPRINC,BLOQUE,PTFAPC,CODDEV,MNTRVFR,MNTRVEU,O RIGINE,NBENFNT,NM1RCMDT,NM2RCMDT,PN1RCMDT,PN2RCMDT ) on Premiere.IDFoyer = LeFoyer.IDFoyer where
Premiere.Typpers || Premiere.Suptechn = '10' and
((LeFoyer.NbPersPrinc || LeFoyer.TypSup = '002 ' and
(Premiere.TYPCLPR || Premiere.PERSPtf || Premiere.Qualite || Premiere.Nom || Premiere.Prenom <
Deuxieme.TYPCLPR || Deuxieme.PERSPtf || Deuxieme.Qualite || Deuxieme.Nom || Deuxieme.Prenom and Premiere.IDPers <> Deuxieme.IDPers) or
(Premiere.TYPCLPR || Premiere.PERSPtf || Premiere.Qualite || Premiere.Nom || Premiere.Prenom =
Deuxieme.TYPCLPR || Deuxieme.PERSPtf || Deuxieme.Qualite || Deuxieme.Nom || Deuxieme.Prenom and Premiere.IDPers > Deuxieme.IDPers)) or
(LeFoyer.NbPersPrinc || LeFoyer.TypSup = '001 '))|||it's horrible 'cause i've got to calculate lot's of fields
before connecting my Grid "via" Ado-ODBC
in my program.

i'm a bit sick of this query
- gaaah - i'm in agony
going home...

thx for your help Mr US-Ohio-BlindMan|||It still will be faster if you put IDHouse in front of LastName, because the join starts with it.|||rdjabarov

what do you mean, "IDHouse in front of LastName"

Friday, March 23, 2012

query

Hi,
There is a table which contains the rows and I would like to create a query
that can show the below result. Can a query do that?
Thanks
Table
--
Owner Cat Name
1 1 Kitap
1 2 Defter
1 3 Kalem
1 2 Dergi
2 1 Ceket
2 1 Gmlek
2 2 Kravat
2 3 orap
2 3 Pantolon
---
The Query result
Owner Cat Name
1 1 Kitap
1 2 Defter
1 3 Kalem
2 1 Ceket
2 2 Kravat
2 3 orap
---A query can probably do this, but you will have to tell us
how you decide which Name to return when there is more
than one row with the same Owner and Cat values. Here,
it looks like you are choosing the one that appears first in
the list of all table rows, but in order to do this with a query,
you need to define the row you want in terms of the column
values, not a particular output order that you can't rely on.
Steve Kass
Drew University
tolgay wrote:

>Hi,
>There is a table which contains the rows and I would like to create a query
>that can show the below result. Can a query do that?
>Thanks
>
>Table
>--
> Owner Cat Name
> 1 1 Kitap
> 1 2 Defter
> 1 3 Kalem
> 1 2 Dergi
> 2 1 Ceket
> 2 1 G闣lek
> 2 2 Kravat
> 2 3 よrap
> 2 3 Pantolon
>---
>The Query result
> Owner Cat Name
> 1 1 Kitap
> 1 2 Defter
> 1 3 Kalem
> 2 1 Ceket
> 2 2 Kravat
> 2 3 よrap
>---
>
>|||Actually it doesn't matter which row comes with the query. But the main
point is the query must get one of the rows.
Thanks
"Steve Kass" <skass@.drew.edu> wrote in message
news:u6PVjiFcGHA.3380@.TK2MSFTNGP04.phx.gbl...
> A query can probably do this, but you will have to tell us
> how you decide which Name to return when there is more
> than one row with the same Owner and Cat values. Here,
> it looks like you are choosing the one that appears first in
> the list of all table rows, but in order to do this with a query,
> you need to define the row you want in terms of the column
> values, not a particular output order that you can't rely on.
> Steve Kass
> Drew University
> tolgay wrote:
>
query|||in that case...
Select owner
, cat
, max(name)
from CatTable
group by owner
, cat
However, this table structure needs keys to prevent duplicates. Two rows as
shown here should never exist. You probably want to change your database
structures before doing anything else. You can guarantee that the name you
pull back will be wrong half the time.
"tolgay" <tgul@.tgul.com> wrote in message
news:%23DJTKpFcGHA.1276@.TK2MSFTNGP03.phx.gbl...
> Actually it doesn't matter which row comes with the query. But the main
> point is the query must get one of the rows.
> Thanks
> "Steve Kass" <skass@.drew.edu> wrote in message
> news:u6PVjiFcGHA.3380@.TK2MSFTNGP04.phx.gbl...
> query
>|||Jim has offered a solution, and I'll just add that while
it doesn't matter to you, you still have to tell SQL Server
what to do. There's no ANY_OLD_ONE aggregate
in SQL. :)
SK
tolgay wrote:

>Actually it doesn't matter which row comes with the query. But the main
>point is the query must get one of the rows.
>Thanks
>"Steve Kass" <skass@.drew.edu> wrote in message
>news:u6PVjiFcGHA.3380@.TK2MSFTNGP04.phx.gbl...
>
>query
>
>
>|||thanks a lot you saved my day :)
"tolgay" <tgul@.tgul.com> wrote in message
news:un$oOaFcGHA.3856@.TK2MSFTNGP03.phx.gbl...
> Hi,
> There is a table which contains the rows and I would like to create a
> query
> that can show the below result. Can a query do that?
> Thanks
>
> Table
> --
> Owner Cat Name
> 1 1 Kitap
> 1 2 Defter
> 1 3 Kalem
> 1 2 Dergi
> 2 1 Ceket
> 2 1 Gmlek
> 2 2 Kravat
> 2 3 orap
> 2 3 Pantolon
> ---
> The Query result
> Owner Cat Name
> 1 1 Kitap
> 1 2 Defter
> 1 3 Kalem
> 2 1 Ceket
> 2 2 Kravat
> 2 3 orap
> ---
>sql

query

Hi,
There is a table which contains the rows and I would like to create a query
that can show the below result. Can a query do that?
Thanks
Table
--
Owner Cat Name
1 1 Kitap
1 2 Defter
1 3 Kalem
1 2 Dergi
2 1 Ceket
2 1 Gömlek
2 2 Kravat
2 3 Çorap
2 3 Pantolon
---
The Query result
Owner Cat Name
1 1 Kitap
1 2 Defter
1 3 Kalem
2 1 Ceket
2 2 Kravat
2 3 Çorap
---A query can probably do this, but you will have to tell us
how you decide which Name to return when there is more
than one row with the same Owner and Cat values. Here,
it looks like you are choosing the one that appears first in
the list of all table rows, but in order to do this with a query,
you need to define the row you want in terms of the column
values, not a particular output order that you can't rely on.
Steve Kass
Drew University
tolgay wrote:
>Hi,
>There is a table which contains the rows and I would like to create a query
>that can show the below result. Can a query do that?
>Thanks
>
>Table
>--
> Owner Cat Name
> 1 1 Kitap
> 1 2 Defter
> 1 3 Kalem
> 1 2 Dergi
> 2 1 Ceket
> 2 1 Gé?£lek
> 2 2 Kravat
> 2 3 ã'rap
> 2 3 Pantolon
>---
>The Query result
> Owner Cat Name
> 1 1 Kitap
> 1 2 Defter
> 1 3 Kalem
> 2 1 Ceket
> 2 2 Kravat
> 2 3 ã'rap
>---
>
>|||Actually it doesn't matter which row comes with the query. But the main
point is the query must get one of the rows.
Thanks
"Steve Kass" <skass@.drew.edu> wrote in message
news:u6PVjiFcGHA.3380@.TK2MSFTNGP04.phx.gbl...
> A query can probably do this, but you will have to tell us
> how you decide which Name to return when there is more
> than one row with the same Owner and Cat values. Here,
> it looks like you are choosing the one that appears first in
> the list of all table rows, but in order to do this with a query,
> you need to define the row you want in terms of the column
> values, not a particular output order that you can't rely on.
> Steve Kass
> Drew University
> tolgay wrote:
> >Hi,
> >
> >There is a table which contains the rows and I would like to create a
query
> >that can show the below result. Can a query do that?
> >Thanks
> >
> >
> >Table
> >--
> > Owner Cat Name
> > 1 1 Kitap
> > 1 2 Defter
> > 1 3 Kalem
> > 1 2 Dergi
> > 2 1 Ceket
> > 2 1 G?lek
> > 2 2 Kravat
> > 2 3 ?rap
> > 2 3 Pantolon
> >
> >---
> >The Query result
> >
> > Owner Cat Name
> > 1 1 Kitap
> > 1 2 Defter
> > 1 3 Kalem
> > 2 1 Ceket
> > 2 2 Kravat
> > 2 3 ?rap
> >
> >---
> >
> >
> >
> >|||in that case...
Select owner
, cat
, max(name)
from CatTable
group by owner
, cat
However, this table structure needs keys to prevent duplicates. Two rows as
shown here should never exist. You probably want to change your database
structures before doing anything else. You can guarantee that the name you
pull back will be wrong half the time.
"tolgay" <tgul@.tgul.com> wrote in message
news:%23DJTKpFcGHA.1276@.TK2MSFTNGP03.phx.gbl...
> Actually it doesn't matter which row comes with the query. But the main
> point is the query must get one of the rows.
> Thanks
> "Steve Kass" <skass@.drew.edu> wrote in message
> news:u6PVjiFcGHA.3380@.TK2MSFTNGP04.phx.gbl...
> > A query can probably do this, but you will have to tell us
> > how you decide which Name to return when there is more
> > than one row with the same Owner and Cat values. Here,
> > it looks like you are choosing the one that appears first in
> > the list of all table rows, but in order to do this with a query,
> > you need to define the row you want in terms of the column
> > values, not a particular output order that you can't rely on.
> >
> > Steve Kass
> > Drew University
> >
> > tolgay wrote:
> >
> > >Hi,
> > >
> > >There is a table which contains the rows and I would like to create a
> query
> > >that can show the below result. Can a query do that?
> > >Thanks
> > >
> > >
> > >Table
> > >--
> > > Owner Cat Name
> > > 1 1 Kitap
> > > 1 2 Defter
> > > 1 3 Kalem
> > > 1 2 Dergi
> > > 2 1 Ceket
> > > 2 1 G?lek
> > > 2 2 Kravat
> > > 2 3 ?rap
> > > 2 3 Pantolon
> > >
> > >---
> > >The Query result
> > >
> > > Owner Cat Name
> > > 1 1 Kitap
> > > 1 2 Defter
> > > 1 3 Kalem
> > > 2 1 Ceket
> > > 2 2 Kravat
> > > 2 3 ?rap
> > >
> > >---
> > >
> > >
> > >
> > >
>|||Jim has offered a solution, and I'll just add that while
it doesn't matter to you, you still have to tell SQL Server
what to do. There's no ANY_OLD_ONE aggregate
in SQL. :)
SK
tolgay wrote:
>Actually it doesn't matter which row comes with the query. But the main
>point is the query must get one of the rows.
>Thanks
>"Steve Kass" <skass@.drew.edu> wrote in message
>news:u6PVjiFcGHA.3380@.TK2MSFTNGP04.phx.gbl...
>
>>A query can probably do this, but you will have to tell us
>>how you decide which Name to return when there is more
>>than one row with the same Owner and Cat values. Here,
>>it looks like you are choosing the one that appears first in
>>the list of all table rows, but in order to do this with a query,
>>you need to define the row you want in terms of the column
>>values, not a particular output order that you can't rely on.
>>Steve Kass
>>Drew University
>>tolgay wrote:
>>
>>Hi,
>>There is a table which contains the rows and I would like to create a
>>
>query
>
>>that can show the below result. Can a query do that?
>>Thanks
>>
>>Table
>>--
>> Owner Cat Name
>> 1 1 Kitap
>> 1 2 Defter
>> 1 3 Kalem
>> 1 2 Dergi
>> 2 1 Ceket
>> 2 1 G?lek
>> 2 2 Kravat
>> 2 3 ?rap
>> 2 3 Pantolon
>>---
>>The Query result
>> Owner Cat Name
>> 1 1 Kitap
>> 1 2 Defter
>> 1 3 Kalem
>> 2 1 Ceket
>> 2 2 Kravat
>> 2 3 ?rap
>>---
>>
>>
>>
>
>|||thanks a lot you saved my day :)
"tolgay" <tgul@.tgul.com> wrote in message
news:un$oOaFcGHA.3856@.TK2MSFTNGP03.phx.gbl...
> Hi,
> There is a table which contains the rows and I would like to create a
> query
> that can show the below result. Can a query do that?
> Thanks
>
> Table
> --
> Owner Cat Name
> 1 1 Kitap
> 1 2 Defter
> 1 3 Kalem
> 1 2 Dergi
> 2 1 Ceket
> 2 1 Gömlek
> 2 2 Kravat
> 2 3 Çorap
> 2 3 Pantolon
> ---
> The Query result
> Owner Cat Name
> 1 1 Kitap
> 1 2 Defter
> 1 3 Kalem
> 2 1 Ceket
> 2 2 Kravat
> 2 3 Çorap
> ---
>

query

Can I have conatins clause like following
where contains(col_name ,'%')
where contains (col_name , '/*')
basically looking for special characters in text columnsHi.
Perhaps you want to look at this example
CREATE TABLE #TEST
(
COL VARCHAR(50)
)
INSERT INTO #TEST VALUES ('FF')
INSERT INTO #TEST VALUES ('F%F')
INSERT INTO #TEST VALUES ('FF%')
INSERT INTO #TEST VALUES ('NNFF')
INSERT INTO #TEST VALUES ('F88F')
INSERT INTO #TEST VALUES ('*FF')
SELECT * FROM #TEST WHERE CHARINDEX('%',COL)>0
<anonymous@.discussions.microsoft.com> wrote in message
news:085e01c39dfe$ff0d6db0$a501280a@.phx.gbl...
> Can I have conatins clause like following
>
> where contains(col_name ,'%')
> where contains (col_name , '/*')
> basically looking for special characters in text columns
>

query

Hi,
There is a table which contains the rows and I would like to create a query
that can show the below result. Can a query do that?
Thanks
Table
--
Owner Cat Name
1 1 Kitap
1 2 Defter
1 3 Kalem
1 2 Dergi
2 1 Ceket
2 1 Gmlek
2 2 Kravat
2 3 orap
2 3 Pantolon
---
The Query result
Owner Cat Name
1 1 Kitap
1 2 Defter
1 3 Kalem
2 1 Ceket
2 2 Kravat
2 3 orap
---A query can probably do this, but you will have to tell us
how you decide which Name to return when there is more
than one row with the same Owner and Cat values. Here,
it looks like you are choosing the one that appears first in
the list of all table rows, but in order to do this with a query,
you need to define the row you want in terms of the column
values, not a particular output order that you can't rely on.
Steve Kass
Drew University
tolgay wrote:

>Hi,
>There is a table which contains the rows and I would like to create a query
>that can show the below result. Can a query do that?
>Thanks
>
>Table
>--
> Owner Cat Name
> 1 1 Kitap
> 1 2 Defter
> 1 3 Kalem
> 1 2 Dergi
> 2 1 Ceket
> 2 1 G闣lek
> 2 2 Kravat
> 2 3 よrap
> 2 3 Pantolon
>---
>The Query result
> Owner Cat Name
> 1 1 Kitap
> 1 2 Defter
> 1 3 Kalem
> 2 1 Ceket
> 2 2 Kravat
> 2 3 よrap
>---
>
>|||Actually it doesn't matter which row comes with the query. But the main
point is the query must get one of the rows.
Thanks
"Steve Kass" <skass@.drew.edu> wrote in message
news:u6PVjiFcGHA.3380@.TK2MSFTNGP04.phx.gbl...[vbcol=seagreen]
> A query can probably do this, but you will have to tell us
> how you decide which Name to return when there is more
> than one row with the same Owner and Cat values. Here,
> it looks like you are choosing the one that appears first in
> the list of all table rows, but in order to do this with a query,
> you need to define the row you want in terms of the column
> values, not a particular output order that you can't rely on.
> Steve Kass
> Drew University
> tolgay wrote:
>
query[vbcol=seagreen]|||in that case...
Select owner
, cat
, max(name)
from CatTable
group by owner
, cat
However, this table structure needs keys to prevent duplicates. Two rows as
shown here should never exist. You probably want to change your database
structures before doing anything else. You can guarantee that the name you
pull back will be wrong half the time.
"tolgay" <tgul@.tgul.com> wrote in message
news:%23DJTKpFcGHA.1276@.TK2MSFTNGP03.phx.gbl...
> Actually it doesn't matter which row comes with the query. But the main
> point is the query must get one of the rows.
> Thanks
> "Steve Kass" <skass@.drew.edu> wrote in message
> news:u6PVjiFcGHA.3380@.TK2MSFTNGP04.phx.gbl...
> query
>|||Jim has offered a solution, and I'll just add that while
it doesn't matter to you, you still have to tell SQL Server
what to do. There's no ANY_OLD_ONE aggregate
in SQL.
SK
tolgay wrote:

>Actually it doesn't matter which row comes with the query. But the main
>point is the query must get one of the rows.
>Thanks
>"Steve Kass" <skass@.drew.edu> wrote in message
>news:u6PVjiFcGHA.3380@.TK2MSFTNGP04.phx.gbl...
>
>query
>
>
>|||thanks a lot you saved my day
"tolgay" <tgul@.tgul.com> wrote in message
news:un$oOaFcGHA.3856@.TK2MSFTNGP03.phx.gbl...
> Hi,
> There is a table which contains the rows and I would like to create a
> query
> that can show the below result. Can a query do that?
> Thanks
>
> Table
> --
> Owner Cat Name
> 1 1 Kitap
> 1 2 Defter
> 1 3 Kalem
> 1 2 Dergi
> 2 1 Ceket
> 2 1 Gmlek
> 2 2 Kravat
> 2 3 orap
> 2 3 Pantolon
> ---
> The Query result
> Owner Cat Name
> 1 1 Kitap
> 1 2 Defter
> 1 3 Kalem
> 2 1 Ceket
> 2 2 Kravat
> 2 3 orap
> ---
>

Tuesday, March 20, 2012

queries

1> how to select 3rd maximim salary from employee table
which contains empid,name,salary.
2> how to select duplicates from a table which doesnt have primary key
*** Sent via Developersdex http://www.codecomments.com ***
Please post this question in programming.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"murali yesuraj" <murali088@.hotmail.com> wrote in message
news:eUhkM1xnFHA.3304@.tk2msftngp13.phx.gbl...
> 1> how to select 3rd maximim salary from employee table
> which contains empid,name,salary.
> 2> how to select duplicates from a table which doesnt have primary key
>
> *** Sent via Developersdex http://www.codecomments.com ***

Friday, March 9, 2012

QA returning negative #s as positive

Hey guys,

I have a very peculiar issue going on. I have a table that contains a decimal(18,2) column called "Amount". Looking at this table through Enterprise Mgr, I can see that there are values in there that are negative. However, when I run a query in Query Analyzer, it displays all the negative values as positives.

The only workaround I've found right now is to change the column type to "real" and then change it back to decimal(18,2), and it starts showing the negatives as negative. However, without performing this absurd workaround, it doesn't work.

Is there a known bug in QA that would manifest itself as this? What is the cause for this?

Thanks in advance.I haven't had a problem with this. What does your query look like? Are the correct results being retuned to your ASP.NET application?

Terri|||Terri,

The query is a straight forward select, nothing tricky at all. Basically, if I look at the Amount values through the analyzer, it displays them as positive. However, one interesting to note is that it recognizes the number as being negative because if i add another column to the return so that it's "Amount * 1", it will return the correct (negative) value.

It basically seems to be a displaying issue. I google'd this issue, and came across a few posts from other forums where people were having the same issue, but none of the threads had an explanation.

Also, this is a problem only with this table. There are other tables in the warehouse that have decimal(18,2) columns with negative values, and they get displayed correctly. At the same time, though, there's nothing special about the table in question. The amount column is sourced from a different table with a column of number(21,6) type, which is really a glorified decimal, so that doesn't seem to be the problem.

I'm pretty much puzzled as to why this column would be displayed incorrectly like this. I welcome any suggestions/ideas.

Thanks|||Have you been able to resolve this issue? I have been out of town this past week and will jump back into this if you are still stuck.

Terri|||Hey Terri,

Actually, it's been sitting on the back burner, and I've been busy with other things. I would, ultimately, like to figure out what is happening, so if you have any ideas, I am all ears.

I did a search on Google groups, this forum, and a few others, and was unable to find an answer. I did find a few threads on various sources concerning this problem, but there was no resolution from anyone.

Thanks for the help.

Saturday, February 25, 2012

Q: Windows Authentication

Is Windows Authentication possible without a domain controller?
I am running a testbed with two Win2K machines without firewalls. One
computer contains the MSDE 2000A, set for Windows Authentication
only. Running MS Access on the other computer under the Administrator
account causes a connection failure error message:
Microsoft SQL Server Login
Connection failed:
SQLState: '01000'
SQL Server Error: 87
[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen
(Connect()).
Connection failed:
SQLState: '08001'
SQL Server Error: 6
[Microsoft][ODBC SQL Server Driver][DBNETLIB]Specified SQL server not
found.
Lou Arnold,
Ottawa, Canada
PS...This is a peer-to peer network...no domain controller.
On Sun, 18 Jul 2004 03:53:19 GMT, Lou_Arnold@.nospam.com (Lou Arnold)
wrote:

>Is Windows Authentication possible without a domain controller?
>I am running a testbed with two Win2K machines without firewalls. One
>computer contains the MSDE 2000A, set for Windows Authentication
>only. Running MS Access on the other computer under the Administrator
>account causes a connection failure error message:
>Microsoft SQL Server Login
>--
>Connection failed:
>SQLState: '01000'
>SQL Server Error: 87
>[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen
>(Connect()).
>Connection failed:
>SQLState: '08001'
>SQL Server Error: 6
>[Microsoft][ODBC SQL Server Driver][DBNETLIB]Specified SQL server not
>found.
>Lou Arnold,
>Ottawa, Canada
|||Try substituting WORKGROUP\USERNAME for DOMAIN\USERNAME. Your error looks
like something other than authentication, however. The two machines can see
each other? Are they in the same workgroup? Maybe try connecting by IP
address instead of machine name and make sure your SQL Server service is
running.
Thanks,
Michael C.
"Lou Arnold" <Lou_Arnold@.nospam.com> wrote in message
news:40f9f68a.19289767@.nntp.flfrd.phub.net.cable.r ogers.com...
> PS...This is a peer-to peer network...no domain controller.
> On Sun, 18 Jul 2004 03:53:19 GMT, Lou_Arnold@.nospam.com (Lou Arnold)
> wrote:
>
|||Michael, Pls see my replies below.
On Sun, 18 Jul 2004 05:18:01 GMT, "Michael C" <nospam@.lol.net> wrote:

>Try substituting WORKGROUP\USERNAME for DOMAIN\USERNAME.
I don't understand where to specify this. There is no domain name as
there is no domain controller.

>Your error looks
>like something other than authentication, however.
> The two machines can see
>each other? Are they in the same workgroup? Maybe try connecting by IP
>address instead of machine name and make sure your SQL Server service is
>running.
Yes, the machines can see each other. File and Printer sharing is
enabled and i can see shares on each computer from the other.
Yes, The work group name WORKGROUP for each computer.
Yes, the SQL server instance is running. (it is a named instance)
Yes, I tried using <ipaddr>\<instancename> and got the same error
message.
Lou Arnold
Ottawa, Canada
|||"Lou Arnold" <Lou_Arnold@.nospam.com> wrote in message
news:40fa18ff.473050@.nntp.flfrd.phub.net.cable.rog ers.com...
> Michael, Pls see my replies below.
> On Sun, 18 Jul 2004 05:18:01 GMT, "Michael C" <nospam@.lol.net> wrote:
> I don't understand where to specify this. There is no domain name as
> there is no domain controller.
If you were connected to a Domain Controller, you would specify
DOMAIN\USERNAME. If you are working on a small LAN with no domain
controller, you can specify WORKGROUP\USERNAME instead; or possibly
MACHINENAME\USERNAME (like this: "MSHOME\BOB" or "COMPUTER1\BOB"). You
might also try connecting using the sa username/password.

> Yes, the machines can see each other. File and Printer sharing is
> enabled and i can see shares on each computer from the other.
> Yes, The work group name WORKGROUP for each computer.
> Yes, the SQL server instance is running. (it is a named instance)
> Yes, I tried using <ipaddr>\<instancename> and got the same error
> message.
>
Do you have a default instance running, or just a named instance? Try
connecting to just <ipaddr> if it's the default instance.
Cheers,
Michael C.
|||In reply:
The instance is a single named instance.
I tried connecting with the SA username and password, but it failed
with the same error message. This was expected since the server is set
up for Windows Authentication only.
Re the Workgroup/Domain name: I understand your explanation, but I
still don't know where (or how) to enter the
workgroup-name/computer-name. Can you be specific about the window
and field that this info should be entered? I am still using the
ipaddr/instance-name in the MIcrosoft SQL Server Database Wizard
Dialog box. This box is the first box displayed when, in MS Access,
you try to create a new Access project. The field has the text label:
"What SQL Server would you like to use for this database?"
Lou
On Sun, 18 Jul 2004 17:42:49 GMT, "Michael C" <nospam@.lol.net> wrote:

>"Lou Arnold" <Lou_Arnold@.nospam.com> wrote in message
>news:40fa18ff.473050@.nntp.flfrd.phub.net.cable.ro gers.com...
>If you were connected to a Domain Controller, you would specify
>DOMAIN\USERNAME. If you are working on a small LAN with no domain
>controller, you can specify WORKGROUP\USERNAME instead; or possibly
>MACHINENAME\USERNAME (like this: "MSHOME\BOB" or "COMPUTER1\BOB"). You
>might also try connecting using the sa username/password.
>
>Do you have a default instance running, or just a named instance? Try
>connecting to just <ipaddr> if it's the default instance.
>Cheers,
>Michael C.
>
|||Michael...here are a few more details:
On the server computer, I have used the SQL Server Network Utility to
disable all but TCP/IP connections. Also, the server is set to use
port 1433. Is this appropriate?
On the client computer, I have used the SQL Server Client Network
Utility to disable all but TCP/IP, and to set the default port value
for TCP/IP to use 1433. Is this appropriate?
Lou.
|||Michael...Sorry I was in error. I enabled File and Printer Sharing and
Client for MS Network on the server computer. Doing this got me past
the connect error I gave in the initial post. However, no database was
created, and no error message was generated. Again, I wonder if this a
Windows Authentication problem.
The symptom is now tthis:
The MS SQL Server Database Wizard apparently connects to the server,
after which a dialog box appears saying that it has all the info it
needs. When I Click Finish, a dialog box appears for a split second.
This dialog box is a progress bar that shows the progress of creating
the new database on the server. This bar shows no progress and quickly
disappears. Why does this happen?
Why is Client for MS Networks and File and Printer Sharing required to
make the connection to the server?
Lou Arnold
|||OK, I'm a little lost now. I was under the assumption that you were trying
to connect to your SQL Server via SQL Enterprise Manager and set up
permissions on an account using that. Now I'm not so sure. Just a couple
of questions so I can try to help you a little better:
1. What exactly are you trying to do?
2. Do you have SQL Server 2K on one computer or both?
3. Are both computers in the same Workgroup (right-click on My Computer >
Properties > Computer Name)?
4. Are both computers set up in the same IP range with the same Subnet
(TCP/IP settings)?
5. Are you running any firewall software?
Thanks,
Michael C.
"Lou Arnold" <Lou_Arnold@.nospam.com> wrote in message
news:40fbcf8b.2586869@.nntp.flfrd.phub.net.cable.ro gers.com...
> Michael...Sorry I was in error. I enabled File and Printer Sharing and
> Client for MS Network on the server computer. Doing this got me past
> the connect error I gave in the initial post. However, no database was
> created, and no error message was generated. Again, I wonder if this a
> Windows Authentication problem.
> The symptom is now tthis:
> The MS SQL Server Database Wizard apparently connects to the server,
> after which a dialog box appears saying that it has all the info it
> needs. When I Click Finish, a dialog box appears for a split second.
> This dialog box is a progress bar that shows the progress of creating
> the new database on the server. This bar shows no progress and quickly
> disappears. Why does this happen?
> Why is Client for MS Networks and File and Printer Sharing required to
> make the connection to the server?
> Lou Arnold
|||Michael...see my replies below.
On Tue, 20 Jul 2004 00:36:08 GMT, "Michael C" <nospam@.lol.net> wrote:

>OK, I'm a little lost now. I was under the assumption that you were trying
>to connect to your SQL Server via SQL Enterprise Manager and set up
>permissions on an account using that. Now I'm not so sure. Just a couple
>of questions so I can try to help you a little better:
Don't blame you for being lost.

>1. What exactly are you trying to do?
The objective is to establish a testbed of two Win2K computers. This
is to be a peer network without a domain controller. The intent is to
establish a configuration whereby these two computers can be used for
development. The server is to be used with Windows Authentication
security only unless this proves impossible. We can play with settings
such as TCP/IP, File and Printer sharing and internet port numbers as
long as we establish a minimum configuration and the reason for each
setting.
>2. Do you have SQL Server 2K on one computer or both?
Only one computer (I'll call it the server computer) has the SQL
Server installed. Only one server is installed and this is a named
instance. The server is set to use port 1433. The other computer (the
client computer) has MS Access installed. This is a requirement for
this testbed. No other computers are connected to these computers.
Both computers are run only under the Windows Administrator account to
avoid the cofiguration of permissions.

>3. Are both computers in the same Workgroup (right-click on My Computer >
>Properties > Computer Name)?
Yes, both are in the same workgroup.

>4. Are both computers set up in the same IP range with the same Subnet
>(TCP/IP settings)?
Yes. they run thru a router and so have adjacent addresses, and the
subnet mask of 255.255.255.0. The router's internet connection is
disabled.
BTW: both TCP/IP and Named Pipes are enabled on both client and server
machines using the client and server network utilities.

>5. Are you running any firewall software?
No. No firewalls have been installed.
More info:
In my initial post, MS Access generated a connection error. After some
trials, it was found that networking components "File and Printer
Sharing" and "Client for MS Networks" had to be enabled on both
computers for the connection to work (why is unclear and must be
investigated). After enabling these two networking components, the
connection appears to succeed, but creation of the database fails and
no error message is generated.
In my mind are the following possible causes:
1) Windows Authentication cannot work because there is no domain
controller. Therefore SQL Server authentication must be used. We must
be sure that this is the only recourse before we abandon Windows
Authentication.
Or
2) Somehow the client's Windows Administrator account is not
recognized by the Server as having permission to create a database,
despite the fact that Windows Administrators should have that
permission by default.
Lou.

Q: Windows Authentication

Is Windows Authentication possible without a domain controller?
I am running a testbed with two Win2K machines without firewalls. One
computer contains the MSDE 2000A, set for Windows Authentication
only. Running MS Access on the other computer under the Administrator
account causes a connection failure error message:
Microsoft SQL Server Login
--
Connection failed:
SQLState: '01000'
SQL Server Error: 87
[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen
(Connect()).
Connection failed:
SQLState: '08001'
SQL Server Error: 6
[Microsoft][ODBC SQL Server Driver][DBNETLIB]Specified SQL serve
r not
found.
Lou Arnold,
Ottawa, CanadaPS...This is a peer-to peer network...no domain controller.
On Sun, 18 Jul 2004 03:53:19 GMT, Lou_Arnold@.nospam.com (Lou Arnold)
wrote:

>Is Windows Authentication possible without a domain controller?
>I am running a testbed with two Win2K machines without firewalls. One
>computer contains the MSDE 2000A, set for Windows Authentication
>only. Running MS Access on the other computer under the Administrator
>account causes a connection failure error message:
>Microsoft SQL Server Login
>--
>Connection failed:
>SQLState: '01000'
>SQL Server Error: 87
>[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen
>(Connect()).
>Connection failed:
>SQLState: '08001'
>SQL Server Error: 6
>[Microsoft][ODBC SQL Server Driver][DBNETLIB]Specified SQL serv
er not
>found.
>Lou Arnold,
>Ottawa, Canada|||Try substituting WORKGROUP\USERNAME for DOMAIN\USERNAME. Your error looks
like something other than authentication, however. The two machines can see
each other? Are they in the same workgroup? Maybe try connecting by IP
address instead of machine name and make sure your SQL Server service is
running.
Thanks,
Michael C.
"Lou Arnold" <Lou_Arnold@.nospam.com> wrote in message
news:40f9f68a.19289767@.nntp.flfrd.phub.net.cable.rogers.com...
> PS...This is a peer-to peer network...no domain controller.
> On Sun, 18 Jul 2004 03:53:19 GMT, Lou_Arnold@.nospam.com (Lou Arnold)
> wrote:
>
>|||Michael, Pls see my replies below.
On Sun, 18 Jul 2004 05:18:01 GMT, "Michael C" <nospam@.lol.net> wrote:

>Try substituting WORKGROUP\USERNAME for DOMAIN\USERNAME.
I don't understand where to specify this. There is no domain name as
there is no domain controller.

>Your error looks
>like something other than authentication, however.
> The two machines can see
>each other? Are they in the same workgroup? Maybe try connecting by IP
>address instead of machine name and make sure your SQL Server service is
>running.
Yes, the machines can see each other. File and Printer sharing is
enabled and i can see shares on each computer from the other.
Yes, The work group name WORKGROUP for each computer.
Yes, the SQL server instance is running. (it is a named instance)
Yes, I tried using <ipaddr>\<instancename> and got the same error
message.
Lou Arnold
Ottawa, Canada|||"Lou Arnold" <Lou_Arnold@.nospam.com> wrote in message
news:40fa18ff.473050@.nntp.flfrd.phub.net.cable.rogers.com...
> Michael, Pls see my replies below.
> On Sun, 18 Jul 2004 05:18:01 GMT, "Michael C" <nospam@.lol.net> wrote:
>
> I don't understand where to specify this. There is no domain name as
> there is no domain controller.
If you were connected to a Domain Controller, you would specify
DOMAIN\USERNAME. If you are working on a small LAN with no domain
controller, you can specify WORKGROUP\USERNAME instead; or possibly
MACHINENAME\USERNAME (like this: "MSHOME\BOB" or "COMPUTER1\BOB"). You
might also try connecting using the sa username/password.

> Yes, the machines can see each other. File and Printer sharing is
> enabled and i can see shares on each computer from the other.
> Yes, The work group name WORKGROUP for each computer.
> Yes, the SQL server instance is running. (it is a named instance)
> Yes, I tried using <ipaddr>\<instancename> and got the same error
> message.
>
Do you have a default instance running, or just a named instance? Try
connecting to just <ipaddr> if it's the default instance.
Cheers,
Michael C.|||In reply:
The instance is a single named instance.
I tried connecting with the SA username and password, but it failed
with the same error message. This was expected since the server is set
up for Windows Authentication only.
Re the Workgroup/Domain name: I understand your explanation, but I
still don't know where (or how) to enter the
workgroup-name/computer-name. Can you be specific about the window
and field that this info should be entered? I am still using the
ipaddr/instance-name in the MIcrosoft SQL Server Database Wizard
Dialog box. This box is the first box displayed when, in MS Access,
you try to create a new Access project. The field has the text label:
"What SQL Server would you like to use for this database?"
Lou
On Sun, 18 Jul 2004 17:42:49 GMT, "Michael C" <nospam@.lol.net> wrote:

>"Lou Arnold" <Lou_Arnold@.nospam.com> wrote in message
>news:40fa18ff.473050@.nntp.flfrd.phub.net.cable.rogers.com...
>If you were connected to a Domain Controller, you would specify
>DOMAIN\USERNAME. If you are working on a small LAN with no domain
>controller, you can specify WORKGROUP\USERNAME instead; or possibly
>MACHINENAME\USERNAME (like this: "MSHOME\BOB" or "COMPUTER1\BOB"). You
>might also try connecting using the sa username/password.
>
>Do you have a default instance running, or just a named instance? Try
>connecting to just <ipaddr> if it's the default instance.
>Cheers,
>Michael C.
>|||Michael...here are a few more details:
On the server computer, I have used the SQL Server Network Utility to
disable all but TCP/IP connections. Also, the server is set to use
port 1433. Is this appropriate?
On the client computer, I have used the SQL Server Client Network
Utility to disable all but TCP/IP, and to set the default port value
for TCP/IP to use 1433. Is this appropriate?
Lou.|||Michael...Sorry I was in error. I enabled File and Printer Sharing and
Client for MS Network on the server computer. Doing this got me past
the connect error I gave in the initial post. However, no database was
created, and no error message was generated. Again, I wonder if this a
Windows Authentication problem.
The symptom is now tthis:
The MS SQL Server Database Wizard apparently connects to the server,
after which a dialog box appears saying that it has all the info it
needs. When I Click Finish, a dialog box appears for a split second.
This dialog box is a progress bar that shows the progress of creating
the new database on the server. This bar shows no progress and quickly
disappears. Why does this happen?
Why is Client for MS Networks and File and Printer Sharing required to
make the connection to the server'
Lou Arnold|||OK, I'm a little lost now. I was under the assumption that you were trying
to connect to your SQL Server via SQL Enterprise Manager and set up
permissions on an account using that. Now I'm not so sure. Just a couple
of questions so I can try to help you a little better:
1. What exactly are you trying to do?
2. Do you have SQL Server 2K on one computer or both?
3. Are both computers in the same Workgroup (right-click on My Computer >
Properties > Computer Name)?
4. Are both computers set up in the same IP range with the same Subnet
(TCP/IP settings)?
5. Are you running any firewall software?
Thanks,
Michael C.
"Lou Arnold" <Lou_Arnold@.nospam.com> wrote in message
news:40fbcf8b.2586869@.nntp.flfrd.phub.net.cable.rogers.com...
> Michael...Sorry I was in error. I enabled File and Printer Sharing and
> Client for MS Network on the server computer. Doing this got me past
> the connect error I gave in the initial post. However, no database was
> created, and no error message was generated. Again, I wonder if this a
> Windows Authentication problem.
> The symptom is now tthis:
> The MS SQL Server Database Wizard apparently connects to the server,
> after which a dialog box appears saying that it has all the info it
> needs. When I Click Finish, a dialog box appears for a split second.
> This dialog box is a progress bar that shows the progress of creating
> the new database on the server. This bar shows no progress and quickly
> disappears. Why does this happen?
> Why is Client for MS Networks and File and Printer Sharing required to
> make the connection to the server'
> Lou Arnold|||Michael...see my replies below.
On Tue, 20 Jul 2004 00:36:08 GMT, "Michael C" <nospam@.lol.net> wrote:

>OK, I'm a little lost now. I was under the assumption that you were trying
>to connect to your SQL Server via SQL Enterprise Manager and set up
>permissions on an account using that. Now I'm not so sure. Just a couple
>of questions so I can try to help you a little better:
Don't blame you for being lost.

>1. What exactly are you trying to do?
The objective is to establish a testbed of two Win2K computers. This
is to be a peer network without a domain controller. The intent is to
establish a configuration whereby these two computers can be used for
development. The server is to be used with Windows Authentication
security only unless this proves impossible. We can play with settings
such as TCP/IP, File and Printer sharing and internet port numbers as
long as we establish a minimum configuration and the reason for each
setting.
>2. Do you have SQL Server 2K on one computer or both?
Only one computer (I'll call it the server computer) has the SQL
Server installed. Only one server is installed and this is a named
instance. The server is set to use port 1433. The other computer (the
client computer) has MS Access installed. This is a requirement for
this testbed. No other computers are connected to these computers.
Both computers are run only under the Windows Administrator account to
avoid the cofiguration of permissions.

>3. Are both computers in the same Workgroup (right-click on My Computer >
>Properties > Computer Name)?
Yes, both are in the same workgroup.

>4. Are both computers set up in the same IP range with the same Subnet
>(TCP/IP settings)?
Yes. they run thru a router and so have adjacent addresses, and the
subnet mask of 255.255.255.0. The router's internet connection is
disabled.
BTW: both TCP/IP and Named Pipes are enabled on both client and server
machines using the client and server network utilities.

>5. Are you running any firewall software?
No. No firewalls have been installed.
More info:
In my initial post, MS Access generated a connection error. After some
trials, it was found that networking components "File and Printer
Sharing" and "Client for MS Networks" had to be enabled on both
computers for the connection to work (why is unclear and must be
investigated). After enabling these two networking components, the
connection appears to succeed, but creation of the database fails and
no error message is generated.
In my mind are the following possible causes:
1) Windows Authentication cannot work because there is no domain
controller. Therefore SQL Server authentication must be used. We must
be sure that this is the only recourse before we abandon Windows
Authentication.
Or
2) Somehow the client's Windows Administrator account is not
recognized by the Server as having permission to create a database,
despite the fact that Windows Administrators should have that
permission by default.
--
Lou.