Swapping Rows And Column
Apr 5, 2001
I have a table that has a column for each month and I want to use a view to convert each row into 12 rows with a one month column. The month column will have 1 - 12 in it depending on the month. I need to convert it this way to push it into an Essbase cube. I know I can use the union operator to do this, but I would rather not read the table 12 times. Is there a way to do this just reading through the table once? My Hyperion Essbase book gives an Oracle example for swapping rows and columns by using a decode function. Is there a similar function in SQL Server?
View 2 Replies
ADVERTISEMENT
Jun 25, 2015
I have questions and answers from one table, I need to select questions as column names and answers column values as the results for the questions column.
View 28 Replies
View Related
Mar 29, 2007
suppose i have aDataset with 11 rows. field1 with 5 rows of aaa, 6 rows of "bbb"
I want's some thing like
field1 rowcount
aaa 5
bbb 6
View 1 Replies
View Related
Mar 19, 2008
I am converting a legacy ASP.NET 1.x site to an ASP.NET 2 one. In the former site, sets of data connections are stored in an web.config file allowing swapping between testing and production servers based on a global variable value at the start of the app. As I now try to use sqldatasource, I find the control has its connection string embedded in the html page and stored as a unique variable in the web.config. How can I dynamically swap the new sqldatasource's connectionstring the same way data connections are made in the former site? Please advise. Thanks.
View 6 Replies
View Related
Jul 23, 2005
I need to build a *.sql script that will remove a database (let's callit "DB1") and replace it with a brand new empty database (let's call it"DB2").Caveat: I don't want to be left with database "DB1" having it's filesconfusingly named "DB2.mdf" and "DB2_log.ldf". These two files shouldalso be renamed to "DB1.mdf" and "DB1_log.ldf" so that outsidecustomers are not left confused. In addition, I need to be able torestore the original DB1 if anything goes wrong during, or even after,the entire process.Let's assume every customer's *.mdf's and *.ldf's will always reside inC:Program FilesMicrosoft SQL ServerMSSQLdata folder.I've researched sp_attach_db, but this looks more appropriate formoving databases. This isn't what I want to do.Thank you in advance.
View 1 Replies
View Related
Dec 21, 2007
Hi,
Is it possible on a matrix report for the rows and columns to be swapped around after the report has been built? E.g, can the rows and columns be swapped around by the user in the preview page?
thanks,
Al
View 6 Replies
View Related
May 16, 2008
I've got a field that might have spurious values in it (say, an admin adds a new row but doesn't have an entry for this field).
I'm trying to swap in the string no_image_EN.jpg if the value in the db does NOT end in .jpg. That way, any value rreturned is either a valid filename or no_image
I'm having trouble with the CASE statement, particularly testing just the last few cahracters of the string:
select product_code,
CASE can_image_en
?? When (can_image_en LIKE '%.jpg') then can_image_en
Else 'no_image_EN.jpg'
End as can_image_en,
none of these do the trick either (some are bad syntax obviously):
? When (can_image_en LIKE '%.jpg') then can_image_en
? When LIKE '.jpg' then can_image_en
? When '%.jpg' then can_image_en
? When right(can_image_en,4) = '%.jpg' then can_image_en This is the one that has correct syntax, though it seems to return false in ALL cases CASE can_image_en
When '%.jpg%' then can_image_en
Else 'no_image_EN.jpg'
View 5 Replies
View Related
Jul 3, 2015
As part of a migration of data to a new SAN I have hit a bit of a snag in the migration. In summary what will happen is user database data files will be moved from one LUN (say drive F:) to a new LUN (say drive G:). Once all the data is migrated, plan is to remove dependency of that drive from SQL server and remove the drive and delete the LUN. So far, so good.
However one of the LUNs (drive D:) destined to be deleted also hosts the instance default directories, i.e. everything under MSSQL11.MSSQLSERVER (Data, Backups, FTData, JOBS, etc). BOL has articles on how to migrate system databases, including tempdb. But there is no guidance that I could find on how to relocate other folders. There are forums where users have listed registry changes, etc that can achieve this but these are steps I am unwilling to take on a production server.
So my plan is:
1) Add new drive to cluster (drive E:), sufficiently large enough to host instance default folders
2) Shutdown SQL server
3) Copy all default folders to new drive
4) Swap drive letters so that new drive is now D:
5) Start SQL server and if everything works, delete the original drive (which is now drive E:).
View 3 Replies
View Related
Jul 20, 2005
All,To make a long story short, we are swapping out the "knock-off" drivesthat the NA purchased on E-Bay in one of our production SQL Servers(SQL Server 2000 Enterprise) this weekend for brand new ones (Compaq15K RPM 32GB drives). We are currently experiencing ASR almost on adaily basis and it is really causing a disription in service. SO, TheNetwork Admin ahs made this decison to replace these drives in attemptto solve this. These new drives will be imaged with ALL of the currentdata on the "knock-off' drives and will be plugged back in to thisdatabase server and brought back up .This Server also happens tocurrently be a subscriber in Merge Replication as well. Besidesstopping replication to this subscriber is there any other tasks thatI need to do or concerns that I need to be knowledgable about or lookfor when we bring this database server backup on line this weekend?Thanks Travis. :)
View 1 Replies
View Related
Feb 27, 2007
HI ,
Need some quick fix Help
I have been
trying to load data from AS400 to DB2 (windows) using ADO.NET connection in
Data reader source and OLEDB Destination (IBM Oledb provider )
The files, I€™m trying to load, have
number of rows more then 15 million.
On execution of the package I get
Out of Memory Error (see below)
My Destination Box is 4GB+ RAM and 4
CPU Box.
There seems to be some Buffer and
Swapping related issue which I€™m not able to figure out. It says that System is
unable to allocate memory
Please help me on the same.
Thanks in Advance
Amit S
SSIS package "ABCDE
1.dtsx" starting.
Information: 0x4004300A at ABCDE
2003 to 2004, DTS.Pipeline: Validation phase is beginning.
Information: 0x4004300A at ABCDE
2003 to 2004, DTS.Pipeline: Validation phase is beginning.
Information: 0x40043006 at ABCDE
2003 to 2004, DTS.Pipeline: Prepare for Execute phase is beginning.
Information: 0x40043007 at ABCDE
2003 to 2004, DTS.Pipeline: Pre-Execute phase is beginning.
Information: 0x4004300C at ABCDE
2003 to 2004, DTS.Pipeline: Execute phase is beginning.
Error: 0xC0202009 at ABCDE
2003 to 2004, OLE DB Destination [12]: An OLE DB error has occurred. Error
code: 0x8007000E.
An OLE DB record is available.
Source: "Microsoft Cursor Engine" Hresult: 0x8007000E Description:
"Out of memory.".
Error: 0xC0047022
at ABCDE 2003 to 2004, DTS.Pipeline: The ProcessInput method on component
"OLE DB Destination" (12) failed with error code 0xC0202009. The
identified component returned an error from the ProcessInput method. The error
is specific to the component, but the error is fatal and will cause the Data
Flow task to stop running.
Error: 0xC0047021 at ABCDE
2003 to 2004, DTS.Pipeline: Thread "WorkThread0" has exited with
error code 0xC0202009.
Error: 0xC02090F5
at ABCDE 2003 to 2004, DataReader Source [61]: The component "DataReader
Source" (61) was unable to process the data.
Error: 0xC0047038 at ABCDE
2003 to 2004, DTS.Pipeline: The PrimeOutput method on component
"DataReader Source" (61) returned error code 0xC02090F5. The
component returned a failure code when the pipeline engine called
PrimeOutput(). The meaning of the failure code is defined by the component, but
the error is fatal and the pipeline stopped executing.
Error: 0xC0047021 at ABCDE
2003 to 2004, DTS.Pipeline: Thread "SourceThread0" has exited with
error code 0xC0047038.
Information: 0x40043008 at ABCDE
2003 to 2004, DTS.Pipeline: Post Execute phase is beginning.
Information: 0x40043009 at ABCDE
2003 to 2004, DTS.Pipeline: Cleanup phase is beginning.
Information: 0x4004300B at ABCDE
2003 to 2004, DTS.Pipeline: "component "OLE DB Destination"
(12)" wrote 289188 rows.
Task failed: ABCDE 2003 to
2004
Warning: 0x80019002 at ABCDE
1: The Execution method succeeded, but the number of errors raised (6) reached
the maximum allowed (1); resulting in failure. This occurs when the number of
errors reaches the number specified in MaximumErrorCount. Change the
MaximumErrorCount or fix the errors.
Executing ExecutePackageTask:
C:Documents and SettingsAdministratorMy DocumentsVisual Studio
2005ProjectsIntegration Services Project1Integration Services Project1ABCDE
2.dtsx
Information: 0x4004300A at ABCDE
2005_04 to 2005_11, DTS.Pipeline: Validation phase is beginning.
Information: 0x4004300A at ABCDE
2005_04 to 2005_11, DTS.Pipeline: Validation phase is beginning.
Information: 0x4004300A at ABCDE
2005_04 to 2005_11, DTS.Pipeline: Validation phase is beginning.
Information: 0x40043006 at ABCDE
2005_04 to 2005_11, DTS.Pipeline: Prepare for Execute phase is beginning.
Information: 0x40043007 at ABCDE
2005_04 to 2005_11, DTS.Pipeline: Pre-Execute phase is beginning.
Information: 0x4004300C at ABCDE
2005_04 to 2005_11, DTS.Pipeline: Execute phase is beginning.
Information:
0x4004800D at ABCDE 2005_04 to 2005_11, DTS.Pipeline: The buffer manager failed
a memory allocation call for 10484320 bytes, but was unable to swap out any
buffers to relieve memory pressure. 3 buffers were considered and 3 were
locked. Either not enough memory is available to the pipeline because not
enough are installed, other processes were using it, or too many buffers are
locked.
Error: 0xC0047012
at ABCDE 2005_04 to 2005_11, DTS.Pipeline: A buffer failed while allocating
10484320 bytes.
Error: 0xC0047011
at ABCDE 2005_04 to 2005_11, DTS.Pipeline: The system reports 63 percent memory
load. There are 4294660096 bytes of physical memory with 1548783616 bytes free.
There are 2147352576 bytes of virtual memory with 227577856 bytes free. The
paging file has 6268805120 bytes with 3607072768 bytes free.
Error: 0xC02090F5 at ABCDE
2005_04 to 2005_11, DataReader Source [61]: The component "DataReader
Source" (61) was unable to process the data.
Error: 0xC0047038 at ABCDE
2005_04 to 2005_11, DTS.Pipeline: The PrimeOutput method on component
"DataReader Source" (61) returned error code 0xC02090F5. The
component returned a failure code when the pipeline engine called
PrimeOutput(). The meaning of the failure code is defined by the component, but
the error is fatal and the pipeline stopped executing.
Error: 0xC0047021 at ABCDE
2005_04 to 2005_11, DTS.Pipeline: Thread "SourceThread0" has exited
with error code 0xC0047038.
Error: 0xC0047039 at ABCDE 2005_04
to 2005_11, DTS.Pipeline: Thread "WorkThread0" received a shutdown
signal and is terminating. The user requested a shutdown, or an error in
another thread is causing the pipeline to shutdown.
Error: 0xC0047021 at ABCDE
2005_04 to 2005_11, DTS.Pipeline: Thread "WorkThread0" has exited
with error code 0xC0047039.
Information: 0x40043008 at ABCDE
2005_04 to 2005_11, DTS.Pipeline: Post Execute phase is beginning.
Information: 0x40043009 at ABCDE
2005_04 to 2005_11, DTS.Pipeline: Cleanup phase is beginning.
Information: 0x4004300B at ABCDE
2005_04 to 2005_11, DTS.Pipeline: "component "OLE DB
Destination" (12)" wrote 0 rows.
Task failed: ABCDE 2005_04 to
2005_11
Warning: 0x80019002 at ABCDE:
The Execution method succeeded, but the number of errors raised (7) reached the
maximum allowed (1); resulting in failure. This occurs when the number of
errors reaches the number specified in MaximumErrorCount. Change the
MaximumErrorCount or fix the errors.
Executing ExecutePackageTask:
C:Documents and SettingsAdministratorMy DocumentsVisual Studio
2005ProjectsIntegration Services Project1Integration Services Project1ABCDE
3.dtsx
Information: 0x4004300A at ABCDE
2005_11 to 2006_04, DTS.Pipeline: Validation phase is beginning.
Information: 0x4004300A at ABCDE
2005_11 to 2006_04, DTS.Pipeline: Validation phase is beginning.
Information: 0x4004300A at ABCDE
2005_11 to 2006_04, DTS.Pipeline: Validation phase is beginning.
Information: 0x40043006 at ABCDE
2005_11 to 2006_04, DTS.Pipeline: Prepare for Execute phase is beginning.
Information: 0x40043007 at ABCDE
2005_11 to 2006_04, DTS.Pipeline: Pre-Execute phase is beginning.
€¦€¦.
€¦€¦€¦€¦
View 11 Replies
View Related
Apr 11, 2007
Hello - I have a SQL 2000 server which has a D: drive that contains all of my databases (system and user). I am running out of space on this volume and need to migrate the contents of this volume to a larger one. My initial plan was to introduce a new volume to the server (say a K: drive). Backup all databases (of course), and then stop all SQL services. Copy all data from D: to K:. Once data is copied, swap drive letter names (D: to I: and then K: to D. Then restart SQL services. SQL should not know any better since everything was on the D: drive when it went down, and everythiing is still on the D: drive when it came back up, correct?
The other option mentioned is to detatch the databases, copy the data and then reattach them in their new locations. I understand this method, but it seems more involved (and riskier) than just renaming the drives. Does anyone have an opinion regarding these two migration methods? Thanks for your help.
Chris
View 3 Replies
View Related
May 28, 2015
Is there a way to permanently change the order of the columns in Job Activity Monitor?
I'd like to move Duration to the right of Step Name, but this only lasts so long as I have JAM open. Once I close it and re-open, JAM goes back to its default column order. Google gives me nothing but the temporary "drag and drop" method that I already know about.
View 2 Replies
View Related
May 1, 2015
I am having issues trying to write a query that would provide me the unique GUID numbers associated with a distinct PID if the unique GUID's > 1. Â To summarize, I need a query that just shows which PID's have more than one unique GUID. A PID could have multiple GUID's that are the same, I'm looking for the PID's that have multiple GUID's that are different/unique.Â
Table1
GUID PID
GUID1 PID1
GUID1 PID1
GUID1 PID1
GUID2 PID1
GUID3 PID2
GUID3 PID2
GUID3 PID2
The result of the query would only have PID1 because it has two unique GUID's. PID2 would not be listed has it has the same GUID3 in each row.
Result:
PID1Â
View 2 Replies
View Related
Feb 27, 2008
Hello,
I need to concatenate a column from multiple rows into a single column in a new table.
How can I do this?
SID NAME PGROUP
------------------------------------------------------------
3467602 CLOTHINGACTIVE
3467602 CLOTHINGDANCE
3467602 CLOTHINGLWR
Need to have
SID NAME PGROUP
------------------------------------------------------------
34676 02 CLOTHING ACTIVE , DANCE, LWR
THANK YOU
View 10 Replies
View Related
Mar 7, 2008
Hi I'm having a bit troubble by creating a SQL-sentence which substract the newest row from the second newest row in the same column. The table looks like this:
Pricecalcid Date Price Itemid
2000 2006-12-12 3000 100
2488 2007-10-11 2800 100
3100 2008-08-07 2500 100
What I need is that the largest "Pricecalcid" that is 3100 equals "Price" 2500 and the second largest "Pricecalcid" eqauls 2800 results in a pricecalculation that substracts 2500 from 2800 for "Itemid" 100.
How do I do that?
Thanks
Morten
View 9 Replies
View Related
Sep 26, 2000
hi
i have a query that returns 1 column 5 rows which i want as 1 row 5 columns
SELECT columna
FROM atable
would become??
thanx
Liju
View 5 Replies
View Related
Jan 11, 2006
How to put two rows of data in one column?
from
dealID dealNO
1 888
1 999
to
dealID dealNO
1 888,999
you can't use create permission, so can't create storedprocedure.
Pls help.
View 4 Replies
View Related
Oct 31, 2007
Hello,can I do this via SQL:example: tbltest has 5 rows:col1===ACFMRWhat I want is this:result:===============A, C, F, M, RDo I really have to go through the rows per SP? I could do this:SELECT UDF(col1)FROM tbltestAin't there a more simple way, maybe theres a T-SQL-command ?thxcandide_sh
View 6 Replies
View Related
Dec 11, 2007
I want to convert the row value as column name
example:-->
value ratio
3 4.166666666661 1.315789473680 00 0
To :->
value ratio ratio1 ratio2 ratio3
3 4.166 1.315 0 0
any ideas?
View 1 Replies
View Related
Jul 26, 2002
Can anyone help me retrieving that result.
take an example
EXEC-ID JOB-CODE
0001 20
0001 63
0001 03
i want result in the following format:
EXEC-ID JOB-CODE1 JOB-CODE2 JOB-CODE3
0001 20 63 03
View 1 Replies
View Related
Dec 29, 2014
Came across one scenario not able to find out how to do it..
Below is the table data
ColA
1
-1
2
-2
Need output in below way
ColA ColB
1 -1
2 -2
View 5 Replies
View Related
Apr 10, 2008
Hi, I need to update column week14 in table PastWeeks with data from Eng_Goal and then result of some calculation from table AverageEngTime in the row Goal and Used respectively. I used the following and was not successful. Please advice. Thank you.
Update Pastweeks
set
week14 = (SELECT Eng_Goal,((Mon_Day + Mon_Night + Tue_Day + Tue_Night + Wed_Day + Wed_Night + Thu_Day + Thu_Night + Fri_Day + Fri_Night + Sat_Day + Sat_Night + Sun_Day + Sun_night)* 100/168) FROM AverageEngTime where Shifts = 'Average')
where Weeks = ('Goal','Used' )
View 8 Replies
View Related
Apr 26, 2008
i have 2 columns like
Col1====col2
username=======saif====mr@hotmai.com
email=======saif@hotmail.com
name======saifullah
I want to get these records from sql like
username email name
saif saif@hotmail.com saifullah
________________________________-
how can I achive this
Muhammad Saifullah
View 3 Replies
View Related
May 20, 2008
i want to split the value of one column into multiple rows. based on comp capacity. pl help me in writing query
Actual table
Product IdProductQtyCompCapacity
1 8000 5000
2 10000 5000
4000
4000
Resultant table
Product IdProductQtyCompCapacity
2 50005000
2 50005000
1 40004000
140004000
View 6 Replies
View Related
Aug 24, 2013
I have a table with following sample data:
**CategoriesIDs RegistrantID**
47 1
276|275|278|274|277 4
276|275|278|274|277 16261
NULL 16262
NULL 16264
NULL 16265
[code]....
I need to know :
1). which category has how many regisrtantids (like 277 has how many registrantids) 2). group the registrants by category so that i can find which registrants are in category 277 for example)
Do I need to create a function which generates a table from csv ? I have created a function but not sure if it will work in this situation with IN clause.
View 2 Replies
View Related
Jul 2, 2014
I am looking to transpose a row into multiple columns. I have a member's data who might be associated with multiple labs for that one member. Instead of having multiple records for that member, I would like to have one record per member with multiple rows for the lab data.
View 16 Replies
View Related
Mar 16, 2006
Hello, This is my first post so please be kind. I have been attempting to convert a query I built in MS Access for use in MSSQL 2000, the syntax for these is different so I was frustrated to find out I could not use the access query.
I have 4 columns one containing a user Id and the others costs, I wish to total the costs per user ID at the end of each row.
So far I have managed to convert about half of my access query, this gives mev the clientID's and costs in columns but I cannot for the life of me get the costs in a total. It's annoying because my access query works perfectly.
This is my Access query:
SELECT DISTINCT Holiday_Bookings.ClientID, Holiday_Bookings.Booking_Cost, Room_Facilities.FacilityCost, Rooms.CostPerNight,
Rooms!CostPerNight*Nights_Stayed+Holiday_Bookings!Booking_Cost+Room_Facilities!FacilityCost AS TotalCost,
[TotalCost]*17.5/100+[TotalCost] AS [Total+VAT]
FROM Room_Facilities INNER JOIN (Hotels INNER JOIN (Holiday_Bookings RIGHT JOIN Rooms ON Holiday_Bookings.ClientID = Rooms.ClientID) ON Hotels.HotelID = Rooms.HotelID) ON Room_Facilities.FacilityID = Rooms.FacilityID;
And this is what I have been able to salvage into MSSQL format:
SELECT
Holiday_Bookings.ClientID,
Holiday_Bookings.Booking_Cost,
Rooms.CostPerNight,
Room_Facilities.FacilityCost
FROM
Rooms
INNER JOIN Room_Facilities ON (Rooms.FacilityID = Room_Facilities.FacilityID)
INNER JOIN Holiday_Bookings ON (Rooms.Clients_ID = Holiday_Bookings.ClientID)
How can I total the three columns and add the tax?
View 3 Replies
View Related
Jun 5, 2006
Mike writes "Hi,
I am a beginner with TSQL and I hope this is not a silly question :-)
Lets say I have a table with 2 columns, 1 a primary key identity field with increment 1 and the other a char.
EG:
ID ANIMAL
---------
1 CAT
2 DOG
3 PIG
4 RAT
5 PIG
6 DOG
7 DOG
.
.
And so on with many entries
How do I return a selection of rows that have the contents of the ANIMAL field matching 1 or more times
EG:
From above table I want to return rows 2,6 & 7 and 3 & 5 ONLY and not 1(CAT) and 4(RAT) because they only occur once.
In my real life situation I have unknown numeric data in field 2 but the principal is the same.
How do I do this?
Thanks in Advance
Mike"
View 2 Replies
View Related
Jul 23, 2005
I am struggling on this issue and was hoping if anyone out there canhelp me.Here is the setup: I have a table with the following data:TableName: TranDetailMerchID ItemName Price------------------101 A 5101 B 3.5101 C 0102 B 7.6102 C 4102 E 65102 G 4103 K 35Table DesignMerchID intItemName varchar(50)Price floatWhat I would like is a report that looks like thisMerchID A B C E G K101 5 3.5 0102 7.6 4 65 4103 35This report can change on every run depending on data in tableTranDetail. The column name in report depends on ItemName in tableTranDetail. As seen in the above report, there is no data for Items D,F, H, I, J and hence they do not show up in the report.What I need: Code for a stored procedure that can get me this data.Thanks for your help...DBA in despair!
View 7 Replies
View Related
Dec 21, 2005
I have a column that has text delimited by a percent sign that I wishto turn into rows.Example:A column contains ROBERT%CAMARDA, I want to turn that into two rows,one row with ROBERT and antoher row with CAMARDA.I will have source rows that have zero, one, or many percent signdelimiters that will correspond to that many rows (One percent signwill create 2 rows, 2 percent signs will create 3 rows and so forth).Any thoughts?TIARob
View 1 Replies
View Related
May 29, 2007
Hi Friends,How to transpose the columns into rowsi want to convert the table which looks like thisID Name HomePhone WorkPhone Email1 test1 678364 643733 Join Bytes!2 test2 678344 643553 Join Bytes!to a table which should look like thisID Name Device1 test1 6783641 test1 6437331 test1 Join Bytes!2 test2 6783442 test2 6435532 test2 Join Bytes!Thanks in AdvanceArunkumar
View 1 Replies
View Related
Dec 20, 2007
Hi
I have an old db I'm converting with SSIS.
In the old db I have an Log-table wich is in this format:
ID,CaseID,Note
each CaseId can have several rows.
Now I want to merge the Note Row into one row based on the CaseID.
So that I get One Row per CaseID with one bignote.
I have been looking into Pivot, but just dont seem to get it working.
Any Ideas?
View 2 Replies
View Related
Mar 4, 2008
Hi,
I have issue about how to pivot and merge some rows into one column.
I have the table name : tableA with columns and records as below shown:
Cola Colb
------ ------
A A1
A A2
A A3
B B1
B B2
The request is to display the query like this :
Cola Colb
------- -----------------------------
A A1A2A3
B B1B2
I get stuck with my query below :
select Cola, ???
from tableA
group by Cola
Do you have idea how to achive this with TSQL?
Thanks.
Kasim
View 1 Replies
View Related