This is my Technical area of troubleshooting and learning new Programming skills and many more. Here you will find answers for many new technologies like asp.net 2.0/3.5,4.0 C# access, mysql, Amazon Webservice ,Sql-server, JD Edwards, SAS, Salesforce, APIs, MVC and many more. please visit & discuss.
Wednesday, September 29, 2010
drop table if exists sql-server 2008/2005
In this sample I am dropping a temp table #temp4 :-
IF OBJECT_ID('tempdb..#temp4', 'U') IS NOT NULL
DROP TABLE #temp4
SQL-Server PIVOT/Transpose with dynamic column, convert row into column
If you have data like following and want to transpose row into column using sql-server 2008 PIVOT,
focomp | FOBUFMED1QT | FOBUFMED2QT |
310 | 2 | 4 |
520 | 5 | 3 |
520 | 5 | 8 |
850 | 3 | 6 |
310 | 3 | 4 |
310 | 3 | 8 |
580 | 3 | 6 |
Transpose means you want Data like following in multiple column sum :
Like following:-
310 | 520 | 580 | 850 |
8 | 10 | 3 | 3 |
16 | 11 | 6 | 6 |
In this example my table name is BOFASY
Use following sql query to achive this:-
DECLARE @listCol VARCHAR(2000)
DECLARE @query VARCHAR(4000)
DECLARE @query1 VARCHAR(4000)
DECLARE @query2 VARCHAR(4000)
SELECT @listCol = STUFF(( SELECT DISTINCT
'],[' + ltrim(focomp)
FROM BOFASY
ORDER BY '],[' + ltrim(focomp)
FOR XML PATH('')
), 1, 2, '') + ']'
SET @query =
'SELECT * FROM
(SELECT focomp,cast(FOBUFMED1QT as int) FOBUFMED1QT FROM BOFASY) src
PIVOT (SUM(FOBUFMED1QT) FOR focomp
IN ('+@listCol+')) AS pvt'
SET @query1 =
'SELECT * FROM
(SELECT focomp,cast(FOBUFMED2QT as int) FOBUFMED2QT FROM BOFASY) src
PIVOT (SUM(FOBUFMED2QT) FOR focomp
IN ('+@listCol+')) AS pvt'
set @query2=@query +' union '+ @query1
EXECUTE (@query2)
Sql-server 2008/2005 Pivot Multiple Column Sum
drop table temp5
SELECT 'media1' Type1,
[310],
[520-530],
[850] into temp5
FROM ( SELECT [focomp],
cast(FOBUFMED1QT as int) FOBUFMED1QT
FROM BOFASY
) p PIVOT
( SUM(FOBUFMED1QT)
FOR [focomp] IN ([310], [520-530],[850] )
) AS pvt
insert into temp5
SELECT 'media2' Type1,
[310],
[520-530],
[850]
FROM ( SELECT [focomp],
cast(FOBUFMED2QT as int) FOBUFMED2QT
FROM BOFASY
) p PIVOT
( SUM(FOBUFMED2QT)
FOR [focomp] IN ([310], [520-530],[850] )
) AS pvt
select * from temp5
PIVOT CAST / sum varchar is not working Sql-server
PIVOT CAST / sum varchar is not working Sql-server 2008/2005 , you have to change in select from table like following:-
[520-530]
,[850]
FROM
( SELECT [focomp], cast(FOBUFMED1QT as int) FOBUFMED1QT FROM BOFASY ) p PIVOT ( SUM(FOBUFMED1QT) FOR [focomp] IN ([310], [520-530],[850] ) ) AS pvtTuesday, September 28, 2010
Saving changes is not permitted Error in SQL Server 2008 Express
Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.
Tools -> Options -> Designers->Table and Database Designers-> and uncheck the option "Prevent saving changes that require table re-creation.
Add member failed for DatabaseRole 'db_securityadmin' sql-server 2008
------------------------------
Add member failed for DatabaseRole 'db_securityadmin'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600.1+((KJ_RTM).100402-1539+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Add+member+DatabaseRole&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Cannot use the special principal 'dbo'. (Microsoft SQL Server, Error: 15405)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1600&EvtSrc=MSSQLServer&EvtID=15405&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
Monday, September 27, 2010
BlackBerry's PlayBook tablet
Research in Motion unveiled the PlayBook
The PlayBook tablet features:
7-inch screen
Flash-capable video
front and rear high-definition camera
9.7 millimeters Thick
operating system: new platform from QNX Software Systems
source:cnnmoney
The recipient server did not accept our requests...
- The other domain doesn't have up-to-date MX records or is otherwise misconfigured.
- The other domain is blacklisting or graylisting messages from Gmail.
- The other domain is experiencing temporary networking problems.
We recommend contacting the customer service department of the recipient's domain for further instructions. If you receive this bounce message when sending to your Google Apps domain, please see our instructions for configuring your MX records.
htp://mail.google.com/support/bin/answer.py?answer=7720
Unable to start the Transact-SQL debugger.
Unable to start the Transact-SQL debugger. The Transact-SQL debugger does not support SQL Server 2005 or earlier versions of SQL Server. (SQLEditors)
------------------------------
Program Location:
at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ScriptAndResultsEditorControl.DebugWrapper.Start()
at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ScriptAndResultsEditorControl.OnDebugScript(Object sender, EventArgs a)
Thursday, September 23, 2010
Data-driven document generation with Word 2007 and the Office XML File Formats: Part 1
http://blogs.msdn.com/b/erikaehrli/archive/2006/08/11/word2007datadocumentgenerationpart1.aspx
Monday, September 20, 2010
Why ASMX web services are not an excuse anymore with WCF 4.0
Account detail & balance problem in JD Edwards EnterpriseOne/xe
Solution:- you have to go database lavel to fix this problem, I mean you have to use SQL-Servre and update that particlure period.
ps: this happens only when if you have only 1 transaction for that year for that account & subledger.
Friday, September 17, 2010
Add OpenID Login Support In Your ASP.NET Application
Thursday, September 16, 2010
MVC 2 Model Metadata to Render Dynamic UI
Wednesday, September 15, 2010
Monday, September 13, 2010
Thursday, September 9, 2010
Access link table column default as number, how to change
I have a column of data with mixture of text and number, in link table its comming as number, how to convert all in text.
Solution:http://office.microsoft.com/en-us/excel-help/three-ways-to-convert-numbers-to-text-HA001136619.aspx
Tuesday, September 7, 2010
Introduction to Android development : TouchCalculator - CodeProject
SQL-Sever The query processor ran out of stack space during query optimization.
Server: Msg 8621, Level 17, State 93, Procedure pSaleovINN, Line 14
Internal Query Processor Error: The query processor ran out of stack space during query optimization.
Friday, September 3, 2010
S#arp Architecture 1.6 Released! - Billy McCafferty - Devlicio.us - Just the Tasty Bits
http://devlicio.us/blogs/billy_mccafferty/archive/2010/08/19/s-arp-architecture-1-6-released.aspx