Sqlite query want to convert in MS Sql server 2008

Hi 
Please let me know how to write MS SQL server query for the below:
Sqlite query :
SELECT strftime('%s',event_time_gmt,'unixepoch','330 minutes') as time;
Regards,
Vijjivinayaka

Declare @dt0 datetime, @dt datetime, @LocalTimeOffset int=5.5*60*60, @epochdt bigint=1389595157, @AdjustedLocaldt bigint;
SET @AdjustedLocaldt = @epochdt + @LocalTimeOffset
SELECT @dt0=DATEADD(second,@epochdt, CAST('1970-01-01 00:00:00' AS datetime))
,@dt=DATEADD(second,@AdjustedLocaldt, CAST('1970-01-01 00:00:00' AS datetime))
; with mycte as (SELECT @epochdt as epochdt, @dt0 as gmtdt , @dt as localdt
, DATEADD(minute, DATEDIFF(minute,0,@dt),0) as StartOftheMinute
,DATEADD(hour, DATEDIFF(hour,0,@dt),0) as StartOftheHour
, DATEADD(day, DATEDIFF(day,0,@dt),0) as StartOftheday
, DATEADD(mm, DATEDIFF(mm,0,@dt),0) as StartOfThisMonth
, DATEADD(year, DATEDIFF(year,0,@dt),0) as StartOftheYear
, DATEADD(wk, DATEDIFF(wk,0,@dt),0) as StartOftheWeek)
select epochdt,
Left(datename(weekday,localdt),3) +' '+ CONVERT(varchar(26),localdt,109) as localdt
,Left(datename(weekday,gmtdt),3) +' '+ CONVERT(varchar(26),gmtdt,109) as gmtdt
,Left(datename(weekday,StartOftheMinute),3) +' '+ CONVERT(varchar(26),StartOftheMinute,109) as StartOftheMinute
,Left(datename(weekday,StartOftheHour),3) +' '+ CONVERT(varchar(26),StartOftheHour,109) as StartOftheHour
,Left(datename(weekday,StartOftheday),3) +' '+ CONVERT(varchar(26),StartOftheday,109) as StartOftheday
,Left(datename(weekday,StartOfThisMonth),3) +' '+ CONVERT(varchar(26),StartOfThisMonth,109) as StartOfThisMonth
,Left(datename(weekday,StartOftheYear),3) +' '+ CONVERT(varchar(26),StartOftheYear,109) as StartOftheYear
,Left(datename(weekday,StartOftheWeek),3) +' '+ CONVERT(varchar(26),StartOftheWeek,109) as StartOftheWeek
from mycte
--http://msdn.microsoft.com/en-us/library/ms187928.aspx

Similar Messages

  • Unhandeled exception occurred while clicking on new query button in Manaement studio in SQL server 2008 R2 SP2.

    I am getting below exception while clicking on new query button in SSMS of SQL server 2008 R2 SP2. 
    I am thinking to reinstall Complete Management Tools. is it worth to give a try on production server?  What can be the fix?
    Exception Details-
    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.SqlServer.Management.UI.VSIntegration.ShellCodeWindowControl.CreateCWWindow()
       at Microsoft.SqlServer.Management.UI.VSIntegration.ShellCodeWindowControl.OnHandleCreated(EventArgs a)
       at System.Windows.Forms.Control.WmCreate(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at Microsoft.SqlServer.Management.UI.VSIntegration.ShellTextEditorControl.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.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    AppIDPackage
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/AppIDPackage.DLL
    System
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    Microsoft.SqlServer.SqlTools.VSIntegration
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.SqlTools.VSIntegration.DLL
    Microsoft.VisualStudio.Shell.Interop
        Assembly Version: 7.1.40304.0
        Win32 Version: 7.10.6071
        CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.VisualStudio.Shell.Interop/7.1.40304.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Shell.Interop.dll
    Microsoft.VisualStudio.OLE.Interop
        Assembly Version: 7.1.40304.0
        Win32 Version: 7.10.6070
        CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.VisualStudio.OLE.Interop/7.1.40304.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.OLE.Interop.dll
    System.Windows.Forms
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    System.Drawing
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    SqlWorkbench.Interfaces
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1540 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/SqlWorkbench.Interfaces.DLL
    Microsoft.SqlServer.SqlTDiagM
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.SqlTDiagM/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.SqlTDiagM.dll
    Microsoft.SqlServer.Instapi
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1540 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Instapi/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Instapi.dll
    EnvDTE
        Assembly Version: 8.0.0.0
        Win32 Version: 8.0.50727.1826 (QFE.050727-1800)
        CodeBase: file:///C:/Windows/assembly/GAC/EnvDTE/8.0.0.0__b03f5f7f11d50a3a/EnvDTE.dll
    Microsoft.VisualStudio.Shell
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.1826 (QFE.050727-1800)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Shell/2.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Shell.dll
    Microsoft.VisualStudio.Shell.Interop.8.0
        Assembly Version: 8.0.0.0
        Win32 Version: 8.0.50727.1826 (QFE.050727-1800)
        CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.VisualStudio.Shell.Interop.8.0/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Shell.Interop.8.0.dll
    Microsoft.SqlServer.Management.SDK.SqlStudio
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1540 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.Management.SDK.SqlStudio.DLL
    Microsoft.DataWarehouse.SQM
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.DataWarehouse.SQM.DLL
    Microsoft.SqlServer.Management.SqlStudio.Explorer
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.Management.SqlStudio.Explorer.DLL
    Microsoft.SqlServer.Management.Controls
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1540 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.Management.Controls.DLL
    System.Configuration
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
    System.Xml
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
    ObjectExplorer
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/ObjectExplorer.DLL
    System.Design
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Design/2.0.0.0__b03f5f7f11d50a3a/System.Design.dll
    Microsoft.SqlServer.Management.UserSettings
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.Management.UserSettings.DLL
    SqlMgmt
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/SqlMgmt.DLL
    Microsoft.SqlServer.Management.Sdk.Sfc
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Management.Sdk.Sfc/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Management.Sdk.Sfc.dll
    ConnectionDlg
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/ConnectionDlg.DLL
    Microsoft.VisualStudio
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.1826 built by: QFE
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio/2.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.dll
    System.Drawing.Design
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing.Design/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.Design.dll
    Microsoft.VisualStudio.Designer.Interfaces
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.VisualStudio.Designer.Interfaces/1.0.5000.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Designer.Interfaces.dll
    Microsoft.SqlServer.RegSvrEnum
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.RegSvrEnum/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.RegSvrEnum.dll
    Microsoft.SqlServer.Management.Reports
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.Management.Reports.DLL
    Microsoft.SqlServer.Management.SqlStudio.Migration
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1540 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.Management.SqlStudio.Migration.DLL
    Microsoft.SqlServer.Smo
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Smo/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Smo.dll
    Microsoft.NetEnterpriseServers.ExceptionMessageBox
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.NetEnterpriseServers.ExceptionMessageBox/10.0.0.0__89845dcd8080cc91/Microsoft.NetEnterpriseServers.ExceptionMessageBox.dll
    System.Data
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
    Microsoft.SqlServer.Management.SqlStudio
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1540 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.Management.SqlStudio.DLL
    Accessibility
        Assembly Version: 2.0.0.0
       Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
    Microsoft.SqlServer.ConnectionInfo
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.ConnectionInfo/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.ConnectionInfo.dll
    Microsoft.SqlServer.Management.RegisteredServers
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Management.RegisteredServers/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Management.RegisteredServers.dll
    Microsoft.SqlServer.SqlClrProvider
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.SqlClrProvider/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.SqlClrProvider.dll
    8h2zzgtz
        Assembly Version: 10.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    Microsoft.SqlServer.SString
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.SString/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.SString.dll
    0seaoek4
        Assembly Version: 10.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    Microsoft.SqlServer.Diagnostics.STrace
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Diagnostics.STrace/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Diagnostics.STrace.dll
    System.Transactions
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
        CodeBase: file:///C:/Windows/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
    System.EnterpriseServices
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
    Microsoft.SqlServer.SqlEnum
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.SqlEnum/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.SqlEnum.dll
    Microsoft.SqlServer.BatchParserClient
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.BatchParserClient/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.BatchParserClient.dll
    Microsoft.SqlServer.BatchParser
        Assembly Version: 10.0.0.0
        Win32 Version: 2009.0100.1600.01 ((KJ_RTM).100402-1540 )
        CodeBase: file:///C:/Windows/assembly/GAC_32/Microsoft.SqlServer.BatchParser/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.BatchParser.dll
    msvcm80
        Assembly Version: 8.0.50727.4940
        Win32 Version: 8.00.50727.4940
        CodeBase: file:///C:/Windows/WinSxS/x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4940_none_d08cc06a442b34fc/msvcm80.dll
    Microsoft.SqlServer.Dmf
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Dmf/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Dmf.dll
    Microsoft.SqlServer.PolicyEnum
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.PolicyEnum/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.PolicyEnum.dll
    ObjectExplorerReplication
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1540 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/ObjectExplorerReplication.DLL
    Microsoft.SqlServer.Sqm
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1540 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/Microsoft.SqlServer.Sqm.DLL
    ihzu3zbs
        Assembly Version: 10.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    System.Management
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Management/2.0.0.0__b03f5f7f11d50a3a/System.Management.dll
    SQLEditors
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/SQLEditors.DLL
    Microsoft.VisualStudio.TextManager.Interop
        Assembly Version: 7.1.40304.0
        Win32 Version: 7.10.6070
        CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.VisualStudio.TextManager.Interop/7.1.40304.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.TextManager.Interop.dll
    Microsoft.SqlServer.Management.MultiServerConnection
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1539 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Management.MultiServerConnection/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Management.MultiServerConnection.dll
    RadLangSvc
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///E:/Program%20Files%20(x86)/Microsoft%20SQL%20Server/100/Tools/Binn/VSShell/Common7/IDE/RadLangSvc.DLL
    Microsoft.VisualStudio.Package.LanguageService
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.1826 (QFE.050727-1800)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.Package.LanguageService/2.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Package.LanguageService.dll
    Microsoft.SqlServer.Management.SqlParser
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.4000.0 ((KJ_PCU_Main).120628-0827 )
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.SqlServer.Management.SqlParser/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.Management.SqlParser.dll
    Microsoft.SqlServer.GridControl
        Assembly Version: 10.0.0.0
        Win32 Version: 10.50.1600.1 ((KJ_RTM).100402-1540 )
        CodeBase: file:///C:/Windows/assembly/GAC_32/Microsoft.SqlServer.GridControl/10.0.0.0__89845dcd8080cc91/Microsoft.SqlServer.GridControl.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.

    Hi,
    How many SQL Server instances were installed on the server?
    Have you tried to connect this instance from another machine using SQL Server Management Studio?
    1. Try the solution by Zack1223 in the link below. Delete the shell folder in C:\Users\<username>\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\ and check the result.
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/dc67c38e-6749-4908-a9a8-d181c12b7e91/sql-server-management-studio-express-2005-keeps-crashing
    2. Try to download and install shared management objects to fix this issue. Download here:
    http://www.microsoft.com/en-us/download/details.aspx?id=30440
    Refer to this thread:
    http://social.msdn.microsoft.com/Forums/en-US/sqlsetupandupgrade/thread/9125eaae-13f5-42b1-861f-e81e2b46c1de
    Hope it helps.
    Tracy Cai
    TechNet Community Support

  • Want to convert function in SQL Server 2000

    Hi ,
    i am writing this function in oracle.Could you please convert this function in SQL Server 2000 because i am new in this and dont know how to use decode function in sql.
    Please following is the code for oracle.
    CREATE OR REPLACE function fun ( localex varchar2,titlex varchar2)
    return number
    as  x number;
    begin
    select sum ( decode (count (username),max(prereq_count),1,0) ) x into x from
       SELECT
                       prereq_count,
                       username
                 FROM
                         table1
    group by     username ;
    return x;
    end fun;
    Regards
    Vishal

    Just take a look example below might give you idea :
    create or replace function f_makeAddress_tx (
    i_address_tx VARCHAR2,
    i_city_tx VARCHAR2,
    i_state_tx VARCHAR2,
    i_zip_tx VARCHAR2)
    return VARCHAR2
    is
    e_badZip EXCEPTION; u279E8
    pragma EXCEPTION_init(e_badZip,-20998); u279E9
    v_out_tx VARCHAR2(256);
    begin
    p_validateZip (i_zip_tx); u279E12
    v_out_tx:= i_address_tx||u2019, u2018|| u279E13
    i_city_tx ||u2019, u2018||
    i_state_tx ||u2019, u2018||
    i_zip_tx;
    return v_out_tx; u279E17
    exception
    when e_badZip then u279E19
    return i_zip_tx || u2018: Invalid zip code.u2019;
    end;
    Regards,
    Clint

  • DeadLocks on Query Notifications with SQL Server 2008 SP3

    Hello,
    according to this article https://support.microsoft.com/kb/975090 the issue with deadlocks on query notifications should be fixed with SQL Server 2008 SP3 (10.0.5500.0). But we still get deadlocks in the following manner:
    <resource-list>
    <keylock hobtid="72057598393909248" dbid="5" objectname="MyDB.sys.query_notification_1411013420" indexname="cidx" id="lock1731c1f00" mode="RangeX-X" associatedObjectId="72057598393909248">
    <owner-list>
    <owner id="process573dc8" mode="RangeX-X"/>
    </owner-list>
    <waiter-list>
    <waiter id="process58ddc8" mode="RangeS-U" requestType="wait"/>
    </waiter-list>
    </keylock>
    <keylock hobtid="72057598372872192" dbid="5" objectname="MyDB.sys.query_notification_253437289" indexname="cidx" id="lock800c8780" mode="RangeS-U" associatedObjectId="72057598372872192">
    <owner-list>
    <owner id="process58ddc8" mode="RangeS-U"/>
    </owner-list>
    <waiter-list>
    <waiter id="process573dc8" mode="RangeS-U" requestType="wait"/>
    </waiter-list>
    </keylock>
    </resource-list>
    Is there any need to install another fix?
    Thanks in Advance!

    Hello,
    SQL Server 2008 SP4 and all cumulative updates of SP3 do not have fixes related to deadlocks.
    Maybe the following workarounds and solutions can help in your scenario.
    http://stackoverflow.com/questions/3707137/understanding-deadlocks-with-sql-server-query-notifications
    Deadlock Prevention. In case you need to lock multiple conversation groups in a transaction, you need to take the same order to lock the different conversation groups in all transactions, otherwise you will have a deadlock issues.
    Source:
    http://blogs.msdn.com/b/kangmo/archive/2008/12/17/a-brief-guide-on-sql-server-service-broker.aspx
    Try to may transactions more simple and shorter.
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • How many query possible in 1 second at Sql Server ?

    Hello
    I have 30,000 records. Table have 10 columns. Columns have indexes if column at where condition. And select question will give 20-30 records as result. (select column1, column2,...... column10 from table where columnSecondID=2I. I will use hosting standart
    plane. 
    How many query possible in 1 second at Sql Server 2008 ?
    How many query possible in 1 second at Sql Server 2012 ?
    How many user can visit my web site ?

    Hello
    I have 30,000 records. Table have 10 columns. Columns have indexes if column at where condition. And select question will give 20-30 records as result. I will use hosting standart plane. 
    How many query possible in 1 second at Sql Server 2008 ?
    How many query possible in 1 second at Sql Server 2012 ?
    How many user can visit my web site ?
    That's hard to say. One second for CPU is quite high time and CPU can do lot of work in that time. again, this is relative and depends on what the query is.
    The biggest bottleneck in performance is - Disk IO system. In general, if  the required data is in memory, it can help significantly in improving the performance.
    Remember, CPU will be doing other processing work while it is fetching the data from disk.
    What you need to is  - load test or stress your server. There are some tools available for you to do it. 
    RML : https://support.microsoft.com/en-us/kb/944837?wa=wsignin1.0
    distributed replay : https://msdn.microsoft.com/en-us/library/ff878183.aspx
    to test IO : http://www.brentozar.com/archive/2008/11/storage-performance-testing-with-sqlio/
    read this : http://www.brentozar.com/archive/2012/06/load-test-sqlserver/
    You also need to look at Max worker thread limitations. this depends on the server configuration(64 bit/32 bit) and other factors...
    https://technet.microsoft.com/en-us/library/ms187024%28v=sql.105%29.aspx
    one problem that can happend is thread pool starvation where there are too many connections
    happening if your server cannot keep up with the workload.. like if your cpu is working in processing the queries and cannot accept new connections..
    watch this good youtube video on thread pool starvatioin :
     https://www.youtube.com/watch?v=XJ67oHBM2Hw
    Hope it Helps!!

  • Problem attaching mdf file in sql server 2008

    hi...!
    I have an mdf file of sql server 2005 database now i want it to attach in sql server 2008 R2 but when i try to attach it, it gave me error saying.
       Fail to retrieve data for this request. 
     An exception occur while executing a Transact-SQL statement or batch.(Microsoft.sqlServer.connectionInfo)
    C:\program files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\file6.mdf is not a primary database file. (Microsoft SQL Server, Error:5171)
    Thanks in advance

    hi...!
    I have an mdf file of sql server 2005 database now i want it to attach in sql server 2008 R2 but when i try to attach it, it gave me error saying.
       Fail to retrieve data for this request. 
     An exception occur while executing a Transact-SQL statement or batch.(Microsoft.sqlServer.connectionInfo)
    C:\program files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\file6.mdf is not a primary database file. (Microsoft SQL Server, Error:5171)
    Thanks in advance
    Hello,
    As the message says the file is not primary data file ,i guess it must be ndf(secondary data file) or some other file you might have selected by mistake.PLease select primary data file and try attching you will succed
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Tables missing in SQL Server 2008 for Hyperion Application

    Hello Experts,
    I am cuurently working on Hyperion Finacial close management (Account Reconciliation Manager) application version 11.1.2.3, O.S is Windows 2008 R2 and relational database is SQL Server 2008.
    When I am trying to copy Account Profiles to a period say go to Manage->Periods->Right Click->Copy to Periods, I get the error:
    Object arm_access is missing.
    When I open SQL server studio, I can clearly see table 'ARM_ACCESS' but when I did a search on oracle support and google, I found out that it is a case sensitive issue and the table has to be in small letters.
    So I created a new table 'arm_access' with all columns as there are in 'ARM_ACCESS' in SQL Server 2008, but it is not fetching any data.
    Can anyone provide me the query that I can run to display the same structure and data for 'arm_access'?
    If anyone is using the instance, he/she should be able to provide me the query that I can run in SQL server 2008 to populate the 'arm_access' table.
    Appreciate your help as this is stopping my development work.
    Thanks in advance.
    Regards,
    Sumit

    Hi Sumit,
    Its just a wild guess am not sure with this.
    i dont have idea about query in sql server. but it oracle it would be something like create table targettablename as select * from sourcetablename.
    Ideally it will not allow to create you a table with that name if its already exists i mean its case insensitive (. Even if you have created manually make sure the db user you created with has select privilage granted for all users or the user you configured in Financial close management) or the DB might not be having select privilage .
    Note:Have backups in place when you are manually to manipulate or changing the database user.
    Thanks
    Amith

  • Converting MDX query into SQL Server 2008

    We have MDX query based OLAP CUbes.
    To reduce MDX based dependenies, we have to convert MDX based cube to sql server 2008 based queries.
    For this I need expert advise to convert below query to sql server 2008 based query :
    CREATE MEMBER CURRENTCUBE.Measures.[Ack Lost]
                        AS 'Sum(PeriodsToDate([Time].[Year], [Time].CurrentMember ), [Measures].[Lost])',
                        FORMAT_STRING = "#,#",
                        VISIBLE = 1;

    Hi Sachin,
    According to your description, you need to convert the MDX query to T-SQL query, right?
    Your MDX query is calculated measure that return the total value from the first sibling and ending with the given member. In T-SQL query we can use the query as Yogisha provided to achieve the same requirement. Now you need to a tool to convert all the MDX
    related SSAS cube queries to MS SQL Server 2008 based queries.
    Although MDX has some similarities with T-SQL these languages are in many ways different. Beginning to learn and comprehend SQL Server Analysis Services (SSAS) MDX queries can be difficult after one has spent years writing queries in T-SQL. Currently, there
    is no such a tool to convert a MDX query to T-SQL query since the structure difference between MDX and T-SQL. So you need to convert them manually, please refer to the links below to see the details.
    http://www.mssqltips.com/sqlservertip/2916/comparison-of-queries-written-in-tsql-and-sql-server-mdx/
    https://sqlmate.wordpress.com/2013/11/12/t-sql-vs-mdx-2/
    http://technet.microsoft.com/en-us/library/aa216779(v=sql.80).aspx
    Regards,
    Charlie Liao
    TechNet Community Support

  • Require help with Pivot table query in SQL Server 2008

    Hi,
    I have a query regarding converting columns to rows in SQL Server 2008. Please look at the table below. 
    I need the output to look something like this :
    The columns for the children can be dynamic or fixed ( max of 6 children) based on the Family_ID.  For Example: A family can have 1 child or more than 1 child.
    Not sure how to go about it. Would appreciate your help :)

    Looks like you need dynamic pivot on multiple columns. I have two articles on this topic, start from this one
    T-SQL:
    Dynamic Pivot on Multiple Columns
    It has reference to my other blog post.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • CONVERT function in SQL Server to oracle

    All,
    How to convert CONVERT function in SQL Server to oracle, below mentioned format is in SQL Server:
    variable1 = convert(numeric(20), SUBSTRING( parameter1,parameter2,parameter3)
    parameter1 datatype nvarchar2(100)
    parameter2 datatype bigint
    parameter3 datatype bigint
    I did bit R&D, but was not successful..but still getting on..
    If any help that would be great...
    Regards,
    ~ORA

    You cannot specify the precision/scale or length of input paramters to a stored procedure in Oracle, or at least the pl/sql engine does not respect the sizing. Assuming that you want to do something with variable1 in the procedure, and not just return it, the Oracle equivalent would be something along the lines of:
    SQL> CREATE FUNCTION f (p_param1 IN VARCHAR2,
      2                     p_param2 IN NUMBER,
      3                     p_param3 IN NUMBER) RETURN NUMBER IS
      4     l_var1 NUMBER(20) := SUBSTR(p_param1, p_param2, p_param3);
      5  BEGIN
      6     RETURN l_var1 * 10;
      7  END;
      8  /
    Function created.
    SQL> SELECT f('ABC10DEF', 4, 2) FROM dual;
    F('ABC10DEF',4,2)
                  100You may need to adjust the return type to match what you are actually returning.
    You can also use this iin a direct assignment in pl/sql without doig a select, something like:
    SQL> DECLARE
      2     l_num NUMBER(20);
      3  BEGIN
      4     l_num := f('ABC10DEF', 4, 2);
      5     DBMS_OUTPUT.Put_Line('The number is: '||l_num);
      6  END;
      7  /
    The number is: 100John

  • How to convert rows to columns in sql server 2008

    How to convert rows to columns in sql server 2008 using the GROUP BY function? (only one query allowed)

    Lookup the Pivot transformation. From BOL:
    The Pivot transformation makes a normalized data set into a less normalized
    but more compact version by pivoting the input data on a column value. For
    example, a normalized Orders data set that lists customer name, product, and quantity purchased typically has multiple rows for any customer who purchased multiple products, with each row for that customer showing order
    details for a different product. By pivoting the data set on the product column, the Pivot transformation can output a data set with a
    single row per customer. That single row lists all the purchases by the customer, with the product names shown as column names, and the quantity shown as a value in the product column. Because not every customer purchases every product, many columns may contain
    null values.
    When a dataset is pivoted, input columns perform different roles in the pivoting process. A column can participate in the following ways:
    The column is passed through unchanged to the output. Because many input rows
    can result only in one output row, the transformation copies only the first
    input value for the column.
    The column acts as the key or part of the key that identifies a set of
    records.
    The column defines the pivot. The values in this column are associated with
    columns in the pivoted dataset.
    The column contains values that are placed in the columns that the pivot
    creates.
    Paul

  • Cannot kill a session that is running a query on a linked server in SQL Server 2008 R2

    Hi,
    Cannot kill a session that is running a query on a linked server  in SQL Server 2008 R2.
    When I try to kill, it status shown as "KILLED/ROLLBACK"
    I have facing the issue from long back. I searched many and none of them worked for me
    Any help is greatly appreciated
    Thanks
    Jaison
    Carver

    I guess its stuck, can you see some blocking or any other process blocking the rollback.
    can you check rollback status using below command. Or you can use sp_who2 and check status column
    select percent_complete,estimated_completion_time from sys.dm_exec_requests
    where spid=xxx
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

  • Undisplayed Physical query SQL Server 2008

    Hi,
    I am querrig an SQL Server 2008 database with OBIEE. But the physical query syntax isn't dispalayed in the nqQuery.
    I got a message seems to History unfound.
    Is there any way to get the physical query on database different from oracle like SQL server or XML...?
    Thanks

    Can you check the logging level of the user you are logging as ?
    I guess because the logging level is not defined hence no history for this user !!

  • SQL Server 2008 R2 Licensing Query

    Hi,
    If i have SQL Server 2008 R2 Enterprise License key for a single instance and I am installing all the shared features from the setup. Then is my license counted as being used or no?
    Or is it only used when i install Database Engine?
    Please mark the answer as helpful if i have answered your query. Thanks and Regards, Kartar Rana

    No, a separate license is not required for
    Management Tools.
    However, any device that has SQL Server tools or technologies installed must have a valid SQL Server license. 
    Hope this clears your question..
    Raju Rasagounder Sr MSSQL DBA

  • Want to know what is improvement in FILEstram storage feature from SQL SERVER 2008 to SQL SERVER 2014

    Hi All ,
     want to know what is improvement in FILEstram storage feature  from  SQL SERVER 2008 to  SQL SERVER 2014
    Regards,
    Manish

    Hello Manish,
    See
    What's New in SQL Server 2012
    What's New in SQL Server 2014
    Nothing really new around that feature.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

Maybe you are looking for

  • A user cant see anything in SharePoint calendar with full access

    Hi, I have a wierd issue, where only one user cannot see anything in SharePoint 2010 Calendar, when everyone else can. The calendar has more than 100 events, and he cannot see anything in Calendar view. The calendar.aspx page comes up with no items i

  • Ok i think its rediculously difficult to put a video from my pc to my ipad2...

    Why do i need 2 hours to finally put a video from my computer to my ipad and an additional 50 minutes for it to convert with software which is not even from apple?!?! What is wrong with the good old copy-paste?! Seriously, Apple is always saying its

  • MM pricing schema

    Hi Friends, Can anyone provide me a real good material but easy to understand how MM pricing schema works? I need to understand the functions, controls and dependancies of all the fields that are used in a schema. Thanks for your help. Rana

  • I need alternative link for Adobe's software

    i need adobe creative cloud packager but i can't download it from here: Adobe CC 2014 Direct Download Links – Creative Cloud 2014 Release | ProDesignTools is anybody can upload it for me?

  • Apple TV / iOS and AirPlay is intermittent after updates.

    Background: Home network with Airport Extreme, Apple TV, 2 MacBook Pro's, 2 iPads and an iPhone. Everything works together great, just as it should. I can play music from either the laptops or iPads over my house system via Apple TV. AirPlay is great