Querying A Really Badly Designed Table

Mar 28, 2006

I am working on an application with a number of tables (which I can't
change) that have data of the form a1, b1, c1... a2, b2, c2...a3, b3,
c3... The tables contain 5 to 10 sets of data in each row.



I want to create a stored procedure to return a cursor with a row for
each set of data for a row of the table. I know I can use unions:



select a1 as a, b1 as b , c1 as c... from sometable where pk=@pk

union

select a2, b2, c2... from sometable where pk=@pk

union

select a3...



Is there a way that is more efficient (eliminates requerying the table and all the unions)?

View 4 Replies


ADVERTISEMENT

How To Collapsible A Column When The Report Was Designed In Table Mode?

Jun 30, 2006

Hi folks, I'm trying to collapse a column on a report that's designed in table mode. I was trying to mimick what happens in a matrix where you have a column that has a '+' in it that makes toggles the visibility of a column to its immediate right (The reason I'm not using Matrix mode is I continually get "out of memory" errors on the report I'm generating.).

When I select the column and mark visible to 'false' in the properties, it of course asks me for a TextBox. My problem is that I am unable to find a scenario where the textbox is "in the proper group". Is this something that's supported, and if so, I'd appreciate some pointers to lead me in the right direction.

Thanks.

View 6 Replies View Related

How To Change The Target Table Name In SSIS Package(not Designed From Scratch But Was Migrated)

Nov 6, 2007

In Past, I created DTS package on 2000 version, that import TXT file into SQL 2000 table.

Now I migrated the DTS to DTSX (SSIS) package, and all is working fine. but I can not find how can I edit or modify the target table name in DTSX(SSIS) package in BI Studio.

can you some body help.

Thanks

View 8 Replies View Related

Transact SQL :: Querying Data From Master Table Into Transaction Table?

Oct 13, 2015

I am stuck in the following scenario.

Tbl_Loan
Trans_ID
Emp_ID
Guarantor_1_ID
Guarantor_1_ID
TRN_01
EMP_01

[code]....

View 5 Replies View Related

SQL Query Help Needed Badly!

Jun 17, 2004

The database is setup as follows:

id (int)
campaign_id (int)
run_date (smalldatetime)
user_id (int)
result (text)
result_id (int)

result_id is an int 1-4 and I am inner joining another table that holds the Campaign_Title on campaign_id. What I would like to be able to do is select the Campaign_Title and then a sum of each of the result_id's but I need to do this by run_date. I would then like to be able to bind it to a datagrid. I have been racking my brain for days now and I can't seem to make the query return the correct results.

Please help! Let me know if you need more information!

View 6 Replies View Related

SQL Server DATEDIFF Behaving Badly

May 10, 2004

Hi,

I'm using the following SQL String in an ASP script with SQl Server:

SELECT time, DATEDIFF(minute, time, '18:00:00') AS difference FROM appointments

I have two appointments in the database - one with a time of 11:00 and one with a time of 14:00.

When I run this SQL query, 'difference' comes out exactly 48 hours more than it should do. So for the first appointment, it says that the difference is 3300 minutes and for the second it is 3120 minutes.

Any idea why this is happening? Is it something to do with the fact that I'm not using dates in the datetime format?

Paul

View 14 Replies View Related

Transactional Replication Newbie, Badly Need Help!

Sep 12, 2006

hi there! i am a newbie with replication. i am trying to implement one, however due to lack of references, there are some difficulties. here are some of my questions, i am hoping anybody could take their time to help me out in details. Thanks and appreciate it!

(1) i could not publish all tables. tables that do not have primary keys are not included, and i need to publish all tables.

(2) tables that i sucessfully published does not replicate the table's primary keys, relationships and triggers, how do i update the subsciber?

(3) for some reason, i could not replicate schema objects - views, UDFs, stored procedures. its giving me an error.

Please advise.

Again, thank you so much!

View 4 Replies View Related

Subscription Email Rendering Badly

Apr 3, 2007

I have created a very simple report that includes a single table with three cells per row.



When I view the report in Visual Studio, on the Report Server, in any format, it looks fine. However, the version that gets emailed as a subscription looks awful. The width of my table cells is not preserved, so they shrink to be as narrow as possible with all the words wrapping.



Basically, the table gets smooshed so that it's much narrower than it should be. All the words wrap when they shouldn't.



CanShrink is set to False. I have tried CanGrow on both False and True and it didn't make any difference.



Remember, the problem is only with the emailed version of the report.





Any idea if there's a solution for this?



Thanks,

Dan

View 4 Replies View Related

Help Needed Badly For Designing SSIS Package??

Apr 4, 2008



Hi guys

I have got a set of queries to run on a table stored in my SQL Database and this query creates a new table which I export to excel for final results.
NOw I need to design an SSIS package for this query to run and to export the result in excel sheet.
I started with the control flow by adding the TSQL statements to it and then in the data flow I connected it with my database.
But when I execute it, it always gives me an error.
I have just started learning SSIS but have not been able to figure it our properly.

Could you please help me out??

Thanks

View 5 Replies View Related

Querying Using Another Table

Apr 30, 2008

Hello all,

I have a table (tbl_a) with 2 columns: itemNames | Date .
ItemNames can have duplicates.
I have another table (tbl_b) with date ranges in 2 columns: startDate | endDate.

what I would like to do is: query tbl_a where date between startDate and endDate of tbl_b.

does anyone have an idea?
thanks in advance.

View 2 Replies View Related

Querying Table More Than Once

Jun 12, 2008

Hi All

Thx in advanced for any help anyone can offer me.

I have 2 tables Staff and Class which are as follows

Staff
ID (Primary Key)
FirstName
MiddleName
Surname
Etc. . .

Class
ID (Primary key)
LessonTemplateID
TeacherID
TermID
AssistantID

LessonTemplateID and TermID link to other tables which i don't need right now.

The Class.TeacherID and Class.AssistantID both link to the Staff.ID

I am trying to create a query where i can say i want to select a class.ID of lets say 12 and display both the Teachers name and the Assistants Name.

If i do just one join between Staff.ID and lets say Class.TeacherID all is fine and i can display the teacher.FirstName for a particular class.ID. However my problem is when im trying to display both teacher and assistant. Every time i try to create a query to do this the query comes back blank.

Im really stuck on this and just can't figure it out (is it even possible?).

Thx for any help Scott.

View 2 Replies View Related

Querying Between Table Adapters ?

Sep 12, 2006

Hi all, I am currently moving from access queries to SQL and am using the query Builder In Visual web developerto help me with the SQL Code..This has been easy while just querying the one table adapter but Now I am stuck..I have a table adapter that links to an SQL Server database through a connection in web.config.I have another table adapter that links to DB2 through a different Connetion in web.config.My question is ..How do you query from one table adapter to another.Each table adpater can only query based on the 1 connection ? Thx,Ray..

View 1 Replies View Related

Log Users Querying Table

May 17, 2000

We have been asked to keep a log of users querying a particular table.
User's can query any odbc compliant tool, not just one application.

Can we do this w/ sql server 7?

View 1 Replies View Related

Connection Handshake Failed: Unexpected Or Badly Formatted Message.

Sep 13, 2007

Hello,

I am unable to send a message to a target service on a different SQL Server instance. Using the SQL Profiler, I get the following error from the target machine:

Broker::Connection: Connection handshake failed: An OS call failed: (80090326) 0x80090326(The message received was unexpected or badly formatted.). State 106.

On the initiator side, the transmission_status shows the following error:

An error occurred while receiving data: '64(The specified network name is no longer available.)'.

Any ideas on why the target thinks the message is "unexpected or badly formatted"? Btw, I am specifying the default message type and contract for the services.

Thanks.

View 1 Replies View Related

Querying The Size Of Table Fields?

Jun 5, 2008

Hello I am writing a stored procedure and instead of "hard coding" the size of the procedure parameters I would like to set them to the size of fields in my database.
 for example instead of declaring a parameter like this:
@ProjectDescription varchar(500)
 
I would like to do something like this:
 
@ProjectDescription varchar(Select size of "ProjectDescription" From Projects);
 
Thanks for the help! 

View 4 Replies View Related

How To Keep Original Order When Querying A Table?

Sep 10, 2004

Hello, everyone:

I have a table like:

ColName
b
b
b
d
d
d
a
a
c
c
c

I use DISTINCT to filter duplicated row. I want to get the return by original order like:
b
d
a
c

However, SQL Server re-order it if using DISTINCT and return like:
a
b
c
d

Can any one have the idea to handle that? Thanks

ZYT

View 4 Replies View Related

Querying Table In Arbitrary Database

May 1, 2006

Would appreciate some help with this one. I need to run a query on a known table an arbitrary database. The DB name will be selected at runtime.

What I've tried:

DECLARE @DBName varchar(10)
SET @DBName = 'WBTST'

SELECT TOP 100 PERCENT Col1, Col2
FROM [@DBName].dbo.Table1
GROUP BY Col1

Result:
Invalid object name '@DBName.dbo.UPR00100'.

I've also tried without the square brackets around @DBName in the FROM clause. This results in: Incorrect syntax near '.'.

Thanks for the help
Wes

View 2 Replies View Related

SQL Query Question- Querying The Middle Table In A M To M

May 17, 2000

I need help with a query, and I haven't seen anything like this in a SQL book.

I will use the Northwind database for this example. The tables I am using are Products, Order_Detail, and Orders. There is a many to many relationship between Products and Orders, that is resolved by the Order_Detail table. Suppose I want to find out which products are related to each order. How would I query the tables?

Thanks everyone,
Nathan

View 1 Replies View Related

Querying Single Table For Multiple Summaries - How?

Jul 20, 2005

Folks,While I still have some hair left, can someone help me with thisquery?I have a table "TestRunInfo". Amongst other fields there are"TestRunIndex" (Pri Key), "TesterID", "Duration", and "Status".The Status field links to a Status table, which links the index valueto a more meaningful label "Pass", "Fail" etc...As you may have guessed, there is a record for each test that anindividual tester runs, and with that record is a duration, and status(1,2,3 etc).What Im trying to do, is create a datasheet view, with a single rowfor each testerID, summarising that Testers work as follows:TesterID, Total Duration, Count of passed tests, Count of failed testsSo far I have:Select TesterID, sum(Duration), count(Status) FROM TestRunInfo GROUPBY TesterIDBut this of course purely gives the total number of tests run by thatengineer as the count. I need to break it down. Help? Someone?Please?!?!?TIASteve

View 2 Replies View Related

Transact SQL :: Is Table Will Be Extracted When Querying To DB Views

Sep 15, 2015

I wonder how the query will be executed when querying to views.Is database engine will be extract the tables that are used to create the view and query for the result ?

View 5 Replies View Related

Data Warehousing :: Querying In Fact Table

May 2, 2015

I have a Fact Table with a ID column as Primary key and clustered index is created. And also I have 4 dimensions FK's of data type INTEGER. And finally, I have one aggregation measure in the Fact Table.

Now, my situation is How can I improve the speed of querying the fact table by creating any of the below indexes?

1. XML
2. Spatial
3. Clustered
4. Non-Clustered

View 2 Replies View Related

Relationships Correctly Designed?

Feb 26, 2008

I am new to SQL Server 2005. I have tried to be a good student and learn on my own about designing the database. However, I am facing a blockage of getting data into the database. I want to verify I have setup the relationships correctly. Here is the tables.

1. A Manufacture has an Address.
2. A Manufacturer has one or more Distribution Points.
3. A Distribution Point has an Address.

The Manufacturer --> Address is a one-to-one relationship.
The Distribution Point --> Address is a one-to-one relationship.
The Manufacturer --> Distribution Point is a one-to-many relationship.

The manufacturer table has a FK to the address id (PK).
The distribution table has a FK to the address id (PK).
The distribution table has a FK to the Manufacturer id (PK).
Address has several other FK, but not used in this scenario.

The INSERT and UPDATE Specification for the Delete Rule and Update Rule is set to "No Action" for the Manufacturer and Address tables. In the Distribution Point table, the relationship for the update rule involving the relationship with the Address and Manufacturer tables is set to CASCADE. What this tells me is SQL Server 2005 will update the table should changes occur in Address and Manufacturer table.

Is there anything else I can check to be sure the issue I am facing is NOT the deisgn of the database?

Thanks for taking the time to read my post.

Russ

View 1 Replies View Related

Is SQL Server Express Designed For Production Use ?

Jan 27, 2007

Per the subject line :Is SQL Server Express designed for production use ?

View 11 Replies View Related

Moving A Poorly Designed Database To SQL

Sep 27, 2001

I have a Access database which has a address field with multiple data sets in it. I am new to writing code and am having trouble finding a example which will help me split these values out into three seperate fields.

Notice how there is no good order in how they are placed.... Some entry's have commas and some don't. Some have periods and some don't.
EX:
[BILL_ADDR3]
AMHERST, WI. 54406
ASHLAND, WI 54806
ASKOV MN 55704

I then need to convert the state to a state code ie:

2 AK
3 AL
4 AR
5 CA
6 CO
7 CT
8 DC
9 DE
10 FL
11 GA
12 HI
13 IA
14 ID
15 IL
16 IN
17 KS
18 KY


Any good sources of information would be greatly appreciated..... Thank You

View 1 Replies View Related

Who's The Idiot That Designed The File Destination?

Jan 23, 2007

It's funny:

Everyone thinks that CSVs are awesome to transport data. I mean after all, SSIS defaults to Comma Delimited files. Even Excel defaults to it. Microsoft is supposed to be our leader! They should get this right. And get the terminology correct too. How many people describe the file as comma separated? It's delimited! Even SQL server calls it delimited by the "delimited" drop down.

CSVs suck and i will tell you why:

When you transport any text field (especially Address) it has the possibility of containing a comma. This causes data to be parsed into the wrong fields. Why in God's grace would you EVER get in the habit of choosing a delimiter that SOMETIMES doesn't work?

I'll tell you a little short story:

I have been waiting (at work) for like a month for a guy to export data and give me this file. Well today i finally got that file. He was in a hurry and used the Defaults to export this file. I don't blame him for being in a hurry and using the defaults. Well the defaults made the import NOT work because the data parsed into the wrong columns. Comma delimited would work if there was a text qualifier. But the default is comma delimited and NO text qualifier. What idiot thought that would be good. Or it was the separation of duties that eff'd this one up? Who knows?

Fix your products!

That's my .02

View 14 Replies View Related

Is SQL Server Express Designed For Production Use?

Jan 28, 2007

Per the subject line :

Is SQL Server Express designed for production use?

View 9 Replies View Related

SQL Server 2012 :: Querying Table With Several Date Type Columns

Oct 30, 2014

I have a table (we will cal DateTable) with several (20) columns, each being a date type. Another table's (Project) PK is referenced in the DateTable.

I am trying to write a query that will pull all dates for a specific project from the DateTable if they meet certain criteria(i.e. if the date is <= 7 days from now.

I started with a normal select statement selecting each column with a join to the project and then a where clause using

(DateTable.ColumnName BETWEEN GETDATE() AND DATEADD(day, 7, GETDATE()) OR (DateTable.ColumnName BETWEEN GETDATE() AND DATEADD(day, 7, GETDATE())) ...

The rest of the columns(all with OR between them).

The problem with this is that because I am using OR once one of the dates meets the criteria it selects all the dates that are associated with the project. I ONLY want the dates that meet the criteria and don't care about the rest.

Obviously because I have all the columns in the select statement... So I need something like

Select ALL Columns
from DateTable d
Join Project p
where p.ProjectID = d.ProjectID AND only dates BETWEEN GETDATE() AND DATEADD(day, 7, GETDATE()))

View 2 Replies View Related

I Need To Generate The Query To Build A Database I've Designed. Please Help..

Apr 3, 2007

I've registered with GoDaddy for my site. I've used Visual Web Dev 2005 with SQL Server Mgmt Express 2005 to create my database etc. Now with GoDaddy, I need to "recreate" the database on their server again, but I don't want to go throug the whole process again. I just want to use their query editor to generate the database online.GoDaddy mentions a "personal-sql" file that SQL Server 2000 generates, but I can't find anything like that with what I have. Thanks.

View 1 Replies View Related

Query A SQL Server Compact Table While Querying A SQL 2005 Server Table

May 21, 2008

Hi there,

I'm trying to run a query on a SQL Server 2005 table which has a WHERE clause that requires a query from my SQL Compact table.



SELECT * from RemoteDB.TESTDB.dbo.Objects

WHERE Last_Updated > '2008-05-21 10:51:00'

AND Object_PARENT IN (select Object_CODE from LocalDB.PDADB.dbo.Objects)


Basicallly on a linked system, this query would find all new objects in my main database where the same objects exist in my local database. This would work just perfectly, no problems.

Now, the local database is actually on a PDA running SQL Server Compact Edition. There is currently no support for creating a linked environment. I have the option of pulling the table off the local db and pushing it to the remote db and then running the above query from within the single db and then retrieving the list of new entries and pulling them down to the local db but that is a HUGE amount of bandwidth, even if I just used the single primary key column.

Would anyone maybe have a little advice for me on how I could possibly achieve the above result on SQL Server Compact please?


Thanks in advance

View 10 Replies View Related

Viewing Reports Designed On SQL 2005 Reporting Server

Jan 8, 2007

I have built the reports that I need using Visual Studio and the SQL 2005 Reporting Server, but now I need a way to view the reports via a web browser.

I am not much of a web/programming expert, so any help that could walk me through the process of publishing the .rdl files that I have created via a web browser would be much, much appreciated. Again, I am a novice in the the web arena, so the more straight forward the steps the better.

Thanks!



View 2 Replies View Related

Trouble With Cursor Designed To Revoke Object Access.

May 30, 2008

Hi everyone. I am having difficulties with a cursor that I am trying to write. The purpose of the cursor is to loop through all tables in a selected Database and revoke "Select" access to that table for the indicated role (RoleToRevoke). I am getting the error on the @name variable within the REVOKE statement. I have placed a comment indicating where I am getting the error. Is there a way to have sql server interpret this @name variable within the REVOKE statement? Thanks for your help.




Code Snippet

USE [Database_Name];

Declare cursorExample Cursor for
Select TABLE_NAME
from information_schema.tables
Where TABLE_TYPE='Base Table'
and TABLE_SCHEMA='dbo'

Declare @name as varchar(255)
Declare @ErrorSave as int
Declare @ErrorCount as int

Open cursorExample

Fetch Next from cursorExample into @name


SET @ErrorSave = 0
SET @ErrorCount = 0




Begin Tran

While @@Fetch_Status=0

Begin

--Getting Error on Line below on @name
REVOKE SELECT ON OBJECT::@name FROM RoletoRevoke;

IF (@@ERROR <> 0)

BEGIN

Print 'Error Revoking Access to Table: ' + CAST(@name AS varchar(75))
SELECT @ErrorCount = @ErrorCount + 1
END
IF (@@ERROR = 0)

BEGIN

Print 'Successful Revoking Select Rights on Table: ' + CAST(@name AS varchar(75))








SELECT @ErrorSave = @ErrorSave + 1
END
Fetch Next from cursorExample into @name


End

IF @ErrorCount = 0

BEGIN

COMMIT TRAN
PRINT 'COMMITTED TRANSACTION'
PRINT 'Total Tables Affected:' + CAST(@ErrorSave AS varchar(75))
END
ELSE

BEGIN

ROLLBACK TRAN
PRINT 'ROLLED BACK TRANSACTION'
END

Close cursorExample
Deallocate cursorExample
GO

View 9 Replies View Related

SQL Server 2012 :: Querying A Supersession Two Column Table With Multiple Supersessions In Both Columns

Jan 29, 2014

I'm fairly new to SQL and am just setting up a Windows 8 app using an Azure SQL server. The issue I have is looking up a part number supersession and getting the latest number. One part number can have multiple supersessions (ie RTC5756 > STC8572 > STC3765 > STC9150 > STC9191 > SFP500160 ).The data I am supplied monthly has both the superseeded items and the supersession information in both columns and is not easy to decipher - for example:

Supersessions Table
----------------------

RTC5756 | STC9191
SFP500160 | STC9191
STC9191 | STC2951
STC3765 | STC9191
STC8572 | STC9191
STC9150 | STC9191

[code]...

The newest part number is kept in a separate table - called "source" - which in this instance is SFP500160. I need access to the latest part number but also to the part's previous numbers, due to the fact that some people may still be stocking them as an old part number and for them to search by. Is there an easy and efficient way of doing both a lookup for the supersessions and a join on the two tables to minimize the queries on the database?

View 9 Replies View Related

SQL Server Admin 2014 :: How To Read And Load Extended Events Into A Table For Querying

Jun 19, 2015

I am setting up extended events more or less just fine, however I am a bit confused as to how to read and load them into a table for querying. In particular the offset part - is there a way to load just a given dates worth in?

I've got the files configured to be 20MB before rolling over, the XE is running all the time.

So if i load in the full file now, say that covers 2.5 days worth, when I load it again tomorrow to get the updated data I'm also reloading today, which is a waste?

I presume I am going about this wrong, but lack an example that really goes into detail of practicalities of loading this data.

View 0 Replies View Related







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