Showing posts with label quotmicrosoft. Show all posts
Showing posts with label quotmicrosoft. Show all posts

Tuesday, March 20, 2012

"WHERE" condition in MSSQL2005 diff. with Oracle DB

Hi,

I got one question about MSSQL2005.

I am using "Microsoft SQL Server Migration Assistant for Oracle" to migrate Oracle Database to Microsoft SQL server 20005.

[Oracle DB]

In Oracle DB, there are two records in table

CREDITOR_ID CREDIT_ID CREDIT_LIMIT CREDIT_BALANCE CREDIT_ONHAND ACCTSTATUSID CREDITTERMSID EDIT_TIME Record 1 YT4996 XX 1 0 0 A 15 1/1/1999 14:10 Record 2 YT4996 XX 2 0 0 B 30 1/1/1998 17:21

In record 1, CREDITOR_ID='YT4996 ', there is a space after string 'YT4996'.

In record 2, CREDITOR_ID='YT4996', there is no space after string 'YT4996'.

SQL(1)

select xxx from CUSTOMER_ID='YT4996'

--> output 1 rows.

SQL(2)

select xxx from CUSTOMER_ID='YT4996 '

--> output 1 rows.

[MSSQL2005]

After migrate data to MSSQL, there are two identical records as Oracle DB.

CREDITOR_ID CREDIT_ID CREDIT_LIMIT CREDIT_BALANCE CREDIT_ONHAND ACCTSTATUSID CREDITTERMSID EDIT_TIME Record 1 YT4996 XX 1 0 0 A 15 1/1/1999 14:10 Record 2 YT4996 XX 2 0 0 B 30 1/1/1998 17:21

In record 1, CREDITOR_ID='YT4996 ', there is a space after string 'YT4996'.

In record 2, CREDITOR_ID='YT4996', there is no space after string 'YT4996'.

SQL(1)

select xxx from CUSTOMER_ID='YT4996'

--> output 2 rows.

SQL(2)

select xxx from CUSTOMER_ID='YT4996 '

--> output 2 rows.

Question:

==> In Oracle DB, 'YT4996 ' <> 'YT4996'

==> In MSSQL2005, 'YT4996 ' = 'YT4996'

Do any setting, affect MSSQL2005, make 'YT4996 ' = 'YT4996' ?

I want MSSQL2005 behaviour as Oracle....

Anyone have hint?

You must have defined the datatype for the column as varchar. This will force sqlserver to strip the trailing blank spaces. If you change the datatype to char, the trailing spaces will be preserved.|||

Thanks for info.

The column is defined as varchar(12).

but I cannot use char(12), since this column will contain variable width data, e.g. 'WT123', 'WT123456'.

If using char(12), all records in this column will become

'WT123 '

'WT123456 '

which will waste space when using char(12).

|||

"Set Ansi_Padding ON" (non-default) before creating the column will force the trailing blanks not to be truncated. This setting needs to be set also during your execution if you decide to create varchar variables and preserve the trailing blanks.

Here is a good example (from bol):

Code Snippet

SET ANSI_PADDING ON
GO
PRINT 'Testing with ANSI_PADDING ON'
GO

CREATE TABLE t1
(charcol char(16) NULL,
varcharcol varchar(16) NULL,
varbinarycol varbinary(8))
GO
INSERT INTO t1 VALUES ('No blanks', 'No blanks', 0x00ee)
INSERT INTO t1 VALUES ('Trailing blank ', 'Trailing blank ', 0x00ee00)

SELECT 'CHAR'='>' + charcol + '<', 'VARCHAR'='>' + varcharcol + '<',
varbinarycol
FROM t1
GO

SET ANSI_PADDING OFF
GO
PRINT 'Testing with ANSI_PADDING OFF'
GO

CREATE TABLE t2
(charcol char(16) NULL,
varcharcol varchar(16) NULL,
varbinarycol varbinary(8))
GO
INSERT INTO t2 VALUES ('No blanks', 'No blanks', 0x00ee)
INSERT INTO t2 VALUES ('Trailing blank ', 'Trailing blank ', 0x00ee00)

SELECT 'CHAR'='>' + charcol + '<', 'VARCHAR'='>' + varcharcol + '<',
varbinarycol
FROM t2
GO

DROP TABLE t1
DROP TABLE t2
GO

|||

Thanks for your info.

I had test your script, it work.

<<<BUT>>>.......

I find this "SET ANSI_NULLS ON" is not work if the COULMN defined as NOT NULL.

Here is my original script for table [CUSTOMER_CREDIT]

===============================================

USE DBSYSTEM
GO
SET ANSI_PADDING ON
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [MAIN].[CUSTOMER_CREDIT]
(
[CREDITOR_ID] varchar(10) NOT NULL,
[CREDIT_ID] varchar(6) NOT NULL,
[CREDIT_LIMIT] numeric(12, 2) NULL,
[CREDIT_BALANCE] numeric(12, 2) NULL,
[CREDIT_ONHAND] numeric(12, 2) NULL,
[ACCTSTATUSID] varchar(3) NULL,
[CREDITTERMSID] varchar(3) NULL,
[EDIT_TIME] datetime NULL
)
GO
ALTER TABLE [MAIN].[CUSTOMER_CREDIT]
ADD CONSTRAINT [PK_CUSTOMER_CREDIT]
PRIMARY KEY
CLUSTERED ([CREDITOR_ID] ASC, [CREDIT_ID] ASC)

GO

If I had create the table like this:

CREATE TABLE [MAIN].[CUSTOMER_CREDIT]
(
[CREDITOR_ID] varchar(10) NULL,
[CREDIT_ID] varchar(6) NOT NULL,
.....

If the COULMN [CREDITOR_ID] defined as NULL, "SET ANSI_PADDING ON" is work, such that I have two records:

[CREDITOR_ID] = 'ABCD ' , ie space after string "ABCD".

[CREDITOR_ID] = 'ABCD' , ie no space after string "ABCD".

But if the COULMN [CREDITOR_ID] defined as "NOT NULL", "SET ANSI_PADDING ON" is NOT work.

Any ideal?

|||

Here is the script to create table and testing:

USE DBSYSTEM
GO
SET ANSI_PADDING ON
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[MAIN].[CUSTOMER_CREDIT]') AND type in (N'U'))
BEGIN

DECLARE @.drop_statement varchar(500)

DECLARE drop_cursor CURSOR FOR
SELECT 'alter table '+quotename(schema_name(ob.schema_id))+
'.'+quotename(object_name(ob.object_id))+ ' drop constraint ' + quotename(fk.name)
FROM sys.objects ob INNER JOIN sys.foreign_keys fk ON fk.parent_object_id = ob.object_id
WHERE fk.referenced_object_id = OBJECT_ID(N'[MAIN].[CUSTOMER_CREDIT]')

OPEN drop_cursor

FETCH NEXT FROM drop_cursor
INTO @.drop_statement

WHILE @.@.FETCH_STATUS = 0
BEGIN
EXEC (@.drop_statement)

FETCH NEXT FROM drop_cursor
INTO @.drop_statement
END

CLOSE drop_cursor
DEALLOCATE drop_cursor

DROP TABLE [MAIN].[CUSTOMER_CREDIT]
END
GO

USE DBSYSTEM
GO
SET ANSI_PADDING ON
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE
[MAIN].[CUSTOMER_CREDIT]
(
[CREDITOR_ID] varchar(10) NOT NULL,
[CREDIT_ID] varchar(6) NOT NULL,
[CREDIT_LIMIT] numeric(12, 2) NULL,
[CREDIT_BALANCE] numeric(12, 2) NULL,
[CREDIT_ONHAND] numeric(12, 2) NULL,
[ACCTSTATUSID] varchar(3) NULL,
[CREDITTERMSID] varchar(3) NULL,
[EDIT_TIME] datetime NULL
)
GO
ALTER TABLE [MAIN].[CUSTOMER_CREDIT]
ADD CONSTRAINT [PK_CUSTOMER_CREDIT]
PRIMARY KEY
CLUSTERED ([CREDITOR_ID] ASC, [CREDIT_ID] ASC)

GO
===============================================================

SET ANSI_PADDING ON

GO

INSERT INTO [MAIN].[CUSTOMER_CREDIT] VALUES ('YT4996', 'XX','2400','0','0','C','30',CURRENT_TIMESTAMP)

GO

SET ANSI_PADDING ON

GO

INSERT INTO [MAIN].[CUSTOMER_CREDIT] VALUES ('YT4996 ','XX','0' ,'0','0','S','15',CURRENT_TIMESTAMP)

GO

SELECT 'VARCHAR'='>' + CREDITOR_ID + '<' FROM [MAIN].[CUSTOMER_CREDIT]
GO


Thursday, March 8, 2012

"Microsoft SQL Server 2005 Datamining Viewer Controls" feature pack

Hi,

I downloaeded "Microsoft SQL Server 2005 Datamining Viewer Controls" feature pack, and tried to run the dataminingviewerclient.exe.

When i view my local time series data mining model, It works well for single series model, but when i load a Microsoft time series model containing multiple data series, an unhandled exception occurs.

I post the error message below:

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.AnalysisServices.Viewers.TimeSeriesViewer.PreprocessChartArrays(ArrayList rgPredicted, ArrayList rgActual, ArrayList rgDeviations)
at Microsoft.AnalysisServices.Viewers.TimeSeriesViewer.LoadChartSpace(MiningModel model)
at Microsoft.AnalysisServices.Viewers.TSCheckedListViewCombo.HandleChangesCommitted(Object sender, EventArgs ea)
at Microsoft.DataWarehouse.Controls.BaseControlComboBox.OnCommittedChanges(EventArgs e)
at Microsoft.DataWarehouse.Controls.BaseControlComboBox.SetSelection(String str, Object obj)
at Microsoft.AnalysisServices.Viewers.TimeSeriesViewer.InitializeCurrentlySelectedPage(Object context)
at Microsoft.AnalysisServices.Viewers.TreeViewer.viewerTabControl_SelectedIndexChanged(Object sender, EventArgs e)
at System.Windows.Forms.TabControl.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.TabControl.WmSelChange()
at System.Windows.Forms.TabControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///E:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
-
DataMiningViewerClient
Assembly Version: 1.0.2023.16746
Win32 Version: 1.0.2023.16746
CodeBase: file:///E:/Documents%20and%20Settings/admin/Desktop/Microsoft%20Download/DataMiningViewerClient/DataMiningViewerClient.exe
-
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
-
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
-
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
-
Microsoft.AnalysisServices.AdomdClient
Assembly Version: 9.0.242.0
Win32 Version: 9.00.2047.00
CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/Microsoft.AnalysisServices.AdomdClient/9.0.242.0__89845dcd8080cc91/Microsoft.AnalysisServices.AdomdClient.dll
-
System.Data
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///E:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
-
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
-
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
-
Microsoft.AnalysisServices.Viewers
Assembly Version: 9.0.242.0
Win32 Version: 9.00.1186.00
CodeBase: file:///E:/Documents%20and%20Settings/admin/Desktop/Microsoft%20Download/DataMiningViewerClient/Microsoft.AnalysisServices.Viewers.DLL
-
Microsoft.DataWarehouse
Assembly Version: 9.0.242.0
Win32 Version: 9.00.1186.00
CodeBase: file:///E:/Documents%20and%20Settings/admin/Desktop/Microsoft%20Download/DataMiningViewerClient/Microsoft.DataWarehouse.DLL
-
Microsoft.DataWarehouse.Interfaces
Assembly Version: 9.0.242.0
Win32 Version: 9.00.2047.00
CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/Microsoft.DataWarehouse.Interfaces/9.0.242.0__89845dcd8080cc91/Microsoft.DataWarehouse.Interfaces.dll
-
Microsoft.AnalysisServices.Controls
Assembly Version: 9.0.242.0
Win32 Version: 9.00.1186.00
CodeBase: file:///E:/Documents%20and%20Settings/admin/Desktop/Microsoft%20Download/DataMiningViewerClient/Microsoft.AnalysisServices.Controls.DLL
-
Microsoft.Office.Interop.Owc11
Assembly Version: 11.0.0.0
Win32 Version: 11.0.5530
CodeBase: file:///E:/WINDOWS/assembly/GAC/Microsoft.Office.Interop.Owc11/11.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Owc11.dll
-
Microsoft.AnalysisServices.Graphing
Assembly Version: 9.0.242.0
Win32 Version: 9.00.1186.00
CodeBase: file:///E:/Documents%20and%20Settings/admin/Desktop/Microsoft%20Download/DataMiningViewerClient/Microsoft.AnalysisServices.Graphing.DLL
-
MSDATASRC
Assembly Version: 7.0.3300.0
Win32 Version: 7.00.9466
CodeBase: file:///E:/WINDOWS/assembly/GAC/MSDATASRC/7.0.3300.0__b03f5f7f11d50a3a/MSDATASRC.dll
-
mscomctl
Assembly Version: 10.0.4504.0
Win32 Version: 10.0.4504
CodeBase: file:///E:/WINDOWS/assembly/GAC/mscomctl/10.0.4504.0__31bf3856ad364e35/mscomctl.dll
-
Accessibility
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
-
Microsoft.AnalysisServices.OleDbDM
Assembly Version: 9.0.242.0
Win32 Version: 9.00.1186.00
CodeBase: file:///E:/Documents%20and%20Settings/admin/Desktop/Microsoft%20Download/DataMiningViewerClient/Microsoft.AnalysisServices.OleDbDM.DLL
-
Microsoft.SqlServer.CustomControls
Assembly Version: 9.0.242.0
Win32 Version: 9.00.2047.00
CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/Microsoft.SqlServer.CustomControls/9.0.242.0__89845dcd8080cc91/Microsoft.SqlServer.CustomControls.dll
-
Microsoft.NetEnterpriseServers.ExceptionMessageBox
Assembly Version: 9.0.242.0
Win32 Version: 9.00.1399.00
CodeBase: file:///E:/WINDOWS/assembly/GAC_MSIL/Microsoft.NetEnterpriseServers.ExceptionMessageBox/9.0.242.0__89845dcd8080cc91/Microsoft.NetEnterpriseServers.ExceptionMessageBox.dll
-
System.Transactions
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///E:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
-

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

***** end of error message***

Can someone help to figure out what went wrong? thx.

Do you have OWC (Office Web Components) installed on the machine? The Time Series viewer uses OWC to draw the series graphs|||

Hi,

I downloaded & installed the "Microsoft SQL Server 2005 Datamining Viewer Controls" feature pack, and AS 9.0 OLEDB provider. I have a TimeSeries mining model already built, which I want to display using the Time Series Viewer. I have added these controls to the toolbox, and added the Timeseries viewer to the form. I m stuck on how to make the program display the mining model, as there are several properties for the control.

I have set the connectionstring to "Provider=MSOLAP;Initial catalog=DM;Data Source=localhost;" and the MIningModelName property to the model name. I have not added any other code.

At run time, nothing is displayed in the control & when i click on the charts tab, i get NullReferenceException on the last line in the code below:

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new Form1());

|||

I have put below the Stack Trace for the run time error.

at Microsoft.AnalysisServices.Viewers.TimeSeriesViewer.InitializeCurveNames()
at Microsoft.AnalysisServices.Viewers.TimeSeriesViewer.InitializeSelector()
at Microsoft.AnalysisServices.Viewers.TimeSeriesViewer.InitializeCurrentlySelectedPage(Object context)
at Microsoft.AnalysisServices.Viewers.TreeViewerBase.viewerTabControl_SelectedIndexChanged(Object sender, EventArgs e)
at System.Windows.Forms.TabControl.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.TabControl.WmSelChange()
at System.Windows.Forms.TabControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
at System.Windows.Forms.Control.WmNotify(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.UserControl.WndProc(Message& m)
at Microsoft.DataWarehouse.Controls.ContextMenuAwareUserControl.WndProc(Message& msg)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.TabControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WinDMViewers.Program.Main() in d:\Devi\WinDMViewers\WinDMViewers\Program.cs:line 19
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

|||Have to ask again, do you have OWC 11 installed? The Time Series viewer uses OWC 11, so unless you have that available, it will not work.|||

Hey, thanks for the reply.

I found a sample in www.sqlserverdatamining.com, and it worked in a win form. But have another question, cant these controls be used in a web page? They appear disabled in the toolbox, when i try to add them to a web form.

|||These are winform only controls.