Showing posts with label write. Show all posts
Showing posts with label write. Show all posts

Friday, March 30, 2012

Link two tables using partial word match

Hi All,

I need to link two tables using partial word match.

How can I write a SQL statement to do so? (I am using MS-Access.)

Table One: [Table Name: tblStreet] [Field Name: Street]
123 ABC Street
124 ABC Street
125 ABC Street
1 XYZ AVE
2 XYZ AVE
3 XYZ AVE
10 CBS Street
11 CBS Street
12 CBS Street
100 Apple Road
101 Apple Road
102 Apple Road

Table Two: [Table Name: tblWord] [Field Name: Word]
ABC
CBS

The output should be:

123 ABC Street
124 ABC Street
125 ABC Street
10 CBS Street
11 CBS Street
12 CBS Street

Could this be done?

Thank you in advanced.

- Grasshopper -SQL Learner wrote:

Quote:

Originally Posted by

Hi All,
>
I need to link two tables using partial word match.
>
How can I write a SQL statement to do so? (I am using MS-Access.)
>
Table One: [Table Name: tblStreet] [Field Name: Street]
123 ABC Street
124 ABC Street
125 ABC Street
1 XYZ AVE
2 XYZ AVE
3 XYZ AVE
10 CBS Street
11 CBS Street
12 CBS Street
100 Apple Road
101 Apple Road
102 Apple Road
>
Table Two: [Table Name: tblWord] [Field Name: Word]
ABC
CBS
>
The output should be:
>
123 ABC Street
124 ABC Street
125 ABC Street
10 CBS Street
11 CBS Street
12 CBS Street
>
Could this be done?
>
Thank you in advanced.
>
- Grasshopper -


SELECT t.* FROM tblStreet t WHERE EXISTS(SELECT 1 FROM tblWord w WHERE
t.Street LIKE '%'+Word+'%')

--------
Alex Kuznetsov
http://sqlserver-tips.blogspot.com/
http://sqlserver-puzzles.blogspot.com/|||Thank you so much Alex! It works. The only thing is that I replaced
the "%" with "*" since this is Transact SQL in Access. : )

By the way, is there any good book that I can use to learn SQL of this
kind?

- Grasshopper -

Link to Oracle Server

Hello.
How can I connect to Oracle from MS SQL and read/write data into Oracle's
tables?
"David Dvali" <david_dvali@.hotmail.com> wrote in message
news:%23tdGh6%23MGHA.2300@.TK2MSFTNGP15.phx.gbl...
> Hello.
> How can I connect to Oracle from MS SQL and read/write data into Oracle's
> tables?
Configuring Linked Servers
http://msdn.microsoft.com/library/de...erver_4uuq.asp
How to set up and troubleshoot a linked server to an Oracle database in SQL
Server
http://support.microsoft.com/kb/280106
David

Link to Oracle Server

Hello.
How can I connect to Oracle from MS SQL and read/write data into Oracle's
tables?"David Dvali" <david_dvali@.hotmail.com> wrote in message
news:%23tdGh6%23MGHA.2300@.TK2MSFTNGP15.phx.gbl...
> Hello.
> How can I connect to Oracle from MS SQL and read/write data into Oracle's
> tables?
Configuring Linked Servers
http://msdn.microsoft.com/library/d...>
ver_4uuq.asp
How to set up and troubleshoot a linked server to an Oracle database in SQL
Server
http://support.microsoft.com/kb/280106
David

Link to Oracle Server

Hello.
How can I connect to Oracle from MS SQL and read/write data into Oracle's
tables?"David Dvali" <david_dvali@.hotmail.com> wrote in message
news:%23tdGh6%23MGHA.2300@.TK2MSFTNGP15.phx.gbl...
> Hello.
> How can I connect to Oracle from MS SQL and read/write data into Oracle's
> tables?
Configuring Linked Servers
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adminsql/ad_1_server_4uuq.asp
How to set up and troubleshoot a linked server to an Oracle database in SQL
Server
http://support.microsoft.com/kb/280106
David

Wednesday, March 21, 2012

Line item query

I have a query that I am trying to write that will get demographic
information from one table and then get journal entries from another
table. However, I want all the journal entries to be concatenated
together so in the end I only have one record for each person.
Any ideas?
Thanks!!use coalesce|||I tried the COALESCE function. It still returns mutiple rows for each
record.|||This is what I am dealing with:
Demographics Table
Person (PK)
Name
Address
City
State
Journal Table
Person (FK)
Journal
Each person can have only one record in Demographics. But there may be
multiple records for each person in Journal. I need to take all the
records from Journal, match them up to the records in Demographics and
then output it all as one record per person.
Thanks for the help.|||Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, data types, etc. in
your schema are. Sample data is also a good idea, along with clear
specifications. It is very hard to debug code when you do not let us
see it.
multiple records[sic] for each person in Journal.<<
What you attempted to post makes no sense. Rows are not anything like
records, But ignoring that, if this "person_<something>" is a key,
then BY DEFINITION there can be multiple rows per person in the Journal
table.
If I understand what you mean, that is called violating First Normal
Form and we do not do this in an RDBMS. You want to use a 1950's COBOL
file system with variant records and an OCCURS clause.|||What CELKO means to say is you can do this in the application rather than
the database. Applications work well for these, not so much with database
queries.
If you are on SQL 2005 you can use the XML functionality to concatenate the
values together. Do a search in this newsgroup for XML and concatenation,
and you'll find a neat trick that makes this very simple.
If you are not on 2005 yet, I think you are stuck with a cursor, which can
be written simpler and more efficiently in most programming languages.
"CJEN" <christopher.t.davis@.gmail.com> wrote in message
news:1146667896.994197.34100@.u72g2000cwu.googlegroups.com...
> This is what I am dealing with:
> Demographics Table
> Person (PK)
> Name
> Address
> City
> State
> Journal Table
> Person (FK)
> Journal
> Each person can have only one record in Demographics. But there may be
> multiple records for each person in Journal. I need to take all the
> records from Journal, match them up to the records in Demographics and
> then output it all as one record per person.
> Thanks for the help.
>|||I might have misunderstood what you're trying to do, but what about
something like this:
CREATE TABLE People(personid int, name varchar(50))
CREATE TABLE Journals(entrydate datetime, PersonID int, entry
varchar(200))
INSERT INTO People
SELECT 1, 'Rod'
UNION ALL
SELECT 2, 'Jane'
UNION ALL
SELECT 3, 'Freddy'
INSERT INTO Journals
SELECT '2006-04-02', 1, 'Up above the streets and houses'
UNION ALL
SELECT '2006-04-01', 1, 'etc...'
UNION ALL
SELECT '2006-04-06', 2, 'I think Rod and Freddy are conspiring against
me'
UNION ALL
SELECT '2006-04-07', 2, 'I must strike first...'
GO
CREATE FUNCTION GetJournal(@.PersonID int)
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @.TotalJournal varchar(8000)
SET @.TotalJournal = ''
SELECT @.TotalJournal = @.TotalJournal + ', ' + Entry FROM Journals
WHERE PersonID = @.PersonID
RETURN @.TotalJournal
END
GO
SELECT PersonID, Name, dbo.GetJournal(PersonID)
FROM People
DROP FUNCTION GetJournal
DROP TABLE Journals
DROP TABLE People
GO

Monday, March 12, 2012

Limiting Records Returned within Groups

Sorry to be a noob here, but I've scoured the rest of the threads, and can't find the answer to my dilemma.

I'm trying to write a report that returns the top 10 depositors (based on current balance) for each of our branches. I've broken out each branch into it's own group.

When I apply the 'Top N' function, it limits the first group to 10 records, but pulls nothing for the remaining groups.

I've seen other posts that say I need to write a formula that counts the records in each group, and then in the detail section, suppress records greater than 10, but I have no idea how to create the 'count records' formula.

Again, sorry to be the fresh fish here, but I'm at my wit's end.

Thanksfirstly create a formula

formula 1:

//it puts in section 'Group header'
shared numbervar mycount:=0;


formula 2:

//now, inside section 'details'
shared numbervar mycount;
mycount:=mycount+1;


now, click right on section 'detalis' it shows popup menu
you do click on Format Section ......
click on button Suppress and there you have to write

shared numbervar mycount;
if mycount>10 then
true


I don't tested this, but I think it may help you|||Hensa22, you are my savior. Thank you so much.

Friday, March 9, 2012

limiting heavy queries

Hi
I who'd like to know if there is a best accepted practice
that can guide me to write a regulation for limiting
Users and developers running Heavy queries on the server
during working hours."Oren" <orenb70@.bezeqint.net> wrote in message
news:07d901c4b6e4$18097c10$a401280a@.phx.gbl...
> Hi
> I who'd like to know if there is a best accepted practice
> that can guide me to write a regulation for limiting
> Users and developers running Heavy queries on the server
> during working hours.
Look up Query governer.
>|||There is a way to do this using the Query Governor configuration parameter.
You can specify a 'cost' limit for queries in where they won't run if the the
cost (based on execution plan) will exceed this value. You can't limit this
by user, but you can limit by connection using SET statement. All of this is
in Books online.
Colleen
"Oren" wrote:
> Hi
> I who'd like to know if there is a best accepted practice
> that can guide me to write a regulation for limiting
> Users and developers running Heavy queries on the server
> during working hours.
>|||The Query Governor option seems more like a stop-gap measure and won't
really solve the problem. If your users are running queries during business
hours to get information they need to do their jobs, limiting their ability
to run those queries might hurt more than it helps... If you have queries
that are taking a long time or using a lot of server resources, there are
several things you can do to improve performance - add resources to the
server, tune your indexes, optimize queries, optimize server
configuration... Also, can't tell from your statement, but if developers
are using your production servers for development and testing, you might
look at giving them their own SQL server...
Thanks,
Michael C., MCDBA
"Oren" <orenb70@.bezeqint.net> wrote in message
news:07d901c4b6e4$18097c10$a401280a@.phx.gbl...
> Hi
> I who'd like to know if there is a best accepted practice
> that can guide me to write a regulation for limiting
> Users and developers running Heavy queries on the server
> during working hours.
>

limiting heavy queries

Hi
I who'd like to know if there is a best accepted practice
that can guide me to write a regulation for limiting
Users and developers running Heavy queries on the server
during working hours.
"Oren" <orenb70@.bezeqint.net> wrote in message
news:07d901c4b6e4$18097c10$a401280a@.phx.gbl...
> Hi
> I who'd like to know if there is a best accepted practice
> that can guide me to write a regulation for limiting
> Users and developers running Heavy queries on the server
> during working hours.
Look up Query governer.

>
|||There is a way to do this using the Query Governor configuration parameter.
You can specify a 'cost' limit for queries in where they won't run if the the
cost (based on execution plan) will exceed this value. You can't limit this
by user, but you can limit by connection using SET statement. All of this is
in Books online.
Colleen
"Oren" wrote:

> Hi
> I who'd like to know if there is a best accepted practice
> that can guide me to write a regulation for limiting
> Users and developers running Heavy queries on the server
> during working hours.
>
|||The Query Governor option seems more like a stop-gap measure and won't
really solve the problem. If your users are running queries during business
hours to get information they need to do their jobs, limiting their ability
to run those queries might hurt more than it helps... If you have queries
that are taking a long time or using a lot of server resources, there are
several things you can do to improve performance - add resources to the
server, tune your indexes, optimize queries, optimize server
configuration... Also, can't tell from your statement, but if developers
are using your production servers for development and testing, you might
look at giving them their own SQL server...
Thanks,
Michael C., MCDBA
"Oren" <orenb70@.bezeqint.net> wrote in message
news:07d901c4b6e4$18097c10$a401280a@.phx.gbl...
> Hi
> I who'd like to know if there is a best accepted practice
> that can guide me to write a regulation for limiting
> Users and developers running Heavy queries on the server
> during working hours.
>

limiting heavy queries

Hi
I who'd like to know if there is a best accepted practice
that can guide me to write a regulation for limiting
Users and developers running Heavy queries on the server
during working hours."Oren" <orenb70@.bezeqint.net> wrote in message
news:07d901c4b6e4$18097c10$a401280a@.phx.gbl...
> Hi
> I who'd like to know if there is a best accepted practice
> that can guide me to write a regulation for limiting
> Users and developers running Heavy queries on the server
> during working hours.
Look up Query governer.

>|||There is a way to do this using the Query Governor configuration parameter.
You can specify a 'cost' limit for queries in where they won't run if the th
e
cost (based on execution plan) will exceed this value. You can't limit this
by user, but you can limit by connection using SET statement. All of this i
s
in Books online.
Colleen
"Oren" wrote:

> Hi
> I who'd like to know if there is a best accepted practice
> that can guide me to write a regulation for limiting
> Users and developers running Heavy queries on the server
> during working hours.
>|||The Query Governor option seems more like a stop-gap measure and won't
really solve the problem. If your users are running queries during business
hours to get information they need to do their jobs, limiting their ability
to run those queries might hurt more than it helps... If you have queries
that are taking a long time or using a lot of server resources, there are
several things you can do to improve performance - add resources to the
server, tune your indexes, optimize queries, optimize server
configuration... Also, can't tell from your statement, but if developers
are using your production servers for development and testing, you might
look at giving them their own SQL server...
Thanks,
Michael C., MCDBA
"Oren" <orenb70@.bezeqint.net> wrote in message
news:07d901c4b6e4$18097c10$a401280a@.phx.gbl...
> Hi
> I who'd like to know if there is a best accepted practice
> that can guide me to write a regulation for limiting
> Users and developers running Heavy queries on the server
> during working hours.
>

Wednesday, March 7, 2012

LIMITED PIE CHART LEGEND ?

Hi,
I have a problem with Reporting services pie chart legend which is
limited in character
Does it exists a solution to write more text on pie charts legend ?
Thx !Hi rebeupaname,
Depending upon what you're after, you could either:
1) drop a textbox onto the chart and position it near the legend to add
supplemental info, or
2) use an expression for the series label to change the text inside of
the legend
Does this help?
Matt A
Reporting Services Newsletter at www.reportarchitex.com
rebeuapaname@.hotmail.com wrote:
> Hi,
> I have a problem with Reporting services pie chart legend which is
> limited in character
> Does it exists a solution to write more text on pie charts legend ?
> Thx !|||Thank you vert much, i have resolved the problem
But another limitation of PIE CHARTS make me loose time :
I'am looking for a maner to GROUP little values of a graph in one
categorie called "OTHER". For example all value under 1% will be
grouped in the "OTHER" category
Do you understand what i want to say ?
Thx