Friday, February 24, 2012

I need some design help (time series analysis)

Hi,
the design looks ok, simple and straight forward, if you don=B4t want to
store more information here, you should be fine with that. Sure AS
could help you in some cases, but this should be just a simple query
here. Lets try to find a suggestion which will fit your needs. What do
you want to see at the end of the day, a list with playids only ? The
sums of their hits ? The difference between nother time period ? Which
time period do you want to investigate ? Try to give some sample
resultset that we can suggest something as an query for you.
HTH, Jens Suessmeyer
http://www.sqlserver2005.de
--Hi,
Here is a fictious example that models my real life problem that I'm trying
to solve.
Lets say we have a bunch of baseball hitters and every day we give them an
hour to hit as many 'out of the park' home runs as they can hit. Now we want
to track home many they hit each day and watch whether their totals are
going up or down over time.
My fictious table design (as I see it) would be (with data)
PlayerId TotalHits Date
1 8 1/1/6
2 6 1/1/6
3 10 1/1/6
4 4 1/1/6
1 9 1/2/6
2 8 1/2/6
3 15 1/2/6
4 1 1/2/6
...
This may be poor design, please tell me if it is.
Anyway, from this design I could do a 'select playerid, sum(totalhits) from
xxx group by playerId' to see who has the most hits and look at each of the
top X hitters and see if they're in a incremental pattern or decreasing
pattern or just steady but high hits count type pattern.
Instead of that manual method I would like to figure a way to have the
system automatically tell me whose hit count is increasing over time and
whose are decreasing. and be able to break it down by week. month
quarter...
I'm guessing this might be analysis services in sql server, I've never used
them so I don't know. I run sql server 2000 btw.
If you have articles or references please point me in the right direction.
thanks|||Hi,
the design looks ok, simple and straight forward, if you don=B4t want to
store more information here, you should be fine with that. Sure AS
could help you in some cases, but this should be just a simple query
here. Lets try to find a suggestion which will fit your needs. What do
you want to see at the end of the day, a list with playids only ? The
sums of their hits ? The difference between nother time period ? Which
time period do you want to investigate ? Try to give some sample
resultset that we can suggest something as an query for you.
HTH, Jens Suessmeyer
http://www.sqlserver2005.de
--|||"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1151300420.928006.36970@.m73g2000cwd.googlegroups.com...
Hi,
the design looks ok, simple and straight forward, if you dont want to
store more information here, you should be fine with that. Sure AS
could help you in some cases, but this should be just a simple query
here. Lets try to find a suggestion which will fit your needs. What do
you want to see at the end of the day, a list with playids only ? The
sums of their hits ? The difference between nother time period ? Which
time period do you want to investigate ? Try to give some sample
resultset that we can suggest something as an query for you.
HTH, Jens Suessmeyer
http://www.sqlserver2005.de
--
Ultimately I would like to see which players hit counts are on the rise and
which are on the decline. And yes I would like to be able to adjust the time
frames to analyze. So to start out I would like to see the query which would
show me the player id's whose hit counts are on the rise over the entire
time period stored in the database.
I can sort of see how the query could group by week (or month) but I don't
see how it can show me counts which are on the rise.
Thanks for your help.|||"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1151300420.928006.36970@.m73g2000cwd.googlegroups.com...
Hi,
the design looks ok, simple and straight forward, if you dont want to
store more information here, you should be fine with that. Sure AS
could help you in some cases, but this should be just a simple query
here. Lets try to find a suggestion which will fit your needs. What do
you want to see at the end of the day, a list with playids only ? The
sums of their hits ? The difference between nother time period ? Which
time period do you want to investigate ? Try to give some sample
resultset that we can suggest something as an query for you.
HTH, Jens Suessmeyer
http://www.sqlserver2005.de
--
Ultimately I would like to see which players hit counts are on the rise and
which are on the decline. And yes I would like to be able to adjust the time
frames to analyze. So to start out I would like to see the query which would
show me the player id's whose hit counts are on the rise over the entire
time period stored in the database.
I can sort of see how the query could group by week (or month) but I don't
see how it can show me counts which are on the rise.
Thanks for your help.

I need some advice before starting VB/SQL Project

I am just in the process of learning VB.NET so that I can upsize an access database that I developed for my company.

I need advise on two subjects:
First, I am going to be starting a new VB.NET / SQL project using MSDE installed on my development computer. What do I need to do to allow me to easily deploy the program on several workstations and a dedicated server once development is finished?

Second, I would like to have a transitional period where both the VBA in the current MDB and the new VB.NET project access the same data. The one solution that I came up with was creating queries on the SQL server that pointed to the MDB, then once I am comfortable with the VB.NET end of things I would transfer the data it's self to the SQL server and change the queries to point to the new data location... However I have no idea weather or not this will work or if it is even close to being a good idea.

Any advice would be greatly appreciated.I wouldn't waste my time on developing in Access and then moving to SQL Server. Just start with the latter!|||Michael Kaiser

Brett Smith

Geez I thought I was unique...

Anyway, take rdjabarov's advice...

You can easily set up an Access mdb and link the sql server tables to it...

Don't bother with Jet...or don't you have sql server installed yet?

Or is it an existing application already?

How big is the database (or how big will it be?)

Also, you don't mention anything about stored procedures...

Do you plan on using them...it would be a big plus, especially for you're design implementation...|||Absolutely. Creating queries in SQL Server that point to data in a transitional Access database is going to cause you more trouble than just building the tables in SQL Server to begin with.

Hey, I like Access a lot, but there is really no point in using it in your development if it is not going to be part of your final solution.

If your data is already in Access, then it is worth trying the Upsizing wizard. I've used it once or twice and I seem to recall that it did a decent job. If you need a transitional application, then move your existing forms and code into a Microsoft Access Data Project that is tied directly to your SQL server database.|||Unfortunately I am already up to my eyeballs in Access
This is at the moment the primary issue tracking system for the small consulting firm that I work for. Hundreds of contacts, thousands of related records... and it has only been in use for about 6 months.

What I need to do is develop the project in vb and slowly transfer functionality over as modules get debugged.

To answer the other question about stored procedures, I am definitely going to be using them.|||I'm a little confused (and that's on a good day)...

Is the data centraly located, or does each client have their own copy of the data?|||Then again, I think you would be best off if you transfered the data to Microsoft SQL server and converted your Access database into an Access Data Project while you transition to your final solution.|||The data is centrally located in a mdb that only contains tables and each client has their own MDB file which has all the forms reports and VBA and links to the tables on the main database

I won't even begin to try to explain how this configuration came about, just keep in mind that decisions like that came about via committee and I (the actual developer) was not invited.|||Well, that's not a bad configuration for a distributed Microsoft Acces solution, but it does make your upsizing more difficult.

You could still develop an Access Data Project file and distribute it to your users. If you import your forms and modules it should look identical to them. Somewhere, you are going to have to bite the administrative bullet and come up with the transition strategy that best suits your business.|||I guess at this point I am going to look into an ADP, what I was hoping to avoid was spending any more time in access when it's not in the final plan. I know that the upsize wizard will not work for most of my forms and two of my tables, but I may just have to do it and get it over with|||Just another thought, would it make senct to just migrate the data to SQL and then change the links in the client MDB files to point to the SQL tables via an ODBC connection rather than actually transfer everything over to an ADP?|||I would...

a data source is a data source...

Only downside depends on the complexity of the forms/reports...

could be a lot slower depending on the # of connections opened by a form or report..|||Sure. Just make sure your security is good. Also, chances are good that you performance will be significantly slower than if you used an ADP interface.|||This is looking like my best option.

The last question on that front would be does anyone know if I like an Access MDB to SQL via ODBC can I use a SQL View for the source and meke it appear to Access to be a linked table?

I would only want to do this for two of the tables, because I would like to make some changes to the table field names.|||Yeah...check it out...they'll appear just like tables...

Just make sure that the view is updatable...otherwise it'll be a problem...|||I would get away from linked objects all together and replace them with pass-through queries to guarantee a more-or-less reasonable performance (I still don't understand why you would want to stick to Access to be your middle man.)

And to answer your question, - yes you can set a view as a source for a linked object.|||I think I am on my way!

I am sure that I will be back soon with other questions, but this should at least allow me to get my data onto SQL wile making very minor changes to the current Access database.

I need Proof!

Not the alcohol kind!!
We're log shipping from one db to another in SQL 2000 and when I turn off
log shipping and move to the new server I need to be able to prove that the
two DB copies are identical bit for bit.
Is there an internal change number that I can get at with this info. Oracle
calls it the system change number.
We cannot for auditing reasons do things like: visually inspect tables,
create a final table and verify it gets applied, drop an object and once it's
dropped on the recipient move forward. Because of our Financial system
requirements, think Sarbanes Oxley, I need to be able to PROVE it with a
command, not something else.
That said, can anyone help? I thought dbcc dbinfo might do it but it
doesn't appear to be the case.
Many thanks!!!!
--
burt_king@.yahoo.comHmmm...you can check the status (success) and time/date for the t-log
backup, copy and restore jobs. Or if needed perhaps a third-party data
comparision tool like RedGate's Data Compare or ApexSQL's Diff tool.
HTH
Jerry
"burt_king" <burt_king@.yahoo.com> wrote in message
news:5EA89F29-EA3F-4793-ADD2-54411D06FE02@.microsoft.com...
> Not the alcohol kind!!
> We're log shipping from one db to another in SQL 2000 and when I turn off
> log shipping and move to the new server I need to be able to prove that
> the
> two DB copies are identical bit for bit.
> Is there an internal change number that I can get at with this info.
> Oracle
> calls it the system change number.
> We cannot for auditing reasons do things like: visually inspect tables,
> create a final table and verify it gets applied, drop an object and once
> it's
> dropped on the recipient move forward. Because of our Financial system
> requirements, think Sarbanes Oxley, I need to be able to PROVE it with a
> command, not something else.
> That said, can anyone help? I thought dbcc dbinfo might do it but it
> doesn't appear to be the case.
> Many thanks!!!!
> --
> burt_king@.yahoo.com|||copy and restore are proof enough for me,,,, but not the company. I need to
run a command which says, "what's the current version of the database?" and
both the source and destination should be the same.
--
burt_king@.yahoo.com
"Jerry Spivey" wrote:
> Hmmm...you can check the status (success) and time/date for the t-log
> backup, copy and restore jobs. Or if needed perhaps a third-party data
> comparision tool like RedGate's Data Compare or ApexSQL's Diff tool.
> HTH
> Jerry
> "burt_king" <burt_king@.yahoo.com> wrote in message
> news:5EA89F29-EA3F-4793-ADD2-54411D06FE02@.microsoft.com...
> > Not the alcohol kind!!
> >
> > We're log shipping from one db to another in SQL 2000 and when I turn off
> > log shipping and move to the new server I need to be able to prove that
> > the
> > two DB copies are identical bit for bit.
> >
> > Is there an internal change number that I can get at with this info.
> > Oracle
> > calls it the system change number.
> >
> > We cannot for auditing reasons do things like: visually inspect tables,
> > create a final table and verify it gets applied, drop an object and once
> > it's
> > dropped on the recipient move forward. Because of our Financial system
> > requirements, think Sarbanes Oxley, I need to be able to PROVE it with a
> > command, not something else.
> >
> > That said, can anyone help? I thought dbcc dbinfo might do it but it
> > doesn't appear to be the case.
> >
> > Many thanks!!!!
> > --
> > burt_king@.yahoo.com
>
>|||Like Jerry said, your best bet is probably a third-party tool for an
extremely strict data versioning requirement like that.
"burt_king" <burt_king@.yahoo.com> wrote in message
news:04BEEA1F-7FB3-4095-A784-870A95A6F0C4@.microsoft.com...
> copy and restore are proof enough for me,,,, but not the company. I need
> to
> run a command which says, "what's the current version of the database?"
> and
> both the source and destination should be the same.
> --
> burt_king@.yahoo.com
>
> "Jerry Spivey" wrote:
>> Hmmm...you can check the status (success) and time/date for the t-log
>> backup, copy and restore jobs. Or if needed perhaps a third-party data
>> comparision tool like RedGate's Data Compare or ApexSQL's Diff tool.
>> HTH
>> Jerry
>> "burt_king" <burt_king@.yahoo.com> wrote in message
>> news:5EA89F29-EA3F-4793-ADD2-54411D06FE02@.microsoft.com...
>> > Not the alcohol kind!!
>> >
>> > We're log shipping from one db to another in SQL 2000 and when I turn
>> > off
>> > log shipping and move to the new server I need to be able to prove that
>> > the
>> > two DB copies are identical bit for bit.
>> >
>> > Is there an internal change number that I can get at with this info.
>> > Oracle
>> > calls it the system change number.
>> >
>> > We cannot for auditing reasons do things like: visually inspect tables,
>> > create a final table and verify it gets applied, drop an object and
>> > once
>> > it's
>> > dropped on the recipient move forward. Because of our Financial
>> > system
>> > requirements, think Sarbanes Oxley, I need to be able to PROVE it with
>> > a
>> > command, not something else.
>> >
>> > That said, can anyone help? I thought dbcc dbinfo might do it but it
>> > doesn't appear to be the case.
>> >
>> > Many thanks!!!!
>> > --
>> > burt_king@.yahoo.com
>>|||try
DBCC fileheader [( {'dbname' | dbid} [, fileid])
--
Aleksandar Grbic
"burt_king" wrote:
> Not the alcohol kind!!
> We're log shipping from one db to another in SQL 2000 and when I turn off
> log shipping and move to the new server I need to be able to prove that the
> two DB copies are identical bit for bit.
> Is there an internal change number that I can get at with this info. Oracle
> calls it the system change number.
> We cannot for auditing reasons do things like: visually inspect tables,
> create a final table and verify it gets applied, drop an object and once it's
> dropped on the recipient move forward. Because of our Financial system
> requirements, think Sarbanes Oxley, I need to be able to PROVE it with a
> command, not something else.
> That said, can anyone help? I thought dbcc dbinfo might do it but it
> doesn't appear to be the case.
> Many thanks!!!!
> --
> burt_king@.yahoo.com|||DBCC fileheader doesn't appear to match the two for a log shipping server.
Sorry.
--
burt_king@.yahoo.com
"Aleksandar Grbic" wrote:
> try
> DBCC fileheader [( {'dbname' | dbid} [, fileid])
> --
> Aleksandar Grbic
>
> "burt_king" wrote:
> > Not the alcohol kind!!
> >
> > We're log shipping from one db to another in SQL 2000 and when I turn off
> > log shipping and move to the new server I need to be able to prove that the
> > two DB copies are identical bit for bit.
> >
> > Is there an internal change number that I can get at with this info. Oracle
> > calls it the system change number.
> >
> > We cannot for auditing reasons do things like: visually inspect tables,
> > create a final table and verify it gets applied, drop an object and once it's
> > dropped on the recipient move forward. Because of our Financial system
> > requirements, think Sarbanes Oxley, I need to be able to PROVE it with a
> > command, not something else.
> >
> > That said, can anyone help? I thought dbcc dbinfo might do it but it
> > doesn't appear to be the case.
> >
> > Many thanks!!!!
> > --
> > burt_king@.yahoo.com

I need Proof!

Not the alcohol kind!!
We're log shipping from one db to another in SQL 2000 and when I turn off
log shipping and move to the new server I need to be able to prove that the
two DB copies are identical bit for bit.
Is there an internal change number that I can get at with this info. Oracle
calls it the system change number.
We cannot for auditing reasons do things like: visually inspect tables,
create a final table and verify it gets applied, drop an object and once it'
s
dropped on the recipient move forward. Because of our Financial system
requirements, think Sarbanes Oxley, I need to be able to PROVE it with a
command, not something else.
That said, can anyone help? I thought dbcc dbinfo might do it but it
doesn't appear to be the case.
Many thanks!!!!
--
burt_king@.yahoo.comHmmm...you can check the status (success) and time/date for the t-log
backup, copy and restore jobs. Or if needed perhaps a third-party data
comparision tool like RedGate's Data Compare or ApexSQL's Diff tool.
HTH
Jerry
"burt_king" <burt_king@.yahoo.com> wrote in message
news:5EA89F29-EA3F-4793-ADD2-54411D06FE02@.microsoft.com...
> Not the alcohol kind!!
> We're log shipping from one db to another in SQL 2000 and when I turn off
> log shipping and move to the new server I need to be able to prove that
> the
> two DB copies are identical bit for bit.
> Is there an internal change number that I can get at with this info.
> Oracle
> calls it the system change number.
> We cannot for auditing reasons do things like: visually inspect tables,
> create a final table and verify it gets applied, drop an object and once
> it's
> dropped on the recipient move forward. Because of our Financial system
> requirements, think Sarbanes Oxley, I need to be able to PROVE it with a
> command, not something else.
> That said, can anyone help? I thought dbcc dbinfo might do it but it
> doesn't appear to be the case.
> Many thanks!!!!
> --
> burt_king@.yahoo.com|||copy and restore are proof enough for me,,,, but not the company. I need t
o
run a command which says, "what's the current version of the database?" and
both the source and destination should be the same.
--
burt_king@.yahoo.com
"Jerry Spivey" wrote:

> Hmmm...you can check the status (success) and time/date for the t-log
> backup, copy and restore jobs. Or if needed perhaps a third-party data
> comparision tool like RedGate's Data Compare or ApexSQL's Diff tool.
> HTH
> Jerry
> "burt_king" <burt_king@.yahoo.com> wrote in message
> news:5EA89F29-EA3F-4793-ADD2-54411D06FE02@.microsoft.com...
>
>|||Like Jerry said, your best bet is probably a third-party tool for an
extremely strict data versioning requirement like that.
"burt_king" <burt_king@.yahoo.com> wrote in message
news:04BEEA1F-7FB3-4095-A784-870A95A6F0C4@.microsoft.com...[vbcol=seagreen]
> copy and restore are proof enough for me,,,, but not the company. I need
> to
> run a command which says, "what's the current version of the database?"
> and
> both the source and destination should be the same.
> --
> burt_king@.yahoo.com
>
> "Jerry Spivey" wrote:
>|||try
DBCC fileheader [( {'dbname' | dbid} [, fileid])
--
Aleksandar Grbic
"burt_king" wrote:

> Not the alcohol kind!!
> We're log shipping from one db to another in SQL 2000 and when I turn off
> log shipping and move to the new server I need to be able to prove that th
e
> two DB copies are identical bit for bit.
> Is there an internal change number that I can get at with this info. Orac
le
> calls it the system change number.
> We cannot for auditing reasons do things like: visually inspect tables,
> create a final table and verify it gets applied, drop an object and once i
t's
> dropped on the recipient move forward. Because of our Financial system
> requirements, think Sarbanes Oxley, I need to be able to PROVE it with a
> command, not something else.
> That said, can anyone help? I thought dbcc dbinfo might do it but it
> doesn't appear to be the case.
> Many thanks!!!!
> --
> burt_king@.yahoo.com|||DBCC fileheader doesn't appear to match the two for a log shipping server.
Sorry.
--
burt_king@.yahoo.com
"Aleksandar Grbic" wrote:
[vbcol=seagreen]
> try
> DBCC fileheader [( {'dbname' | dbid} [, fileid])
> --
> Aleksandar Grbic
>
> "burt_king" wrote:
>

I need Optimised duplicate finding query

I have a query which is like this
Select field a, field b,field c, field d from table1 where field d not in
(select distinct field d from table 2)
Table 1 has 35000 records
Table 2 has 12391876 records
Field d is of type varchar.
If there is any duplicate to be found in table 2 then the insertion from
table 1 to table 2 will not happen.
I need this query to be get optimised.Hi
DECLARE @.rowcount INT
SELECT Field1,COUNT(*) FROM Table2
GROUP BY Field1
HAVING COUNT(*)>1
SET @.rowcount =@.@.ROWCOUNT
IF @.rowcount >0 --Do exist duplicate rows
.........
"Cynthia" <Cynthia@.discussions.microsoft.com> wrote in message
news:CDCF5DF6-52FA-4D80-AAED-1F3803720972@.microsoft.com...
>I have a query which is like this
> Select field a, field b,field c, field d from table1 where field d not in
> (select distinct field d from table 2)
>
> Table 1 has 35000 records
> Table 2 has 12391876 records
> Field d is of type varchar.
>
> If there is any duplicate to be found in table 2 then the insertion from
> table 1 to table 2 will not happen.
>
> I need this query to be get optimised.
>|||I understand that the below query is used for finding out a duplicate value
in table2.
Note : field d contains <FILE NAME> . if there are 20 records in a file then
20 records will have the same filename and so on. A group of files will be
imported to the temporary table (table 1). Before inserting it to the main
table (table 2) a check is done whether that file is existing in the main
table. If it is existing then the insertion process will not done in order t
o
avoid duplicate file being entered into the main table.
We use the below said query given by me for this task.
So I need a optimised query.
"Uri Dimant" wrote:

> Hi
> DECLARE @.rowcount INT
> SELECT Field1,COUNT(*) FROM Table2
> GROUP BY Field1
> HAVING COUNT(*)>1
> SET @.rowcount =@.@.ROWCOUNT
> IF @.rowcount >0 --Do exist duplicate rows
> ..........
> "Cynthia" <Cynthia@.discussions.microsoft.com> wrote in message
> news:CDCF5DF6-52FA-4D80-AAED-1F3803720972@.microsoft.com...
>
>|||> So I need a optimised query.
CREATE indexes to optimize your query
http://www.sql-server-performance.c...red_indexes.asp
http://www.sql-server-performance.c...red_indexes.asp
http://www.sql-server-performance.c...ing_indexes.asp
"Cynthia" <Cynthia@.discussions.microsoft.com> wrote in message
news:2B4DD3B0-5BFE-4984-9726-9036457E8EA1@.microsoft.com...
>I understand that the below query is used for finding out a duplicate value
> in table2.
> Note : field d contains <FILE NAME> . if there are 20 records in a file
> then
> 20 records will have the same filename and so on. A group of files will be
> imported to the temporary table (table 1). Before inserting it to the main
> table (table 2) a check is done whether that file is existing in the main
> table. If it is existing then the insertion process will not done in order
> to
> avoid duplicate file being entered into the main table.
> We use the below said query given by me for this task.
> So I need a optimised query.
> "Uri Dimant" wrote:
>|||You might try using a not exists instead of not in. Not in will select all
12,391,876 rows from table2 then order them and summarize them, which
requires a fiar amount of in memory processing. The Not exists will check
table2 for each row in table1, meaning a maximum of 35,000 lookups. Note,
this will be faster if you have an index on table2.fieldd, but may be much
slower is this index does not exist.
Select fielda, fieldb,fieldc, fieldd from table1 t1 where not exists
(select 1 from table2 t2 where t2.fieldd = t1.fieldd)
"Cynthia" <Cynthia@.discussions.microsoft.com> wrote in message
news:CDCF5DF6-52FA-4D80-AAED-1F3803720972@.microsoft.com...
> I have a query which is like this
> Select field a, field b,field c, field d from table1 where field d not in
> (select distinct field d from table 2)
>
> Table 1 has 35000 records
> Table 2 has 12391876 records
> Field d is of type varchar.
>
> If there is any duplicate to be found in table 2 then the insertion from
> table 1 to table 2 will not happen.
>
> I need this query to be get optimised.
>

I need more

Hi,

Thanks for your answer,

It is a good solution but i need something like a free software from microsoft can do that , or a free script that do this simply because i am not familiar with .Net Programming

Express Advanced comes with most things in the for pay version and it is free you can download it in the link below.

http://msdn.microsoft.com/vstudio/express/sql/download/

|||

You know my sql server is SQL server 2000 express, Does this software work for me?

|||

There is no 2000 Express just MSDE(Microsoft data engine), SQL Server 2005 Express Advanced comes with most of the features of the other SQL Server editions and it is still free, MSDE does not come with Enterprise Manager, this one comes with Management Studio the new Enterprsie Manager. So download and install it as a named instance. Hope this helps.

i need info

Now i'm migrating my SQL server SP and triggers from v6.5 to 7.0... but i need the some convertion table of data types between 6.5 to 7.0
do somebody have this convert table with the rules?You might want to take a look at "Installing SQL Server -> Upgrading from earlier version" section in SQL 7 book online. There's a well of info there.

I need identity on updatable partitioned view

Ok, already read that is not allowed to have identity column in any member table of a updateable partitioned view.

But I need an identity column. Is there any other way or ide how to solve this problem?

This is one of the situation where using a column with a uniqueidentifier datatype, set to a default of newid() is the 'right' solution.|||It does not work...|||

I have to disagree with you on that!

What are you attempting to accomplish, and what steps have you taken so far.

Please include the TABLE and VIEW DDL.

|||

create table bileta_te_lozura_2007_01

(id int not null,

databiletes datetime not null check (databiletes>=cast('20070101' as datetime) and databiletes<cast('20070201' as datetime)),

constraint [pkjan2007] primary key clustered ([id],[databiletes]) with fillfactor=50 on [primary]

)

create table bileta_te_lozura_2007_02

(id int not null,

databiletes datetime not null check (databiletes>=cast('20070201' as datetime) and databiletes<cast('20070301' as datetime)),

constraint [pkshk2007] primary key clustered ([id],[databiletes]) with fillfactor=50 on [primary]

)

create view bileta_te_lozura

as

select * from bileta_te_lozura_2007_01

union all

select * from bileta_te_lozura_2007_02

I need ID to be an unique ID

For the whole view not only for one table!

|||

Try this:

CREATE TABLE bileta_te_lozura_2007_01
( ID uniqueidentifier DEFAULT newid() NOT NULL,
DataBiletes datetime NOT NULL CHECK ( DataBiletes >= cast( '20070101' AS datetime ) AND DataBiletes < cast( '20070201' as datetime )),
CONSTRAINT [pkjan2007] PRIMARY KEY CLUSTERED ([ID],[DataBiletes]) WITH FILLFACTOR = 50 ON [primary]
)

CREATE TABLE bileta_te_lozura_2007_02
( ID uniqueidentifier DEFAULT newid() NOT NULL,
DataBiletes datetime NOT NULL CHECK ( DataBiletes >= cast( '20070201' AS datetime ) AND DataBiletes < cast( '20070301' as datetime )),
CONSTRAINT [pkshk2007] PRIMARY KEY CLUSTERED ([ID],[DataBiletes]) WITH FILLFACTOR = 50 ON [primary]
)

CREATE VIEW dbo.bileta_te_lozura
AS
SELECT * FROM bileta_te_lozura_2007_01
UNION ALL
SELECT * FROM bileta_te_lozura_2007_02

|||

That will create an unique identifier column, not an integer column. Looking that all this is done because table can be be very large i'm affraid for performance issues using rowguid things...

I mean, if i query as follows:

select aa,bb,cc from bileta_te_lozura where id='233acf-sdffd-sdfsdfs-sdfsf-sdfssss'

have the same performance with:

select aa,bb,cc from bileta_te_lozura where id=1167876

Every table has some million rows.

Anyway... this also does not work. It report error during insert

Partitioned view 'renis.dbo.bileta_te_lozura' is not updatable because table '[renis].[dbo].[bileta_te_lozura_2007_01]' has a DEFAULT constraint.

|||

Ok Regis,

I'm starting to get a better idea about your situation. I think that if you do not have a primary key for the data, and that if you need to create a surrogate key, and since IDENTITY is not available in this situation, you may have to create a 'Table of Numbers' and get/increment the new value before each INSERT. One option would be having a Staging table, where the IDENTITY column does exist, and then immediately (after the IDENTITY value is assigned) move the data to your partitioned tables.

I also caution you that having a new table for every month will rapidly become burdensome. If you are using SQL 2005, you may wish to investigate table partitioning -and if you are not using SQL 2005, table partitioning may be the reason to upgrade. See Books Online, topic: [Partitioned Tables]

Distributed Partitioned Views (DPV) are best suited for multiple servers.

|||I tried and resolved this problem using partition tables... With partition views this was impossible, (not impossible, but just too long and complicated, which in generall means a lot of bugs)

i need idea for bus transport databse

i have many buses that drive between many cities. some of the buses connect
more than 2 cities in one line...Homework assignment?
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--
"TomislaW" <tomislav147@.hotmail.com> wrote in message
news:%23WxwyI7LFHA.2384@.tk2msftngp13.phx.gbl...
> i have many buses that drive between many cities. some of the buses
connect
> more than 2 cities in one line...
>|||Homework or do you want to hire someone?
Take a look at:
http://www.databaseanswers.org/data_models/index.htm
David Portas
SQL Server MVP
--|||Hi
<http://www.databaseanswers.com/data_models/index.htm> -- examples
database design
"TomislaW" <tomislav147@.hotmail.com> wrote in message
news:%23WxwyI7LFHA.2384@.tk2msftngp13.phx.gbl...
> i have many buses that drive between many cities. some of the buses
connect
> more than 2 cities in one line...
>|||Without knowing more (and really understanding your need) it will be
difficult to make recommendations. Look at the things that you need to
track. Group them logically. Some things that come to mind are:
Bus (one row per bus)
Location (stops)
Route (itinerary -- stops that make up a trip)
Passenger
Keith
"TomislaW" <tomislav147@.hotmail.com> wrote in message
news:%23WxwyI7LFHA.2384@.tk2msftngp13.phx.gbl...
> i have many buses that drive between many cities. some of the buses
connect
> more than 2 cities in one line...
>|||Check out the 6th installment of this MSDN article on data structures;
particularly about Graphs...
http://msdn.microsoft.com/vcsharp/d...uctures20_1.asp
"Keith Kratochvil" wrote:

> Without knowing more (and really understanding your need) it will be
> difficult to make recommendations. Look at the things that you need to
> track. Group them logically. Some things that come to mind are:
> Bus (one row per bus)
> Location (stops)
> Route (itinerary -- stops that make up a trip)
> Passenger
> --
> Keith
>
> "TomislaW" <tomislav147@.hotmail.com> wrote in message
> news:%23WxwyI7LFHA.2384@.tk2msftngp13.phx.gbl...
> connect
>|||>> Homework assignment? <<
This is one I used to give students myself! The gimmick was adding the
temporal parts to the graph.

i need help: SiteBuilder for Windows (sitebuilder-3.0.2_build060426.365_win.exe) installatio

where i can download service pack for windows server 2003

Lameck -

Can you confirm that you are running Windows 2003 Sp1 this is a pre-reg for Sitebuilder - you should confirm the other pre-reqs as well by referencing: http://www.swsoft.com/en/products/sitebuilder/win/reqs/

I would guess that your system does not have Windows 2003 SP1 installed so I would recommend going here downloading it and installing it: http://www.microsoft.com/technet/downloads/winsrvr/servicepacks/sp1/default.mspx - you can confirm its installed by right clicking on My computer on your desktop selecting properties and looking at the system details on the General Tab.

Thanks,

AWAL

|||

thanks. unfortunately theyre all not win32 applications.

|||

Lameck -

You should only install 1 OS Service Pack - You can't be running Windows 2003, XP and Small Business Service on the same machine - can you go to My Computer and look under General Tab in the System area and determine what OS you are running (and what Service Pack its currently at)?

Also why are you installing Exchange Service pack - is this machine an Exchange Server?

Thanks

AWAL

I need help...!

Hello!
I am using IN to determine if a given StateId values matches any value in a
query.
Previously, I used following query:
SELECT * FROM Cities WHERE StateId IN (1, 2, 3)
but now I would like to pass dynamic values as a input parameter...
SELECT * FROM Cities WHERE StateId IN(@.StateId)
StateId is an integer.
Could anyone help me with this, I can't get it working. I am new to SQL
Server.
Thank you!
JamesJames
CREATE PROCEDURE mysp
@.array nvarchar(4000)
AS
BEGIN
SET NOCOUNT ON
DECLARE @.nsql nvarchar(4000)
SET @.nsql = '
SELECT *
FROM sysobjects
WHERE name IN ( ' + @.array + ')'
PRINT @.nsql
EXEC sp_executesql @.nsql
END
GO
EXEC mysp
@.array = '''sysobjects'',''sysindexes'',''syscolu
mns'''
GO
"James T." <gimenei@.hotmail.com> wrote in message
news:O7P%23D8dOFHA.3356@.TK2MSFTNGP12.phx.gbl...
> Hello!
> I am using IN to determine if a given StateId values matches any value in
a
> query.
> Previously, I used following query:
> SELECT * FROM Cities WHERE StateId IN (1, 2, 3)
> but now I would like to pass dynamic values as a input parameter...
> SELECT * FROM Cities WHERE StateId IN(@.StateId)
> StateId is an integer.
> Could anyone help me with this, I can't get it working. I am new to SQL
> Server.
> Thank you!
> James
>|||The Curse and Blessings of Dynamic SQL
http://www.sommarskog.se/dynamic_sql.html
Arrays and Lists in SQL Server
http://www.sommarskog.se/arrays-in-sql.html
Faking arrays in T-SQL stored procedures
http://www.bizdatasolutions.com/tsql/sqlarrays.asp
How do I simulate an array inside a stored procedure?
http://www.aspfaq.com/show.asp?id=2248
AMB
"James T." wrote:

> Hello!
> I am using IN to determine if a given StateId values matches any value in
a
> query.
> Previously, I used following query:
> SELECT * FROM Cities WHERE StateId IN (1, 2, 3)
> but now I would like to pass dynamic values as a input parameter...
> SELECT * FROM Cities WHERE StateId IN(@.StateId)
> StateId is an integer.
> Could anyone help me with this, I can't get it working. I am new to SQL
> Server.
> Thank you!
> James
>
>

I need Help.

Hi. I'm trying a SQL like this
SELECT MIN(PRICE) FROM TABLE1 WHERE ID=112 AND STATUS=1 GROUP BY ID
its returns me
PRICE
100
150
30
But i lik SQL like this
SELECT SUM(MIN(PRICE)) FROM TABLE1 WHERE ID=112 AND STATUS=1 GROUP BY ID
i want return like
PRICE
280
When i runs second SQL an error happens.
" Cannot perform an aggregate function on an expression containing an
aggregate or a subquery. "
_____________________________________________________________
Murat FÝDANOne way
SELECT SUM(MinPrice)AS SumPrice
FROM (SELECT MIN(PRICE) AS MinPrice
FROM TABLE1
WHERE ID=3D112
AND STATUS=3D1
GROUP BY ID )x
Denis The SQL Menace
http://sqlservercode.blogspot.com
http://sqlblog.com/blogs/denis_gobo/default.aspx
On Aug 23, 9:04 am, "Murat Fidan" <murat.fi...@.tekdurak.com> wrote:
> Hi. I'm trying a SQL like this
> SELECT MIN(PRICE) FROM TABLE1 WHERE ID=3D112 AND STATUS=3D1 GROUP BY ID
> its returns me
> PRICE
> 100
> 150
> 30
> But i lik SQL like this
> SELECT SUM(MIN(PRICE)) FROM TABLE1 WHERE ID=3D112 AND STATUS=3D1 GROUP BY= ID
> i want return like
> PRICE
> 280
> When i runs second SQL an error happens.
> " Cannot perform an aggregate function on an expression containing an
> aggregate or a subquery. "
> _____________________________________________________________
> Murat F=DDDAN|||Murat Fidan,
Use a derived table.
select sum(min_price)
from
(
SELECT MIN(PRICE) as min_price
FROM TABLE1
WHERE ID=112 AND STATUS=1
GROUP BY ID
) as t
go
AMB
"Murat Fidan" wrote:
> Hi. I'm trying a SQL like this
> SELECT MIN(PRICE) FROM TABLE1 WHERE ID=112 AND STATUS=1 GROUP BY ID
> its returns me
> PRICE
> 100
> 150
> 30
> But i lik SQL like this
> SELECT SUM(MIN(PRICE)) FROM TABLE1 WHERE ID=112 AND STATUS=1 GROUP BY ID
> i want return like
> PRICE
> 280
>
> When i runs second SQL an error happens.
> " Cannot perform an aggregate function on an expression containing an
> aggregate or a subquery. "
>
> _____________________________________________________________
> Murat FÃ?DAN
>
>

I need help, please...

I have 3 tables - 2 source, 1 destination. All tables have 2 IDs. One
is ID of a person, the other is sort of a 'segment' ID. This segment ID
defines the department. The destination table is a new table that is to
hold data from the old ones.
The problem is copying from the old tables, coz the IDs of persons do
not match - i.e. the first table contains IDs not present in the second
table and the second table contains IDs that the first one doesn't. The
majority exist in both.
I first tryed a left join only to find the missing IDs in both tables
as stated previously. Then I tryed to copy the tables separately of
each other, then I tryed in reverse order, but foud that I was always
left with missing data. That is, all person IDs were in the destination
table with their segment IDs but still missing some data in other
fields.

Table A (old)
+----+---+----------+
| PersID | SegID | -some other data not in B- |
+----+---+----------+
| 1 | 1 | . . . |
| 2 | 1 | . . . |
| 3 | 1 | . . . |
| 4 | 2 | . . . |
| 5 | 2 | . . . |
| 6 | 2 | . . . |
| 7 | 2 | . . . | <-- missing in B
| 8 | 2 | . . . | <-- missing in B
| 9 | 2 | . . . |
| 11 | 3 | . . . |
| . . . | . . . | . . . |
+----+---+----------+

Table B (old)
+----+---+----------+
| PersID | SegID | -some other data not in A- |
+----+---+----------+
| 1 | 1 | . . . |
| 2 | 1 | . . . |
| 3 | 1 | . . . |
| 4 | 2 | . . . |
| 5 | 2 | . . . |
| 6 | 2 | . . . |
| 9 | 2 | . . . |
| 10 | 2 | . . . | <-- missing in A
| 11 | 2 | . . . | <-- missing in A
| 11 | 3 | . . . |
| . . . | . . . | . . . |
+----+---+----------+

Table C (new)
+----+---+----------+
| PersID | SegID | -other data from A and B- |
+----+---+----------+
| 1 | 1 | . . . |
| 2 | 1 | . . . |
| 3 | 1 | . . . |
| 4 | 2 | . . . |
| 5 | 2 | . . . |
| 6 | 2 | . . . |
| 7 | 2 | . . . | <-- not a problem
| 8 | 2 | . . . | <-- not a problem
| 9 | 2 | . . . |
| 10 | 2 | . . . | <-- not a problem
| 11 | 2 | . . . | <-- not a problem
| 11 | 3 | . . . | <-- not a problem
| . . . | . . . | . . . |
+----+---+----------+

Table C has data missing because some data isn't present in A or B. In
addition C has missing data that tables A or B do have!!! This is the
problem I'm solving for some time now and am at an end (with nervs,
ideas, etc.).

I hope I've explained the problem thoroughly enough and that you can
help.

I am very close to dead line so please help...

P.S.
DB is Oracle 9.2

Thank you.Do you JOIN Table (A) and Table (B) together? I mean do you have to join them to populate Table C properly (some columns are only in Table A and some only in Table B) or if you insert e.g. record from A you insert all its attributes into C (you don't need any attribute from Table B)?|||Data from table B can be faked and later updated into C.|||what's wrong on this?:

INSERT INTO TableC
SELECT * FROM TableA
UNION ALL
SELECT * FROM TableB where PersID not in (SELECT PersID FROM TableA)

I need help, please

I have a problem with my sql server.
I use a lot of Request.QueryString("Index1")
But the Request.QueryString is always the same.
I use in If-Loops.

The server send me the follow message:
Response Buffer Limit Exceeded

Execution of the ASP page caused the Response Buffer to exceed its
configured limit

Can everybody help me, please.
Thank you.Hi,

Sorry but thats not a SQL Server question, youd better give it a try
in the ASP groups.

HTH, jens Suessmeyer.

--
http://www.sqlserver2005.de
--|||As you say, this seems to be placed in an infinite loop and so the
'buffer exceeded limit' error.
try a smaller loop like
while i < 3
Request.QueryString(...)
....

and see what gets printed.

also this is ASP error not an SQL Server.

I need help with xmla query

Hi,

I need to do a xmla query for calling more than one prespective. For example:

I have a cube with 4 perspectives, but in the xmla query only need 2 perspectives.

Cube: Censo
Perspectives: Depto.
Pais
Principal
Privado

But i only need
Cube: Censo
Perspectives: Depto
PaisI'm not sure I entirely understand your question, but if you need to reference objects from 2 different prespectives you should be able to just query the underlying cube.|||Sorry if i don't explain well my question... but here put a example.

I have this query:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<Discover xmlns="urn:schemas-microsoft-com:xml-analysis">
<RequestType>MDSCHEMA_CUBES</RequestType>
<Restrictions>
<RestrictionList>
<CUBE_NAME>Depto</CUBE_NAME>
<CUBE_NAME>País</CUBE_NAME>
</RestrictionList>
</Restrictions>
<Properties>
<PropertyList>
<DataSourceInfo>SERVER</DataSourceInfo>
<Catalog>Censo</Catalog>
<Format>Tabular</Format>
<Content>SchemaData</Content>
</PropertyList>
</Properties>
</Discover>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

With this query only show me the País perspective, but i want show me Depto and País perspective because the cube have 4 perspectives.|||

Thanks for the example, now I understand what your are after. :)

Unfortunately I don't think you can have more than one CUBE_NAME element in your restriction list. What I believe is happening is that the value is being overwritten and the last one is the one that is used.

I think you have 2 options

1) fire off 2 separate Discover requests, one for each perspective

2) do not put any restrictions in the request and filter the results on the client side.

I need help with xmla query

Hi,

I need to do a xmla query for calling more than one prespective. For example:

I have a cube with 4 perspectives, but in the xmla query only need 2 perspectives.

Cube: Censo
Perspectives: Depto.
Pais
Principal
Privado

But i only need
Cube: Censo
Perspectives: Depto
PaisI'm not sure I entirely understand your question, but if you need to reference objects from 2 different prespectives you should be able to just query the underlying cube.|||Sorry if i don't explain well my question... but here put a example.

I have this query:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<Discover xmlns="urn:schemas-microsoft-com:xml-analysis">
<RequestType>MDSCHEMA_CUBES</RequestType>
<Restrictions>
<RestrictionList>
<CUBE_NAME>Depto</CUBE_NAME>
<CUBE_NAME>País</CUBE_NAME>
</RestrictionList>
</Restrictions>
<Properties>
<PropertyList>
<DataSourceInfo>SERVER</DataSourceInfo>
<Catalog>Censo</Catalog>
<Format>Tabular</Format>
<Content>SchemaData</Content>
</PropertyList>
</Properties>
</Discover>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

With this query only show me the País perspective, but i want show me Depto and País perspective because the cube have 4 perspectives.|||

Thanks for the example, now I understand what your are after. :)

Unfortunately I don't think you can have more than one CUBE_NAME element in your restriction list. What I believe is happening is that the value is being overwritten and the last one is the one that is used.

I think you have 2 options

1) fire off 2 separate Discover requests, one for each perspective

2) do not put any restrictions in the request and filter the results on the client side.

I need help with what appears to be a botched install.

Okay, i'm learning VB.NET (and having quite a bit of fun with it). Well, I had the old beta version. Anyway, went away for a week and found I could no longer use it. Why?

"Beta period is over.".

Yeah, it sucks.

Well, I uninstalled it via the uninstaller. I upgraded my .NET framework, etc, and redownloaded VB.NET. Everything installed okay, save for the SQL server. It repeatedly fails.

I have hunted down and shot each component quite ruthlessly, but I don't know what beta component remains. I can't get it to install because it says I have beta components left.

And VB.NET works. Barely. I had to disable the hosting process, otherwise it gives me a message about an invalid binding handle. Not often that a Beta product works better than the production one.

The uninstall tool won't work for some reason. I'm this close to just reformatting.

Please help, I'd like to code again.

Thanks.

bump|||Hi,

if you also had SQL Server beta installed you should also deinstall SQL Server as in the Beta period the SQL Server framework version and the version of the framework VS uses had to be in line.So installing VS / SQL Server / Framework version, reboot, installing SQL Server / VS (Framework is installed with one of the two) should make your system running :-)

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

I need help with what appears to be a botched install.

Okay, i'm learning VB.NET (and having quite a bit of fun with it). Well, I had the old beta version. Anyway, went away for a week and found I could no longer use it. Why?

"Beta period is over.".

Yeah, it sucks.

Well, I uninstalled it via the uninstaller. I upgraded my .NET framework, etc, and redownloaded VB.NET. Everything installed okay, save for the SQL server. It repeatedly fails.

I have hunted down and shot each component quite ruthlessly, but I don't know what beta component remains. I can't get it to install because it says I have beta components left.

And VB.NET works. Barely. I had to disable the hosting process, otherwise it gives me a message about an invalid binding handle. Not often that a Beta product works better than the production one.

The uninstall tool won't work for some reason. I'm this close to just reformatting.

Please help, I'd like to code again.

Thanks.

bump|||Hi,

if you also had SQL Server beta installed you should also deinstall SQL Server as in the Beta period the SQL Server framework version and the version of the framework VS uses had to be in line.So installing VS / SQL Server / Framework version, reboot, installing SQL Server / VS (Framework is installed with one of the two) should make your system running :-)

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

I need help with Transactional Replication

I am just beginning with transactional replication, and I have a publisher
with a primary key on the identity column (UID), some data, then an adddate
(varchar 8) column iwth ccyymmdd data in it. I want to replicate this table
to a server based on the adddate value (all records pushed since a given
adddate). My replication attempts seem to only want to work off of the
primary key column. How do I get it to work off of the adddate column, or do
I even really want to?
Thank you for any help in advance
The publisher (and subscriber) tables look like this:
create table temp (
uid bigint,
data_1 varchar(20),
adddate varchar(8)
)
Carl,
TR will only replicate the changes to this table since the last
synchronization. If new records have been added, they'll automatically be
picked up. With this in mind you can probably forget about filtering the
dddate column, unless I am misunderstanding you.
rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||ok, perhaps I have a different problem, then. When I update the publisher by
inserting numerous new rows, I manually run the distributer and it claims
that there are no rows to replicate. How can I get the distributor to see the
new rows?
"Paul Ibison" wrote:

> Carl,
> TR will only replicate the changes to this table since the last
> synchronization. If new records have been added, they'll automatically be
> picked up. With this in mind you can probably forget about filtering the
> dddate column, unless I am misunderstanding you.
> rgds,
> Paul Ibison SQL Server MVP, www.replicationanswers.com
> (recommended sql server 2000 replication book:
> http://www.nwsu.com/0974973602p.html)
>
>
|||Carl,
are you using a filter on the publication?
Is the log reader agent running?
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||There are no filters being used, and the log reader agent shows no errors.
"Paul Ibison" wrote:

> Carl,
> are you using a filter on the publication?
> Is the log reader agent running?
> Rgds,
> Paul Ibison SQL Server MVP, www.replicationanswers.com
> (recommended sql server 2000 replication book:
> http://www.nwsu.com/0974973602p.html)
>
>
|||Carl,
make a change to a row then run sp_browsereplcmds in the
distribution database to see if the rows are reaching
there.
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)

I need help with this tsql statement

Every time I try this statement I keep getting a syntext error near count I must be over looking something can some one help me with this.

SELECT 'Quarter 1' as 'qtr'
count(jobid) as 'transcount',
count(distinct job.patientid) as 'patientcount',
sum(job.LANGUAGE_TCOST) as 'lcost',
Sum(job.LANGUAGE_DISC_COST) as 'dlcost',
avg(LANGUAGE_DISC) as 'avgLDisc',
(sum(job.LANGUAGE_TCOST) + sum(job.LANGUAGE_DISC_COST)) as 'LGrossAmtBilled',
(sum(LANGUAGE_TCOST) / count(distinct job.patientid)) as 'PatAvgL',
(sum(LANGUAGE_TCOST) / count(jobid)) as 'RefAvgL',
sum(LANGUAGE_DISC) as 'avgPercentDiscL',
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE
INVOICE_AR.INVOICE_DATE AS EXPR1,
INVOICE_AR.AMOUNT_DUE

FROM JOB
INNER JOIN INVOICE_AR
ON JOB.JOBID = INVOICE_AR.JOBID
LEFT OUTER JOIN PAYER
ON PAYER.PAYERID = JOB.PAYER.ID
LEFT OUTER JOIN STATES
ON JOB.JURISDICTION = STATES.INITIALS

WHERE
(INVOICE_AR.AMOUNT_DUE > 0)
AND
(INVOICE-AR.INVOICE_DATE BETWEEN @.startdate and @.enddate)
AND
(MONTH(INVOICE_AR.INVOICE_DATE) IN (1,2,3))
AND
(PAYER.PAYCOMPANY like '%' + @.Company + '%')


Group By
JOB.JURISDICTION
PAYER.PAY_COMPANY
PAYER.PAY_CITY
PAYER.PAY_STATE
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE,
INVOICE_AR.AMOUNT_DUE

UNION ALL

SELECT 'Quarter 2' as 'qtr'
count(jobid) as 'transcount',
count(distinct job.patientid) as 'patientcount',
sum(job.LANGUAGE_TCOST) as 'lcost',
Sum(job.LANGUAGE_DISC_COST) as 'dlcost',
avg(LANGUAGE_DISC) as 'avgLDisc',
(sum(job.LANGUAGE_TCOST) + sum(job.LANGUAGE_DISC_COST)) as 'LGrossAmtBilled',
(sum(LANGUAGE_TCOST) / count(distinct job.patientid)) as 'PatAvgL',
(sum(LANGUAGE_TCOST) / count(jobid)) as 'RefAvgL',
sum(LANGUAGE_DISC) as 'avgPercentDiscL',
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE
INVOICE_AR.INVOICE_DATE AS EXPR1,
INVOICE_AR.AMOUNT_DUE

FROM JOB
INNER JOIN INVOICE_AR
ON JOB.JOBID = INVOICE_AR.JOBID
LEFT OUTER JOIN PAYER
ON PAYER.PAYERID = JOB.PAYER.ID
LEFT OUTER JOIN STATES
ON JOB.JURISDICTION = STATES.INITIALS

WHERE
(INVOICE_AR.AMOUNT_DUE > 0)
AND
(INVOICE-AR.INVOICE_DATE BETWEEN @.startdate and @.enddate)
AND
(MONTH(INVOICE_AR.INVOICE_DATE) IN (4,5,6))
AND
(PAYER.PAYCOMPANY like '%' + @.Company + '%')


Group By
JOB.JURISDICTION
PAYER.PAY_COMPANY
PAYER.PAY_CITY
PAYER.PAY_STATE
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE,
INVOICE_AR.AMOUNT_DUE

UNION ALL

SELECT 'Quarter 3' as 'qtr'
count(jobid) as 'transcount',
count(distinct job.patientid) as 'patientcount',
sum(job.LANGUAGE_TCOST) as 'lcost',
Sum(job.LANGUAGE_DISC_COST) as 'dlcost',
avg(LANGUAGE_DISC) as 'avgLDisc',
(sum(job.LANGUAGE_TCOST) + sum(job.LANGUAGE_DISC_COST)) as 'LGrossAmtBilled',
(sum(LANGUAGE_TCOST) / count(distinct job.patientid)) as 'PatAvgL',
(sum(LANGUAGE_TCOST) / count(jobid)) as 'RefAvgL',
sum(LANGUAGE_DISC) as 'avgPercentDiscL',
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE
INVOICE_AR.INVOICE_DATE AS EXPR1,
INVOICE_AR.AMOUNT_DUE

FROM JOB
INNER JOIN INVOICE_AR
ON JOB.JOBID = INVOICE_AR.JOBID
LEFT OUTER JOIN PAYER
ON PAYER.PAYERID = JOB.PAYER.ID
LEFT OUTER JOIN STATES
ON JOB.JURISDICTION = STATES.INITIALS

WHERE
(INVOICE_AR.AMOUNT_DUE > 0)
AND
(INVOICE-AR.INVOICE_DATE BETWEEN @.startdate and @.enddate)
AND
(MONTH(INVOICE_AR.INVOICE_DATE) IN (7,8,9))
AND
(PAYER.PAYCOMPANY like '%' + @.Company + '%')


Group By
JOB.JURISDICTION
PAYER.PAY_COMPANY
PAYER.PAY_CITY
PAYER.PAY_STATE
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE,
INVOICE_AR.AMOUNT_DUE

UNION ALL

SELECT 'Quarter 4' as 'qtr'
count(jobid) as 'transcount',
count(distinct job.patientid) as 'patientcount',
sum(job.LANGUAGE_TCOST) as 'lcost',
Sum(job.LANGUAGE_DISC_COST) as 'dlcost',
avg(LANGUAGE_DISC) as 'avgLDisc',
(sum(job.LANGUAGE_TCOST) + sum(job.LANGUAGE_DISC_COST)) as 'LGrossAmtBilled',
(sum(LANGUAGE_TCOST) / count(distinct job.patientid)) as 'PatAvgL',
(sum(LANGUAGE_TCOST) / count(jobid)) as 'RefAvgL',
sum(LANGUAGE_DISC) as 'avgPercentDiscL',
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE
INVOICE_AR.INVOICE_DATE AS EXPR1,
INVOICE_AR.AMOUNT_DUE

FROM JOB
INNER JOIN INVOICE_AR
ON JOB.JOBID = INVOICE_AR.JOBID
LEFT OUTER JOIN PAYER
ON PAYER.PAYERID = JOB.PAYER.ID
LEFT OUTER JOIN STATES
ON JOB.JURISDICTION = STATES.INITIALS

WHERE
(INVOICE_AR.AMOUNT_DUE > 0)
AND
(INVOICE-AR.INVOICE_DATE BETWEEN @.startdate and @.enddate)
AND
(MONTH(INVOICE_AR.INVOICE_DATE) IN (10,11,12))
AND
(PAYER.PAYCOMPANY like '%' + @.Company + '%')


Group By
JOB.JURISDICTION
PAYER.PAY_cOMPANY
PAYER.PAY_CITY
PAYER.PAY_STATE
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE,
INVOICE_AR.AMOUNT_DUE

Order By 'QTR' asc

At first glance I can see that you are missing commas after all of the columns that look like this:'Quarter 1' as 'qtr'|||

I fixed the commas issue but now I get a

There is an error in the query. Incorrect syntax near '.'.
Incorrect syntax near '.'.
Incorrect syntax near '.'.
Incorrect syntax near '.'.

Can some one help me I cant see where the error is coming

SELECT 'Quarter 1' as 'qtr',
COUNT(JOB.JOBID) as 'transcount',
COUNT(DISTINCT JOB.PATIENTID) as 'patient count',
SUM(JOB.LANGUAGE_TCOST) as 'lcost',
SUM(JOB.LANGUAGE_DISC_COST) as 'dlcost',
AVG(JOB.LANGUAGE_DISC) as 'avgLDisc',
SUM(JOB.LANGUAGE_TCOST) + SUM(JOB.LANGUAGE_DISC_COST) as 'LGrossAmtBilled',
SUM(JOB.LANGUAGE_TCOST) / COUNT(DISTINCT JOB.PATIENTID) as 'PatAvgL',
SUM(JOB.LANGUAGE_TCOST) / COUNT(JOB.JOBID) as 'RefAvgL',
SUM(JOB.LANGUAGE_DISC) as 'avgPercentDiscL',
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE
INVOICE_AR.INVOICE_DATE AS EXPR1,
INVOICE_AR.AMOUNT_DUE

FROM JOB
INNER JOIN INVOICE_AR
ON JOB.JOBID = INVOICE_AR.JOBID
LEFT OUTER JOIN PAYER
ON PAYER.PAYERID = JOB.PAYER.ID
LEFT OUTER JOIN STATES
ON JOB.JURISDICTION = STATES.INITIALS

WHERE
(INVOICE_AR.AMOUNT_DUE > 0)
AND
(INVOICE-AR.INVOICE_DATE BETWEEN @.startdate and @.enddate)
AND
(MONTH(INVOICE_AR.INVOICE_DATE) IN (1,2,3))
AND
(PAYER.PAYCOMPANY like '%' + @.Company + '%')


Group By
JOB.JURISDICTION
PAYER.PAY_COMPANY
PAYER.PAY_CITY
PAYER.PAY_STATE
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE,
INVOICE_AR.AMOUNT_DUE

UNION ALL

SELECT 'Quarter 2' as 'qtr',
COUNT(JOB.JOBID) as 'transcount',
COUNT(DISTINCT JOB.PATIENTID) as 'patient count',
SUM(JOB.LANGUAGE_TCOST) as 'lcost',
SUM(JOB.LANGUAGE_DISC_COST) as 'dlcost',
AVG(JOB.LANGUAGE_DISC) as 'avgLDisc',
SUM(JOB.LANGUAGE_TCOST) + SUM(JOB.LANGUAGE_DISC_COST) as 'LGrossAmtBilled',
SUM(JOB.LANGUAGE_TCOST) / COUNT(DISTINCT JOB.PATIENTID) as 'PatAvgL',
SUM(JOB.LANGUAGE_TCOST) / COUNT(JOB.JOBID) as 'RefAvgL',
SUM(JOB.LANGUAGE_DISC) as 'avgPercentDiscL',
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE
INVOICE_AR.INVOICE_DATE AS EXPR1,
INVOICE_AR.AMOUNT_DUE

FROM JOB
INNER JOIN INVOICE_AR
ON JOB.JOBID = INVOICE_AR.JOBID
LEFT OUTER JOIN PAYER
ON PAYER.PAYERID = JOB.PAYER.ID
LEFT OUTER JOIN STATES
ON JOB.JURISDICTION = STATES.INITIALS

WHERE
(INVOICE_AR.AMOUNT_DUE > 0)
AND
(INVOICE-AR.INVOICE_DATE BETWEEN @.startdate and @.enddate)
AND
(MONTH(INVOICE_AR.INVOICE_DATE) IN (4,6,3))
AND
(PAYER.PAYCOMPANY like '%' + @.Company + '%')


Group By
JOB.JURISDICTION
PAYER.PAY_COMPANY
PAYER.PAY_CITY
PAYER.PAY_STATE
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE,
INVOICE_AR.AMOUNT_DUE

UNION ALL

SELECT 'Quarter 3' as 'qtr',
COUNT(JOB.JOBID) as 'transcount',
COUNT(DISTINCT JOB.PATIENTID) as 'patient count',
SUM(JOB.LANGUAGE_TCOST) as 'lcost',
SUM(JOB.LANGUAGE_DISC_COST) as 'dlcost',
AVG(JOB.LANGUAGE_DISC) as 'avgLDisc',
SUM(JOB.LANGUAGE_TCOST) + SUM(JOB.LANGUAGE_DISC_COST) as 'LGrossAmtBilled',
SUM(JOB.LANGUAGE_TCOST) / COUNT(DISTINCT JOB.PATIENTID) as 'PatAvgL',
SUM(JOB.LANGUAGE_TCOST) / COUNT(JOB.JOBID) as 'RefAvgL',
SUM(JOB.LANGUAGE_DISC) as 'avgPercentDiscL',
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE
INVOICE_AR.INVOICE_DATE AS EXPR1,
INVOICE_AR.AMOUNT_DUE

FROM JOB
INNER JOIN INVOICE_AR
ON JOB.JOBID = INVOICE_AR.JOBID
LEFT OUTER JOIN PAYER
ON PAYER.PAYERID = JOB.PAYER.ID
LEFT OUTER JOIN STATES
ON JOB.JURISDICTION = STATES.INITIALS

WHERE
(INVOICE_AR.AMOUNT_DUE > 0)
AND
(INVOICE-AR.INVOICE_DATE BETWEEN @.startdate and @.enddate)
AND
(MONTH(INVOICE_AR.INVOICE_DATE) IN (7,8,9))
AND
(PAYER.PAYCOMPANY like '%' + @.Company + '%')


Group By
JOB.JURISDICTION
PAYER.PAY_COMPANY
PAYER.PAY_CITY
PAYER.PAY_STATE
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE,
INVOICE_AR.AMOUNT_DUE

UNION ALL

SELECT 'Quarter 4' as 'qtr',
COUNT(JOB.JOBID) as 'transcount',
COUNT(DISTINCT JOB.PATIENTID) as 'patient count',
SUM(JOB.LANGUAGE_TCOST) as 'lcost',
SUM(JOB.LANGUAGE_DISC_COST) as 'dlcost',
AVG(JOB.LANGUAGE_DISC) as 'avgLDisc',
SUM(JOB.LANGUAGE_TCOST) + SUM(JOB.LANGUAGE_DISC_COST) as 'LGrossAmtBilled',
SUM(JOB.LANGUAGE_TCOST) / COUNT(DISTINCT JOB.PATIENTID) as 'PatAvgL',
SUM(JOB.LANGUAGE_TCOST) / COUNT(JOB.JOBID) as 'RefAvgL',
SUM(JOB.LANGUAGE_DISC) as 'avgPercentDiscL',
JOB.JURISDICTION,
PAYER.PAY_COMPANY,
PAYER.PAY_CITY,
PAYER.PAY_STATE,
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE
INVOICE_AR.INVOICE_DATE AS EXPR1,
INVOICE_AR.AMOUNT_DUE

FROM JOB
INNER JOIN INVOICE_AR
ON JOB.JOBID = INVOICE_AR.JOBID
LEFT OUTER JOIN PAYER
ON PAYER.PAYERID = JOB.PAYER.ID
LEFT OUTER JOIN STATES
ON JOB.JURISDICTION = STATES.INITIALS

WHERE
(INVOICE_AR.AMOUNT_DUE > 0)
AND
(INVOICE-AR.INVOICE_DATE BETWEEN @.startdate and @.enddate)
AND
(MONTH(INVOICE_AR.INVOICE_DATE) IN (10,11,12))
AND
(PAYER.PAYCOMPANY like '%' + @.Company + '%')


Group By
JOB.JURISDICTION
PAYER.PAY_COMPANY
PAYER.PAY_CITY
PAYER.PAY_STATE
PAYER.PAY_SALES_STAFF_ID,
JOB.INVOICE_DATE,
INVOICE_AR.INVOICE_DATE,
INVOICE_AR.AMOUNT_DUE

Order By 'QTR' asc

|||

Again, just glancing, I see that you are missing commas after some of the columns in your GROUP BY clause. And I believe that this structure is invalid: COUNT(DISTINCT JOB.PATIENTID) as 'patient count' (specially, the DISTINCT keyword).

|||A troubleshooting suggestion: get just one of those SQL SELECT statements working without error (for the first quarter). Then add the second quarter. Once you have those 2 working together, add the other 2 quarters. Dealing with the entire thing all at once is giving you too much to worry about. Get the basics working first.

I need help with this sql string....({0}, {1},{2}, {3});", Chr(64 + j)

I was looking around on the internet and need something like this:
Dim NumberOfRows As Integer = 10
Dim NumberOfColumns As Integer = 4
Dim PlaneID As String = "3434278231"
Dim SeatType As String
Dim i As Integer
Dim j As Integer

For i = 1 To NumberOfRows
For j = 1 To NumberOfColumns
If j = 2 Or j = 4 Then
'Assuming B & D are Window Seats (j=1 For A, 2 for B and so on)
SeatType = "Window"
Else
SeatType = "Aisle"
End If
Qry = String.Format("INSERT INTO TBL_SEAT (SEAT_NUM, SEAT_ROW, SEAT_TYPE, PLANE_ID) VALUES ('{0}', {1},'{2}', '{3}');", Chr(64 + j), i, SeatType, PlaneID)
MsgBox(Qry)
Next j
Next i

i figured out most of it but need help figureing out how it inserts the seat number and row?

what does all this do: ('{0}', {1},'{2}', '{3}');", Chr(64 + j)

thanks for any advice.Assigns:

SEAT_NUM Chr(64 + j) to '{0}',
SEAT_ROW i to {1},
SEAT_TYPE SeatType to '{2}' and
PLANE_ID PlaneID to '{3}'.

:rolleyes:

I need help with the following (SQL Team Cross Post)

I am trying to setup a shape, shape attributes and calculate the cross
sectional area using the formula specified in the tbShapes.Formula field.
See the code below.

What this does is convert the formula

(Width * Flange) + (((Height - Flange) * Leg) * Count)

to

(108 * 4) + (((36 - 4) * 5) *2)

Now I need to calculate the expression above, but the
expression is a varchar string.

Any help?

USE NORTHWIND
GO

SET NOCOUNT ON
CREATE TABLE [dbo].[tbProductCodes] (
[ProductCode] [int] NOT NULL ,
[fkAccountID] [int] NOT NULL ,
[Product] [varchar] (50) NOT NULL ,
[fkShapeID] [int] NOT NULL
) ON [PRIMARY]
GO

INSERT INTO tbProductCodes (ProductCode, fkAccountID, Product, fkShapeID)
SELECT 2001, 1, 'New Product', 1
GO

CREATE TABLE [dbo].[tbProductTemplateAttributeValues] (
[fkTemplateID] [int] NOT NULL ,
[fkAttributeID] [int] NOT NULL ,
[AttributeValue] [float] NOT NULL
) ON [PRIMARY]
GO

INSERT INTO tbProductTemplateAttributeValues (fkTemplateID, fkAttributeID, AttributeValue)
SELECT 1, 1, 108 UNION ALL
SELECT 1, 2, 36 UNION ALL
SELECT 1, 3, 4 UNION ALL
SELECT 1, 4, 5 UNION ALL
SELECT 1, 5, 2
GO

CREATE TABLE [dbo].[tbProductTemplates] (
[TemplateID] [int] NOT NULL ,
[fkProductCode] [int] NOT NULL ,
[Template] [varchar] (50) NOT NULL ,
[fkMixID] [int] NULL
) ON [PRIMARY]
GO

INSERT INTO tbProductTemplates (TemplateID, fkProductCode, Template, fkMixID)
SELECT 1, 2001, 'ProductTemplate', 1
GO

CREATE TABLE [dbo].[tbShapeAttributes] (
[AttributeID] [int] NOT NULL ,
[fkShapeID] [int] NOT NULL ,
[Attribute] [varchar] (50) NOT NULL
) ON [PRIMARY]
GO

INSERT tbShapeAttributes (AttributeID, fkShapeID, Attribute)
SELECT 1, 1, 'Width' UNION ALL
SELECT 2, 1, 'Height' UNION ALL
SELECT 3, 1, 'Flange' UNION ALL
SELECT 4, 1, 'Leg' UNION ALL
SELECT 5, 1, 'Count'
GO

CREATE TABLE [dbo].[tbShapes] (
[ShapeID] [int] NOT NULL ,
[Shape] [varchar] (50) NOT NULL ,
[Formula] [varchar] (100) NULL
) ON [PRIMARY]
GO

INSERT INTO tbShapes (ShapeID, Shape, Formula)
SELECT 1, 'Double T', '(Width * Flange) + (((Height - Flange) * Leg) * Count)'
GO

CREATE PROCEDURE usp_shapes_GetCrossSection

@.iTemplate int,
@.cResult varchar (500) OUTPUT

AS

declare @.cAttribute varchar(50),
@.fAttribute float

-- Get the formula for the templates shape
SELECT @.cResult = s.Formula
FROM tbShapes AS s INNER JOIN tbProductCodes AS pc
ON s.ShapeID = pc.fkShapeID
INNER JOIN tbProductTemplates AS pt
ON pc.ProductCode = pt.fkProductCode
WHERE pt.TemplateID = @.iTemplate

SELECT @.cResult AS Formula

DECLARE AttributeCursor CURSOR FOR
SELECT sa.Attribute,
av.AttributeValue
FROM tbProductTemplateAttributeValues AS av INNER JOIN tbShapeAttributes AS sa
ON av.fkAttributeID = sa.AttributeID
WHERE av.fkTemplateID = @.iTemplate

OPEN AttributeCursor
FETCH NEXT FROM AttributeCursor INTO @.cAttribute, @.fAttribute
while(@.@.FETCH_STATUS = 0)
BEGIN
SELECT @.cResult = REPLACE(@.cResult, @.cAttribute, CAST(@.fAttribute AS VarChar))
FETCH NEXT FROM AttributeCursor INTO @.cAttribute, @.fAttribute
END

SELECT @.cResult AS NewFormula

CLOSE AttributeCursor
DEALLOCATE AttributeCursor
GO

-- Test stored proc

declare @.iTemplate int, @.fResult float

SET @.iTemplate = 1
EXECUTE usp_shapes_GetCrossSection @.iTemplate, @.fResult OUTPUT
SELECT @.fResult AS Result
GO

drop table [dbo].[tbProductCodes]
GO

drop table [dbo].[tbProductTemplateAttributeValues]
GO

drop table [dbo].[tbProductTemplates]
GO

drop table [dbo].[tbShapeAttributes]
GO

drop table [dbo].[tbShapes]
GO

DROP PROCEDURE usp_shapes_GetCrossSection
GO

Mike BMike, I guess I still don't get why your application requires this. Broken down, what you are doing is taking values stored as integers, running them through a procedure that casts them as characters buried in a string, and then looking for a procedure that strips them back out again?

It sound kind of circular.

Without too much difficulty, you could write a store procedure specific to the formula you gave that will parse the values out based on their positional relationship to the parenthesis characters, but it would not be a general solution. It would not work for any other formula.

If you can limit your operations to add, subtract, multiply, and divide, and if you can ensure that your formula will contain plenty of parenthesis to specify operation precedence, then without you might be able to write a recursive function that would be a general solution for simple formulas.|||Originally posted by blindman
Mike, I guess I still don't get why your application requires this. Broken down, what you are doing is taking values stored as integers, running them through a procedure that casts them as characters buried in a string, and then looking for a procedure that strips them back out again?

It sound kind of circular.

Without too much difficulty, you could write a store procedure specific to the formula you gave that will parse the values out based on their positional relationship to the parenthesis characters, but it would not be a general solution. It would not work for any other formula.

If you can limit your operations to add, subtract, multiply, and divide, and if you can ensure that your formula will contain plenty of parenthesis to specify operation precedence, then without you might be able to write a recursive function that would be a general solution for simple formulas.

Thanks for your reply BlindMan, but a couple of people at SQL Team found a solution.

declare @.iTemplate int, @.fResult varchar(500)

SET @.iTemplate = 1
EXECUTE usp_shapes_GetCrossSection @.iTemplate, @.fResult OUTPUT

DECLARE @.stmt nvarchar(4000)
DECLARE @.param nvarchar(4000)
DECLARE @.Eval int

SET @.stmt='SET @.StmResult = ' + @.fResult
SET @.Param='@.StmResult int out'

EXEC sp_executesql @.stmt, @.Param, @.Eval OUT

SELECT @.Eval

Using the dynamic SQL the Equation can be computed. Anyway, if you would like to see the post it is at:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=34179

Mike B|||OK, that was a cool solution. Dynamic SQL.

I Need Help With The Connection String

I Need Help With The Connection String cuz that i need to connect with the database for Mobile Application and i have sqlexpress

Since you didn't post your connection string, it appears that you don't need help with it -you want someone to do it for you.

You might find a visit to www.connectionstrings.com to be useful.

|||

Thank you about your help

i need another help

I need to write an stored procedure that contain the 4 T-sql statement (Select,insert,update,delete) these T-SQL related to the same table.

When I Call the stored procedure on the Visual Stedio How can i deals with this Situation I need The Code

|||

Thank you about your help

i need another help

I need to write an stored procedure that contain the 4 T-sql statement (Select,insert,update,delete) these T-SQL related to the same table.

When I Call the stored procedure on the Visual Stedio How can i deals with this Situation I need The Code

I Need Help With The Connection String

I Need Help With The Connection String cuz that i need to connect with the database for Mobile Application and i have sqlexpress

Since you didn't post your connection string, it appears that you don't need help with it -you want someone to do it for you.

You might find a visit to www.connectionstrings.com to be useful.

|||

Thank you about your help

i need another help

I need to write an stored procedure that contain the 4 T-sql statement (Select,insert,update,delete) these T-SQL related to the same table.

When I Call the stored procedure on the Visual Stedio How can i deals with this Situation I need The Code

|||

Thank you about your help

i need another help

I need to write an stored procedure that contain the 4 T-sql statement (Select,insert,update,delete) these T-SQL related to the same table.

When I Call the stored procedure on the Visual Stedio How can i deals with this Situation I need The Code

I need help with stored procs and UDF

First off, this is a cross post which is also located here:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=34073

Now, with the following stored procs and UDF, the Result is NULL and I cannot figure out why.

What I am doing is calling a stored procedure pass in an OUTPUT variable of type float. This stored proceudre then calls a different stored procedure passing the same OUTPUT variable of type float. The second stored procedure then calls a UDF passing in two variables to be multiplied ans this should set the OUTPUT variable to the result.

The UDF does return the correct result to the interior stored procedure, but the interior stored procedure does not pass the value back to the original stored procudure resultint in a Result value = NULL.

The code is below, just copy / past, execute and you will see exactly what I mean.

Any thoughts?

USE NORTHWIND
GO

CREATE FUNCTION RECTANGULAR_XSECTION
(@.fWidth float, @.fHeight float)

RETURNS float

AS
BEGIN
RETURN (@.fWidth * @.fHeight)
END
GO

CREATE PROCEDURE usp_shapes_GetRectangularXSection

@.fResult float OUTPUT

AS

declare @.fWidth float, @.fHeight float
SELECT @.fWidth = 108, @.fHeight = 10

SELECT @.fResult = [dbo].[RECTANGULAR_XSECTION](@.fWidth, @.fHeight)
SELECT @.fResult AS CalledProcedureOkHere

GO

CREATE PROCEDURE usp_shapes_GetXSection

@.fResult float OUTPUT

AS

EXECUTE usp_shapes_GetRectangularXSection @.fResult
SELECT @.fResult AS CallingProcedure_NULL?
GO

declare @.fResult float
EXECUTE usp_shapes_GetXSection @.fResult
SELECT @.fResult as OutsideCallingProcedure_NULL?
GO

DROP FUNCTION RECTANGULAR_XSECTION
GO
DROP PROCEDURE usp_shapes_GetRectangularXSection
GO
DROP PROCEDURE usp_shapes_GetXSection
GO

Mike BI found it, I forgot "OUTPUT" on the call to the stored procedure!!

Damn, simple, simple, simple!!!!
Mike B|||dooh

I hate when that happens....

It was a good post though...

Sorry I'm late...|||Originally posted by Brett Kaiser

dooh

I hate when that happens....

It was a good post though...

Sorry I'm late...
Thanks for you response all the same. I know you would have helped ;)

Mike B

I need help with stored procedures.

Basically I've got a stored procedure, and I want to declare a variable within that stored procedure then put a value into that varible with a SELECT statement , then INSERT that value, along with some other values, into another table. I hope im explaining myself right.
Anyway, here's my code (its wrong)

/*
This stored procedure adds a new issue
*/

CREATE PROCEDURE {databaseOwner}{objectQualifier} [PreciseData_IssueTracker_AddIssue]
@.moduleId int,
@.starterUserId int,
@.typeId int,
@.subject varchar (50)
AS

SET @.assignedUserId = SELECT userId FROM PreciseData_IssueTracker_Assignments WHEREtypeId=@.typeId


INSERT INTO PreciseData_IssueTracker_Issue
(
moduleId,
starterUserId,
assignedUserId,
statusId,
typeId,
subject,
startDate
)
VALUES
(
@.moduleId,
@.starterUserId,
@.assignedUserId,
1,
@.typeId,
@.subject,
getdate()
)
GO

Like this:

SELECT @.assignedUserId = userId FROM PreciseData_IssueTracker_Assignments WHEREtypeId=@.typeId


|||Thanks very much!

I need help with SELECT statement

Hi, Could you help me modify the SELECT statement below that would
accomplish my final goal.
SELECT col1, col2 FROM table1 WHERE col3 < @.V
In col1 rows have many duplicates
col2 has unique values
col3 can have 5 possible values: 5, 10, 15, 20, 25
Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
The goal is to:
Return row values from col1 without duplicates, and return corresponding
values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
maximum value from all possible values but is <= @.V
Thank you.
Vanessa
Learn how not to multi-post to every single group and next time maybe you'll
get some help.
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
"Vanessa Lee" <van77788@.yahoo.com> wrote in message
news:H4GdnZuIZaAui8LfRVn-hg@.comcast.com...
> Hi, Could you help me modify the SELECT statement below that would
> accomplish my final goal.
> SELECT col1, col2 FROM table1 WHERE col3 < @.V
> In col1 rows have many duplicates
> col2 has unique values
> col3 can have 5 possible values: 5, 10, 15, 20, 25
> Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
> The goal is to:
> Return row values from col1 without duplicates, and return corresponding
> values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
> maximum value from all possible values but is <= @.V
> Thank you.
> Vanessa
>

I need help with SELECT statement

Hi, Could you help me modify the SELECT statement below that would
accomplish my final goal.
SELECT col1, col2 FROM table1 WHERE col3 < @.V
In col1 rows have many duplicates
col2 has unique values
col3 can have 5 possible values: 5, 10, 15, 20, 25
Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
The goal is to:
Return row values from col1 without duplicates, and return corresponding
values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
maximum value from all possible values but is <= @.V
Thank you.
Vanessa
See my answer in .msde.
Jacco Schalkwijk
SQL Server MVP
"Vanessa Lee" <van77788@.yahoo.com> wrote in message
news:o4SdndJqXfNEiMLfRVn-uQ@.comcast.com...
> Hi, Could you help me modify the SELECT statement below that would
> accomplish my final goal.
> SELECT col1, col2 FROM table1 WHERE col3 < @.V
> In col1 rows have many duplicates
> col2 has unique values
> col3 can have 5 possible values: 5, 10, 15, 20, 25
> Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
> The goal is to:
> Return row values from col1 without duplicates, and return corresponding
> values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
> maximum value from all possible values but is <= @.V
> Thank you.
> Vanessa
>

I need help with SELECT statement

Hi, Could you help me modify the SELECT statement below that would
accomplish my final goal.
SELECT col1, col2 FROM table1 WHERE col3 < @.V
In col1 rows have many duplicates
col2 has unique values
col3 can have 5 possible values: 5, 10, 15, 20, 25
Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
The goal is to:
Return row values from col1 without duplicates, and return corresponding
values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
maximum value from all possible values but is <= @.V
Thank you.
Vanessa
Vanessa
This question has nothing to do with clustering. It looks like you have
posted to every single SQL Server newsgroup, regardless of relevancy. Please
do not do this.
HTH
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Vanessa Lee" <van77788@.yahoo.com> wrote in message
news:qISdnUhUgOVTiMLfRVn-hg@.comcast.com...
> Hi, Could you help me modify the SELECT statement below that would
> accomplish my final goal.
> SELECT col1, col2 FROM table1 WHERE col3 < @.V
> In col1 rows have many duplicates
> col2 has unique values
> col3 can have 5 possible values: 5, 10, 15, 20, 25
> Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
> The goal is to:
> Return row values from col1 without duplicates, and return corresponding
> values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
> maximum value from all possible values but is <= @.V
> Thank you.
> Vanessa
>

I need help with SELECT statement

Hi, Could you help me modify the SELECT statement below that would
accomplish my final goal.
SELECT col1, col2 FROM table1 WHERE col3 < @.V
In col1 rows have many duplicates
col2 has unique values
col3 can have 5 possible values: 5, 10, 15, 20, 25
Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
The goal is to:
Return row values from col1 without duplicates, and return corresponding
values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
maximum value from all possible values but is <= @.V
Thank you.
Vanessa
SELECT distinct col1, col2 FROM table1 WHERE col3 < @.V

I need help with SELECT statement

Hi, Could you help me modify the SELECT statement below that would
accomplish my final goal.
SELECT col1, col2 FROM table1 WHERE col3 < @.V
In col1 rows have many duplicates
col2 has unique values
col3 can have 5 possible values: 5, 10, 15, 20, 25
Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
The goal is to:
Return row values from col1 without duplicates, and return corresponding
values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
maximum value from all possible values but is <= @.V
Thank you.
Vanessa
Learn how not to multi-post to every single group and next time maybe you'll
get some help.
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
"Vanessa Lee" <van77788@.yahoo.com> wrote in message
news:PcadnZPKVP9xiMLfRVn-jA@.comcast.com...
> Hi, Could you help me modify the SELECT statement below that would
> accomplish my final goal.
> SELECT col1, col2 FROM table1 WHERE col3 < @.V
> In col1 rows have many duplicates
> col2 has unique values
> col3 can have 5 possible values: 5, 10, 15, 20, 25
> Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
> The goal is to:
> Return row values from col1 without duplicates, and return corresponding
> values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
> maximum value from all possible values but is <= @.V
> Thank you.
> Vanessa
>
|||Hi Vanessa,
You can try simply this statement if it does'nt matter which values from
col1 you want to take in case qualifying rows have duplicate in col1.
SELECT Col1,Col2 FROM Table1 WHERE Col1 IN
(SELECT DISTINCT Col1 FROm Table1 WHERE Col3<=@.V)
We can always tweak this query to perform better as i have used IN here
instead oj join.
Thanks,
Vicky Dhawan
"Vanessa Lee" wrote:

> Hi, Could you help me modify the SELECT statement below that would
> accomplish my final goal.
> SELECT col1, col2 FROM table1 WHERE col3 < @.V
> In col1 rows have many duplicates
> col2 has unique values
> col3 can have 5 possible values: 5, 10, 15, 20, 25
> Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
> The goal is to:
> Return row values from col1 without duplicates, and return corresponding
> values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
> maximum value from all possible values but is <= @.V
> Thank you.
> Vanessa
>
>

I need help with SELECT statement

Hi, Could you help me modify the SELECT statement below that would
accomplish my final goal.
SELECT col1, col2 FROM table1 WHERE col3 < @.V
In col1 rows have many duplicates
col2 has unique values
col3 can have 5 possible values: 5, 10, 15, 20, 25
Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
The goal is to:
Return row values from col1 without duplicates, and return corresponding
values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
maximum value from all possible values but is <= @.V
Thank you.
Vanessa
It's not completely crystal clear what you need, but my guess is:
SELECT t1.col1, t1.col2
FROM table1 t1
INNER JOIN (SELECT col1, MAX(col3) AS col3
FROM table1
WHERE col3 <= @.v
GROUP BY col1) t2
ON t1.col1 = t2.col1 AND t1.col3 = t2.col3
Jacco Schalkwijk
SQL Server MVP
"Vanessa Lee" <van77788@.yahoo.com> wrote in message
news:Q7ydnWLCvMGoi8LfRVn-iQ@.comcast.com...
> Hi, Could you help me modify the SELECT statement below that would
> accomplish my final goal.
> SELECT col1, col2 FROM table1 WHERE col3 < @.V
> In col1 rows have many duplicates
> col2 has unique values
> col3 can have 5 possible values: 5, 10, 15, 20, 25
> Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
> The goal is to:
> Return row values from col1 without duplicates, and return corresponding
> values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
> maximum value from all possible values but is <= @.V
> Thank you.
> Vanessa
>

I need help with SELECT statement

Hi, Could you help me modify the SELECT statement below that would
accomplish my final goal.
SELECT col1, col2 FROM table1 WHERE col3 < @.V
In col1 rows have many duplicates
col2 has unique values
col3 can have 5 possible values: 5, 10, 15, 20, 25
Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
The goal is to:
Return row values from col1 without duplicates, and return corresponding
values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
maximum value from all possible values but is <= @.V
Thank you.
Vanessa
>> Could you help me modify the SELECT statement below that would accomplish[vbcol=seagreen]
Yes, but for such questions it is helpful to post your table structures &
sample data so that others can understand you better. For details refer to:
www.aspfaq.com/5006
[vbcol=seagreen]
Based on guesswork:
SELECT * -- use required column names
FROM tbl t1
WHERE t1.col2 = ( SELECT MAX( t2.col2 )
FROM tbl t2
WHERE t2.col1 = t1.col1
AND t2.col3 = t1.col3 )
AND t2.col3 < @.v ;
Anith

I need help with SELECT statement

Hi, Could you help me modify the SELECT statement below that would
accomplish my final goal.
SELECT col1, col2 FROM table1 WHERE col3 < @.V
In col1 rows have many duplicates
col2 has unique values
col3 can have 5 possible values: 5, 10, 15, 20, 25
Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
The goal is to:
Return row values from col1 without duplicates, and return corresponding
values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
maximum value from all possible values but is <= @.V
Thank you.
Vanessa
Vanessa,
I was going to take a look at this but I noticed that you have already
cross-posted in the programming group. Please give one group a chance before
trying another, otherwise we spend unnecessary time trying to solve
something thaat is already solved elsewhere.
Rgds,
Paul Ibison SQL Server MVP, www.replicationanswers.com/default.asp
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)

I need help with SELECT statement

Hi, Could you help me modify the SELECT statement below that would
accomplish my final goal.
SELECT col1, col2 FROM table1 WHERE col3 < @.V
In col1 rows have many duplicates
col2 has unique values
col3 can have 5 possible values: 5, 10, 15, 20, 25
Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
The goal is to:
Return row values from col1 without duplicates, and return corresponding
values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
maximum value from all possible values but is <= @.V
Thank you.
VanessaIf by
"WHERE" col3 always has maximum value from all possible values but is <= @.V
do you mean Maximum vaue of Col2 from all the rows with the same value in
col1, then Try this:
SELECT col1, col2
FROM table1 T
WHERE col3 =
(Select Max(Col3)
From Table1
Where Col1 = T.col1)
And col3 < @.V
"Vanessa Lee" wrote:

> Hi, Could you help me modify the SELECT statement below that would
> accomplish my final goal.
> SELECT col1, col2 FROM table1 WHERE col3 < @.V
> In col1 rows have many duplicates
> col2 has unique values
> col3 can have 5 possible values: 5, 10, 15, 20, 25
> Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
> The goal is to:
> Return row values from col1 without duplicates, and return corresponding
> values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
> maximum value from all possible values but is <= @.V
> Thank you.
> Vanessa
>
>|||Hi,
The "possible values" can only be 5 or 10 or 15 or 20 or 25. They are from
col3 only.
Thank you.
"CBretana" <cbretana@.areteIndNOSPAM.com> wrote in message
news:108BBC29-5478-48BE-A260-8179B6EE6FC0@.microsoft.com...
> If by
> "WHERE" col3 always has maximum value from all possible values but is <=
@.V
> do you mean Maximum vaue of Col2 from all the rows with the same value in
> col1, then Try this:
> SELECT col1, col2
> FROM table1 T
> WHERE col3 =
> (Select Max(Col3)
> From Table1
> Where Col1 = T.col1)
> And col3 < @.V
>
> "Vanessa Lee" wrote:
>|||you didn't mention how to handle col2 when col1 have duplicate records,
i assume col2 and col3 has same requirement
select col1, max(col2), max(col3)
from table1
where col3 <@.V
group by col1
"Vanessa Lee" <van77788@.yahoo.com> wrote in message
news:baudnQyz7rjji8LfRVn-1w@.comcast.com...
> Hi, Could you help me modify the SELECT statement below that would
> accomplish my final goal.
> SELECT col1, col2 FROM table1 WHERE col3 < @.V
> In col1 rows have many duplicates
> col2 has unique values
> col3 can have 5 possible values: 5, 10, 15, 20, 25
> Variable @.V can be equal to 5 or 10 or 15 or 20 or 25
> The goal is to:
> Return row values from col1 without duplicates, and return corresponding
> values from col2 (both col1 and col2 in one row) "WHERE" col3 always has
> maximum value from all possible values but is <= @.V
> Thank you.
> Vanessa
>