Wednesday, December 9, 2015

Blank "initial catalog" problem on OLEDB connection string of SQL Server Database

see also -- Got Error: Invalid object name 'master.dbo.spt_values'

As usually we use below connection string to connect to SQL Server using OLEDB provider.

Data Source=DBSERVER;Initial Catalog=DB_NAME;Provider=SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;

What if “Initial Catalog” is blank like below one?

Data Source=DBSERVER;Initial Catalog=;Provider=SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;

We know when we create a login user; we have to mansion a database as default to connect. Due to this, OLEDB provider connects to this default database in case of missing Initial Catalog. So that we have to more careful to run DDL using OLEDB.

To bypass this default fault/mistake, we can create a dummy blank database and point all users to this blank database as default database.

Tuesday, December 8, 2015

Got Error: Invalid object name 'master.dbo.spt_values'

see also -- Blank "initial catalog" problem on OLEDB connection string of SQL Server Database

When you tried to view properties of a database in SQL Server, you got the error " Invalid object name 'master.dbo.spt_values' ". it is very common error, raised when one or more views are unavailable/deleted somehow from master database. Don't be panic for that. It's very simple to recover. Just run the below mentioned script to resolved it.

goto the location "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Install".
where "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER" is your SQL Server installation folder.

then run the script u_tables.sql file. it's done. now this error will be gone away.

Monday, May 25, 2015

SQL/ tSql to UnPivot Pivoted Data on SQL Setver

You have to use SQL Server relational operator UNPIVOT/CROSS APPLY to UnPivot data from Pivoted data.

·        For single measure its simple to write unpivot query (tSql).
·        But for multiple measures, unpivot operator should have to be used for multiple times and a where clause required to relate each unpivor operator depends on your chosen common dimension.
Example:

v Single measure:

Ø  Sample Data - Table Name ([dbo].[TEST_PIVOT])
CITY
People – 2001
People – 2002
Dhaka
45623
524854
Dilly
456987
5478965
Ø  Sample Output
§  Here, CITY is your provided dimension and People & 2001/2002 is your unpivotable measure & dimension (period).
CITY
Period
People
Dhaka
2001
45623
Dhaka
2002
524854
Dilly
2001
456987
Dilly
2002
5478965
Ø  tSQL-
select CITY, Period, People
from ( select CITY, [People – 2001] as [2001], [People – 2002] as [2002] from [dbo].[TEST_PIVOT] ) Data
UNPIVOT (
People for Period IN ([2001], [ 2001])
) upvt

v Multi Measures:

Ø  Sample Data
CITY
People – 2001
People – 2002
Home – 2001
Home - 2002
Dhaka
45623
524854
4000
50000
Dilly
456987
5478965
40000
5000000
Ø  Sample Output
§  Here, CITY is your provided dimension and People & 2001/2002 is your unpivotable measure & dimension (period).
CITY
Period
People
Home
Dhaka
2001
45623
4000
Dhaka
2002
524854
50000
Dilly
2001
456987
40000
Dilly
2002
5478965
5000000
Ø  tSQL -

§  using UNPIVOT operator-

select CITY, PeriodPeople as Period, People, Home
from ( select CITY, [People – 2001], [People – 2002], [Home – 2001], [Home – 2002] from [dbo].[TEST_PIVOT] ) Data
UNPIVOT (
People for PeriodPeople IN ([People – 2001], [People – 2002])
) upvtP
UNPIVOT (
Home for PeriodHome IN ([Home – 2001], [Home – 2002] )
) upvtH
               WHERE RIGHT(upvtP.PeriodPeople,4) = RIGHT (upvtH.PeriodHome,4)


§  using CROSS APPLY operator - 

     SELECT [CITY]
, [PERIOD]
, [People]
, [Home]
FROM [dbo].[TEST_PIVOT]
CROSS APPLY (
VALUES (
[People-2001]
, [Home-2001]
, right([People-2001], 4)
)
, (
[People-2002]
, [Home-2002]
, right([People-2002], 4)
)
) a([People], [Home], [PERIOD])

Sunday, April 26, 2015

Google 2nd step verification to deploy ODK Aggregate

see also -- Java security to deploy ODK Aggregate at Google App Engine
             -- Revoke/Remove App-Specific Password from Google Account


If you use 2ne step authentication for you Google account, then you have to use an App specific password to deploy ODK Aggregate.

Login to Google account. Go to “Account settings” à

Click on the “2-nd Step Verification”. Enter your password again to verify account.

Click on the “App Specific Password” tab. Then click “Manage Application-specific Passwords” [bottom of this tab].


Select “Other(Custom Name)” from “Select App” drop down list. Type “ODK Aggregate”. Then click on “GENERATE”.


You will see a password, write it down to use at the time of ODK Aggregate deployment. [don’t enter blank spaces].

Java security to deploy ODK Aggregate at Google App Engine

see also -- Google 2nd step verification to deploy ODK Aggregate
             -- Revoke/Remove App-Specific Password from Google Account


You have to configure Java security to deploy ODK Aggregate at Google App Engine. Let’s see step by step java security configuration.

Assume that Java 7 or higher JDK installed on your PC (ODK Requirement)

Go to Java Control Panel à go to windows control panel. Find in the program section or direct “Java”

                 


A dialog window will be appeared name “Java Control Panel”. Click on the Security tab.



Check “Enable Java Content in the browser”

Select Security “High” option.

Click on the button “Edit Site List”.


A new dialog window will appear named “Exception Site List”. Click on the button “Add”. An entry field will appear in the “Location” list. Enter your Google Appspot.com site. Which one you want to use deploy ODK Aggregate. See my example “http://mtechnologiesbd.appspot.com/Aggregate.html”.

Click “OK”. Click “Apply” then “Ok”.

Hope it will work to deploy ODK Aggregate.