Saving Tables That Are Generated By Queries As HTML File Or Sub-tables

Oct 17, 2006

I have a trade data tables (about 10) and I need to retrieve information based on input parameters. Each table has about 3-4 million rows.

The table has columns like Commodity, Unit, Quantity, Value, Month, Country

A typical query I use to select data is "Select top 10 commodity , sum(value), sum(quantity) , column4, column5, column6 from table where month=xx and country=xxxx"

The column4 = (column2)/(total sum of value) and column 5=(column3)/(total sum of quantity). Column6=column5/column4.

It takes about 3-4 minutes for the query to complete and its a lot of time specially since I need to pull this information from a webpage.

I wanted to know if there is an alternate way to pull the data from server ?

I mean can I write a script that creates tables for all the input combinations i.e month x country (12x228) and save them in table (subtable-table) with a naming convention so from the web I can just pull the table with input parameters mapped to name convention and not running any runtime queries on database ??

OR

Can I write a script that creates a html files for each table for all input combinations save them ?

OR

Is there exists any other solution ?

View 1 Replies


ADVERTISEMENT

Create Tables From Sql Queries In A .txt File

Apr 22, 2008

Hello,

I am new to SSIS. I have a scenario:

I am creating a database using 'Execute SQL Task'. Then i have to create few tables in that database. where,I have my create table SQL queries for 5 tables in a .txt file.

How to approach this task...

View 1 Replies View Related

SQL Generated Tables

Sep 27, 2007



Suppose I want to generate a table as below

No. Col1 Col2
1 100 Alan
2 110 Alan
3 120 Alan

In Column I there is a sequence of numbers from 1 to 3 with a step of 1
In Column 2 there is a sequence of numbers from 100 to 120 with a step of 2
In Column 3 there is a name that is repeated accross the whole column

Can I generate such a table with just a single SQL Statement . I don't see any reason why it should not be possible. We know the logic to generate all the numbers of every row. It would be possible using a while loop , but that is be tedious and I am looking for a better way.

One application I can think of is, Suppose I want to find out all deleted primary key ids from a table or say if I have a set
(1,2,3, 7,8,9) , and wish to know the missing numbers in the range 1 to 9. If an sql like above is possible I could use it in a left join to get me the desired output.

Could anyone tell me if it is possible and if not , why not ?

Thanks,
Alec

View 6 Replies View Related

Return The Last Identity Value Generated All Tables In A Database

Apr 14, 2008



I need a script that returns the last identity value generated for each table in a database that has an identity column.



I am using SQL Server 2005.

Thanks.

View 6 Replies View Related

T-SQL (SS2K8) :: Find Tables That Are Generated From SSIS Package

Jun 26, 2014

I have three databases and 40 tables within each database on my server, for each of the tables I want to know which SSIS package generates that table. Is there a script that can do this?

If the SSIS package does not create or populate a table on the server I then want to check if there is a stored procedure that populates this.

View 6 Replies View Related

Saving Data Into Two Tables

Jan 12, 2008

Hello all ...
 I am facing a problem in the evaluation form that I am working on ...
I have 3 textboxes which are
Trainee ID, Trainee Name and Trainee Department
I want the Trainee ID to be saved in the Evauaiton form , The trainee id is a foregin key in the Evaluation table in my SQL table, it is coming from the trainee table where the Trainee ID is primary key and it is incremneting ...
I want the same Trainee Id to be sent to both Trainee and evaluation table , but at the same time , i want whenever a user open the evaualtion form an id will be shown and it will be inccremented ...
 
Hope that is clear ...
 How I can solve this problem?
 

View 3 Replies View Related

Export SQL Database Tables Into HTML Page

Oct 19, 2006

Hello,

I just want to know how can I create a SSIS package to export a few distinct tables into distinct HTML pages.

If anyone can help.

Thanks in advance.

Best regards...

View 3 Replies View Related

How To Link Mssql Data (tables) In Notepad (HTML)

Nov 29, 2006

menardo writes "Hi there!
I'm a very newbie in SQL programming. Can anybody help me how do I start to learn scriptings.

Can you give me the process or scripts on how to export it??

Thanks in advance.

-menardo"

View 2 Replies View Related

DB Engine :: Saving Data From One Textbox To 2 Tables?

Oct 1, 2015

i need to display variables from one textbox to 2 or more tables in database, how do i do that?

View 2 Replies View Related

Saving HTML To Sql

Oct 25, 2007

hello,

Im not really sure if this is the right thing to do. But i want to save a copy of the html from my invoice to sql so that i can keep a history of the invoices in case their are changes done to them. Anybody know what would be the best way to do this?

Thank you,

~ Mauricio

View 3 Replies View Related

Cannot Access Any Tables In Queries

Nov 7, 2007



I am using SQL2005 (Installed on VISTA). It was running smoothly until today....for some reason I cannot access any tables in queries that I try to run in Management Studio. I can open the tables and see the information, but all queries I try to run result in the following error:


Msg 208, Level 16, State 1, Line 1

Invalid object name 'DBO.BEYLEVEL16'.


I tried to run simple select queries on other tables but I get the same error message. Do not understand, eveything was working fine yesterday.

Any suggestions greatly appreciated.
Thanks

View 9 Replies View Related

Lost Tables And Queries

Aug 14, 2007

I appologise if this is dumb to anyone but I need a lot of help. I had a large program with over 50 tables and over 100 queries written in access. I upsized to SQL into a server windows 2003. Everything was cool and I made all corrections such that the program was working fine. The program resided in a D: accessory drive which was going bad. I copied my program to a different drive and replaced the D drive and returned my program to the new drive. I amde sure all shares and securities were the same. Lo and Behold My program now is missing all the queries and tables and when I run it it says it is disconnected. What happened to my tables I am currentely sobbing right now.

View 3 Replies View Related

Queries In Productions AND History Tables

Jun 18, 2004

I've got a large and growing database in SQL Server 7.0. I'd like to utilize a monthly stored procedure that will search various tables for records that are older than 3 months and copy this data out to corresponding history tables. Typically, most production queries are run only on the new data, but occasionally (like at year-end, for example), we will need to run some queries on data extending back 12 months -- that is, on data in the production tables AND in the history tables. Notwithstanding the fact that I've never done stored procedures*, I would like to know if it is possible to run a query that can search for data in both production and history tables at the same time. I know this sounds like a stupid question, but I read somewhere that doing this qould require some kind of Joining function that is complex...?

Thanks,
Whill96205

* Also, any good resources I could use for developing stored procedures?

View 4 Replies View Related

Queries On Recursive Self Join Tables

Oct 24, 2007



Good morning!
Or good "whatever daytime you read this"!

SQL Server 2005 has this nice new feature Common table expression or CTE, which allows quite easy to define a "drill down" in recursive self join tables.

By recursive self join tables I mean this common example:
idPerson INT <--------|
idReportsTo INT ---------|
PersonName VARCHAR


A CTE to "go down" the tree from any entry point and find all subs to a parent entry is well documented. I managed to make myself a CTE and use it a lot!

What I find myself needing too often is:
a) Look up from a deep position and find the entry that is for example 3 steps above my reference in the branch
b) Look up from a deep position and find the one that is 2nd or 3rd level (absolute) from top of the tree in the branch


I did try quite some versions, but I cannot get it to work. Any idea how you do the "drill up" with a CTE or another SQL solution.
Of course performance is always needed, so I'd like to avoid the cursors I got it working with and use now. (It is not working good I admit...)

Cheers!
Ralf

View 7 Replies View Related

Why Would Tables Pulled In From ODBC In Access Be Different Than Tables In SQL 2005 Tables?

Jan 24, 2008

I'm new to my company, although not new to SQL 2005 and I found something interesting. I don't have an ERD yet, and so I was asking a co-worker what table some data was in, they told me a table that is NOT in SQL Server 2005's list of tables, views or synonyms.

I thought that was strange, and so I searched over and over again and still I couldn't find it. Then I did a select statement the table that Access thinks exists and SQL Server does not show and to my shock, the select statement pulled in data!

So how did this happen? How can I find the object in SSMS folder listing of tables/views or whatever and what am I overlooking?

Thanks,
Keith

View 4 Replies View Related

Print List Of Queries, Tables, Views And Sp

Oct 29, 2007

I just started a new job and 1st time on sql server, how can i print list of queries, tables, views, stored procedures and functions?

View 6 Replies View Related

Queries Using Tables From Diffrent Databases Or SQL Instances

Aug 10, 2007



Hello,

I am new in SSIS.

I am using an OLEDB source and setted as SQL Command.

The Query is a JOIN between different databases.

How can I make the QUERY with different source (different databases or SQL Servers)?

I mean, any solution is OK, the important is to make queries against different databases with SSIS.

Thank

View 9 Replies View Related

Large FullText Tables - Slow Queries

May 31, 2007

Hi,



I currently have a large table (35 million rows, over 80GB). I have one varchar(max) column on the table that is used in the fulltext index.



To query the complete index is fast, for example:



SELECT 'ipod', COUNT(*)

FROM CONTAINSTABLE(MyDB.dbo.Contents, [Body], 'ipod') CT



This took 70 seconds (which I can live with). However, I seldom run queries like this, most are more like:



SELECT 'ipod', COUNT(*)

FROM CONTAINSTABLE(MyDB.dbo.Contents, [Body], 'ipod') CT

JOIN Pages ITP ON ITP.PageID = CT.[Key]

JOIN Feeds ITF ON ITP.IPID = ITF.IPID

JOIN Buyers ITB ON ITB.IBID = ITF.IBID

WHERE ITB.ID IN (1342,246)



These queries are much slower (this example took 17 minutes). I understand that FT searches the index and returns all rows that match the query to SQL. SQL then performs the joins and counts only the correct results. (Correct me if I'm wrong here).



One solution I've seen to this to put data or "tags" into the FT column - so my Body column would become something like:



'{ID:1342}' + [Body]



That sounds like a very good idea. I could then change the 2nd query above to be:



SELECT 'ipod', COUNT(*)

FROM CONTAINSTABLE(MyDB.dbo.Contents, [Body], '("ID:1342" OR "ID:246") AND "ipod"') CT



That all works well until I want to select 1000 different ID's because the FT query will become very long and complex. Also I'm only including one column (ID) in this example - but I have about 7 or 8 columns that I would need to include in these "tags". Quering multiple columns become very complex quickly and no doubt I will reach a query limit at somepoint.



If anyone has any other suggestions to the above I'd love to hear them. Another thought I'm having is to partition the table. I can find very little online about how FT behaves on partitioned tables - I fear it behaves exactly the same, what I'd like to think is that I could partition the table on an ID say 100 per partition or something, and then fulltext would only search the relevant partitions. If it behaves like this it may work. If no-one knows then I'll give it ago, but this will take me a while due to the table size - so I'm hoping one of you clever lot know!



Many thanks for any advice.



Simon





View 2 Replies View Related

Store Procedure Saving HTML Text In Table Column

May 22, 2008

Hi All,I am looking for a store procedure or any alternate method which save my html file(s) text (with or without tags) in my table column automatically when I upload my html file to my file system (local hard drive).any help will be appreciate.Thanks in advance. 

View 7 Replies View Related

SQL 2012 :: Queries Based On ER Diagram And Joining Tables

Feb 22, 2015

I need to create a few select queries based on an er diagram.

These are my Create Table statements and import statements:

Create Table Agent (Aid integer primary key, Pid integer, aName text);
Create Table Product (Pid integer primary key, pName text);
Create Table Supplier (Sid integer primary key, sName text);
Create table Supplies (Sid integer, Pid integer, price decimal(8,2));

.import agent.txt Agent
.import product.txt Product
.import supplier.txt Supplier
.import supplies.txt Supplies

I think I got all my create table statements are correct.

I need to Find the number of agents for each supplier that has at least one agent. The result should be tuples of the form (sid, sName, number of agents)

-Select Sid, sName, count(Aid) from Agent A join Supplier S on (S.Sid = A.Sid) group by S.Sid, S.sName, Aid;
But it gives me this error: no such column: A.Sid

Im thinking I might have a problem with my create table statement and/or primary key statements?

View 9 Replies View Related

Execution Of Queries On Tables Without Table Owner Specified Fails.

Feb 7, 2006

Hi

Having some issues with our apps.
We are trying to get our applications to work with sql2005.

Ive got the databases "setup", and all our apps run fine...
...except for when queries are made without the owner of the
table being specified in the query.

The connection is opened with the username that is associated with that owner.
And it fails in Manager as well. Is there something im missing, because you should
be able to do this.

eg:
select * from <table_name>

Gives the error:


Msg 208, Level 16, State 1, Line 1

Invalid object name '<table_name>'.

However if i were to query like this:
select * from <owner>.<table_name>

it works fine.

View 11 Replies View Related

T-SQL (SS2K8) :: Joining Results Of Two Queries Without Creating Temporary Tables?

Nov 16, 2014

In the T-SQL below, I retrieved data from two queries and I've tried to join them to create a report in SSRS 2008 R2. The SQL runs, but I can't create a report from it. (I also couldn't get this query to run in an Excel file that connects to my SQL Server data base. I've used other T-SQL queries in this Excel file and they run fine.) I think that's because I am creating temporary tables. How do I modify my SQL so that I can get the same result without creating temporary tables?

/*This T-SQL gets the services for the EPN download from WITS*/

-- Select services entered in the last 20 days along with the MPI number and program code.

SELECT DISTINCT dbo.group_session_client.note, dbo.group_session_client.error_note, dbo.group_session_client.group_session_id,
dbo.group_session_client.group_session_client_id, dbo.group_session.signed_note, dbo.group_session.unsigned_note
into #temp_group_sessions
FROM dbo.group_session_client, dbo.group_session
WHERE dbo.group_session_client.group_session_id = dbo.group_session.group_session_id

-- Select group notes

SELECT DISTINCT
dbo.client_ssrs.state_client_number, dbo.delivered_service_detail.program_name, dbo.delivered_service_detail.start_date,
dbo.delivered_service_detail.start_time,
dbo.delivered_service_detail.service_name, dbo.delivered_service_detail.cpt_code, dbo.delivered_service_detail.icd9_code_primary,

[code]....

-- Form an outer join selecting all services with any group notes attached to them.

select * from #temp_services
LEFT OUTER JOIN #temp_group_sessions
on #temp_services.group_session_client_id = #temp_group_sessions.group_session_client_id
;

-- Drop temporary tables

DROP TABLE #temp_group_sessions;
DROP TABLE #temp_services;

View 9 Replies View Related

SQL Server 2014 :: How To Systematically Manage Big List Of Queries And Tables

Sep 12, 2015

Suppose someone has to work on a lot of different SQL Server Databases which have got a lot of Tables and Queries / Views inside them.

After a period of time, it becomes very difficult to remember exactly what kind of columns are present within a given Table and View.

Any method by which one can keep a systematic list of all the Tables and Views that are present within a SQL Server Database, along with the columns that are present within them.

Are there any Add-on products or services etc. available in making this type of work systematic?

Currently I add comments to each queries inside SQL Server to remind me of what this query is doing, but this method is not great.

View 2 Replies View Related

How To Change The Sql Queries Generated Internally

May 3, 2007

We are trying a cluster setup on MS SQL 2005 with one m/c as Publisher (Primary) and another as Subscriber (Secondary).

When Publisher and Subscriber both are running, everything goes fine but when Publisher server goes down, subscriber server troubles.



We are using MSADO15.DLL for database connectivity.

We have a table where ID column is set to primary key with Auto Increment true.

We use AddNew() function of this library to insert a new record.

We fill a structure with all necessary values to pass it to AddNew() with ID field set to 0.

When we use AddNew() on the above table to insert a record, the ID auto inserted in table is correct but returned structure contains wrong ID value.



We tried to trace this problem using SQL Server Profiler Tool of SQL Server.

AddNew() function performs following operations in back end

1. Inserts the record to the table using INSERT

2. Calculates the auto increment field ID using SELECT @@IDENTITY

3. Fills this ID in the structure passed to AddNew() and returns it.

But ID returned by SELECT @@IDENTITY query is wrong.

There are other ways also to retrieve the last ID inserted in table by

IDENT_CURRENT(‘table_name’) which return right ID.



Can we change the call of SELECT @@IDENTITY to IDENT_CURRENT in AddNew() functions behavior of MSADO DLL?

Or there is another way of retrieving right ID

View 1 Replies View Related

How To Change The Sql Queries Generated Internally

May 3, 2007

We are trying a cluster setup on MS SQL 2005 with one m/c as Publisher (Primary) and another as Subscriber (Secondary).

When Publisher and Subscriber both are running, everything goes fine but when Publisher server goes down, subscriber server troubles.



We are using MSADO15.DLL for database connectivity.

We have a table where ID column is set to primary key with Auto Increment true.

We use AddNew() function of this library to insert a new record.

We fill a structure with all necessary values to pass it to AddNew() with ID field set to 0.

When we use AddNew() on the above table to insert a record, the ID auto inserted in table is correct but returned structure contains wrong ID value.



We tried to trace this problem using SQL Server Profiler Tool of SQL Server.

AddNew() function performs following operations in back end

1. Inserts the record to the table using INSERT

2. Calculates the auto increment field ID using SELECT @@IDENTITY

3. Fills this ID in the structure passed to AddNew() and returns it.

But ID returned by SELECT @@IDENTITY query is wrong.

There are other ways also to retrieve the last ID inserted in table by

IDENT_CURRENT(‘table_name’) which return right ID.



Can we change the call of SELECT @@IDENTITY to IDENT_CURRENT in AddNew() functions behavior of MSADO DLL?

Or there is another way of retrieving right ID?

View 1 Replies View Related

Optimizing Queries Generated At Runtime

Sep 5, 2007

Hi

We are using SQL SERVER 2005, enterprise/standard edition for an application that generates queries at runtime and normally having many joins in it. But these queries are taking lot of time when they are executed. After setting the database parameter PARAMETERIZATION to FORCED, performance of the queries have improved a lot but still we want to improve them further. Is there any other parameter that we can set for improving the performance of the queries. We have created the indexes on the basic columns that will be used while querying but it may happen that some other columns may also be used for searching in which case queries become quiet slow. Is there anything like skip-scan indexes(of oracle) in sql server 2005.

Regards
Salil

View 4 Replies View Related

Bad Performance In Queries With Jet4.0 And Linked ODBC-tables To SQL-Server 2000

Jul 20, 2005

I changed from Access97 to AccessXP and I have immense performanceproblems.Details:- Access XP MDB with Jet 4.0 ( no ADP-Project )- Linked Tables to SQL-Server 2000 over ODBCI used the SQL Profile to watch the T-SQL-Command which Access ( whocreates the commands?) creates and noticed:1) some Jet-SQL commands with JOINS and Where-Statements aretranslated very well, using sp_prepexe and sp_execute, including thesimilar SQL-Statement as in JET.2) other Jet-SQL commands with JOINS and Where-Statements aretranslated very bad, because the Join wasn´t sent as a join, Accesscollects the data of the individual tables seperately.Access sends much to much data over the network, it is a disaster!3) in Access97 the same command was interpreted wellCould it be possible the Access uses a wrong protocol-stack, perhapsJet to OLEDB, OLEDB to ODBC, ODBC to SQL-Server orJet to ODBC, ODBC to OLEDB and OLEDB to SQL-Server instead ofJet to ODBC and ODBC direct to SQL-ServerDoes anyone knows anything about:- Command-Interpreter of JetODBC, Parameters, how to influence thecommand-interpreter- Protocol-Stack of a Jet4.0 / ODBC / SQL-Server applicationThanks , Andreas

View 6 Replies View Related

Integration Services :: Get Data From Source By Executing Set Of Queries That Have Temp Tables

Jul 29, 2015

I need to grab data from teradata(using odbc connection).. i have no issues if its just bunch of joins and wheres conditions.. but now i have a challenge. simple scenario, i have to create volatile table, dump data into this and then grab data from this volatile table. (Don't want to modify the query in such a way i don't have to use this volatile table.. its a pretty big query and i have no choice but create bunch of volatile tables, above scenarios is just mentioned on simple 1 volatile table ).

So i created a proc and trying to pass this string into teradata, not sure if it works.. what options i have.. (I dont have a leisure to create proc in terdata and get it executed when ever i want and then grab data from the table. )

View 2 Replies View Related

SQL Server 2012 :: Find Queries That Lock Tables Or Not Using Primary Key While Running Update

Jul 20, 2015

I need to search for such SPs in my database in which the queries for update a table contains where clause which uses non primary key while updating rows in table.

If employee table have empId as primary key and an Update query is using empName in where clause to update employee record then such SP should be listed. so there would be hundreds of tables with their primary key and thousands of SPs in a database. How can I find them where the "where" clause is using some other column than its primary key.

If there is any other hint or query to identify such queries that lock tables, I only found the above few queries that are not using primary key in where clause.

View 2 Replies View Related

Saving Queries

Jun 20, 2007

I just started using Visual Studio 2005. How do you actually save your queries to use again? Also, is there a way to export results in a user friendly format?



thanks!

View 6 Replies View Related

SQL Express, Saving Queries?

Jan 30, 2007

I opened up a new project using Visual Basic Express, and selected the SQL object to start creating a database. Well I finished putting all of my tables together and started making the queries but for some reason I can't save them like when I finished making the tables. When I finished making the tables I could just click the disk icon and name the table and it would appear in a drill down menu on the left. However when I do that with the queries it just says it's saving in the lower left corner but it doesn't do anything?

I am new to VB & SQL so any help is appreciated. Thank you.

View 7 Replies View Related

How To Change The Sql Queries Generated Internally By Functions Supported By MSADO Dll For MS SQL Server2005

May 3, 2007

We are trying a cluster setup on MS SQL 2005 with one m/c as Publisher (Primary) and another as Subscriber (Secondary).
When Publisher and Subscriber both are running, everything goes fine but when Publisher server goes down, subscriber server troubles.

We are using MSADO15.DLL for database connectivity.
We have a table where ID column is set to primary key with Auto Increment true.
We use AddNew() function of this library to insert a new record.
We fill a structure with all necessary values to pass it to AddNew() with ID field set to 0.
When we use AddNew() on the above table to insert a record, the ID auto inserted in table is correct but returned structure contains wrong ID value.

We tried to trace this problem using SQL Server Profiler Tool of SQL Server.
AddNew() function performs following operations in back end
1. Inserts the record to the table using INSERT
2. Calculates the auto increment field ID using SELECT @@IDENTITY
3. Fills this ID in the structure passed to AddNew() and returns it.
But ID returned by SELECT @@IDENTITY query is wrong.
There are other ways also to retrieve the last ID inserted in table by
IDENT_CURRENT(€˜table_name€™) which return right ID.

Can we change the call of SELECT @@IDENTITY to IDENT_CURRENT in AddNew() functions behavior of MSADO DLL?
Or there is another way of retrieving right ID?

View 3 Replies View Related

Track The Changes To Normalised Tables And Update The Denormalised Tables Depending On The Changes To Normalised Tables

Dec 7, 2006

We have 20 -30 normalized tables in our dartabase . Also we have 4tables where we store the calculated data fron those normalised tables.The Reason we have these 4 denormalised tables is when we try to dothe calcultion on the fly, our site becomes very slow. So We haveprecalculated and stored it in 4 tables.The Process we use to do the precalcultion, will get do thecalculation and and store it in a temp table. It will compare the thetemp with denormalised tables and insert new rows , delte the old oneans update if any changes.This process take about 20 mins - 60mins. Ittakes long time because in this process we first do the calculationregardless of changes and then do a compare to see what are changed andremove if any rows are deleted, and insert new rowsand update thechanges.Now we like to capture the rows/columns changed in the normalisedtables and do only those chages to the denormalised table , which weare hoping will reduce the processing time by atleast 50%WE have upgraded to SQL SERVER 2005.So We like to use the newtechnology for this process.I have to design the a model to capture the changes and updated onlythose changes.I have the list of normalised tables and te columns which will affectthe end results.I thought of using Triggers or OUTPUT clause to capture the changes.Please help me with the any ideas how to design the new process

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved