Joining Timestamps and Time Intervals + SQL Server 2012

I'm trying to compile a report for the uptime of some assets grouped into 10 minute intervals, with the time the asset went down reported on in the next 10 minute block and any block it crosses into.
Currently I have two tables the first is a Calendar table with entries for each 10 minute block which creates my time intervals for the month.
CalendarDate
01/01/2015 20:20:00
01/01/2015 20:30:00
01/01/2015 20:40:00
Etc.
The second table is my Events table which gives me the start of the down time and the end of the down time along with some other useful data.
StartTime:-01/01/2015 20:29:25
EndTime:-01/01/2015 21:42:54
Asset:-Asset01
EventCode:-Event01
TimeOnRoundedUp:-01/01/2015 20:30:00
TimeOffRoundedUp:-01/01/2015 21:20:00
And
StartTime:-01/01/2015 22:01:31
EndTime:-01/01/2015 22:02:01
Asset:-Asset01
EventCode:-Event01
TimeOnRoundedUp:-01/01/2015 22:10:00
TimeOffRoundedUp:-01/01/2015 22:10:00
There is only 1 Event active per Asset at any given time but many events for different assets, some events only last 30 seconds and are within the same 10 minute reporting period, other events span one or more periods.
The result set I'd like to see is grouped by CalanderDate, Asset and EventCode showing the total number of seconds in the ten minute window the asset was running.
Using the two examples above I'd like to see the two rows below:-
CalendarDate, Asset, EventCode, RunningTimeSeconds
01/01/2015 20:30:00, Asset01, Event01, 565 (600-35)
01/01/2015 20:40:00, Asset01, Event01, 0 (600-600)
01/01/2015 20:50:00, Asset01, Event01, 426 (600-174)
01/01/2015 21:00:00, (600-0)
01/01/2015 21:10:00, Asset01, Event01, 570 (600-30)
For the Events that Start and Stop in the same interval I can get those, using DATEDIFF, it's the Events that happen to span one of more periods I can't work out.
I can add additional columns to the tables if needed.
Any and all help is greatly welcomed, thank you for reading my post.
Mark

Give this a go:
DECLARE @calendar TABLE (dateTime DATETIME)
DECLARE @daTetime DATETIME = '2015-01-01'
SET NOCOUNT ON
WHILE CAST(@dateTime AS DATE) = '2015-01-01'
BEGIN
INSERT INTO @calendar (dateTime) VALUES (@dateTime)
SET @dateTime = DATEADD(MINUTE,10,@dateTime)
END
SET NOCOUNT OFF
DECLARE @events TABLE (startDateTime DATETIME, endDateTime DATETIME, asset VARCHAR(20), eventCode VARCHAR(20))
INSERT INTO @events (startDateTime, endDateTime, asset, eventCode)
VALUES ('2015-01-01 02:39:57','2015-01-01 02:59:32','asset01','event01'),('2015-01-01 10:22:57','2015-01-01 13:01:32','asset01','event01'),('2015-01-01 17:38:57','2015-01-01 19:39:32','asset01','event01')
SELECT *,
DATEDIFF(SECOND,
CASE WHEN e.startDateTime >= c.dateTime THEN e.startDateTime
WHEN e.startDateTime < c.dateTime THEN c.dateTime
END,
CASE WHEN e.endDateTime <= DATEADD(MINUTE,10,c.dateTime) THEN e.endDateTime
WHEN e.endDateTime > DATEADD(MINUTE,10,c.dateTime) THEN DATEADD(MINUTE,10,c.dateTime)
END
FROM @calendar c
LEFT OUTER JOIN @events e
ON e.startDateTime BETWEEN c.dateTime AND DATEADD(MINUTE,10,c.dateTime)
OR e.endDateTime BETWEEN c.dateTime AND DATEADD(MINUTE,10,c.dateTime)
OR c.dateTime BETWEEN e.startDateTime AND e.endDateTime

Similar Messages

  • SQL Server Data Tools – Business Intelligence for Visual Studio 2013 (SSDT BI) and SSIS on SQL Server 2012

    This great blog entry titled
    SQL Server Data Tools - Business Intelligence for Visual Studio 2013 (SSDT BI), link below, highlights the lack of support for SSIS projects using SQL Server 2012, VS 2013 and SSDT BI for VS 2013. I see there is a new version
    on SSDT BI for VS 2013 (12.0.2430.0, File Name: SSDTBI_x86_ENU.exe, Date Published: 10/27/2014) link below.
    Does this version support SSIS projects using SQL Server 2012 using VS 2013 and SSDT BI for VS 2013?
    http://blogs.msdn.com/b/analysisservices/archive/2014/04/02/sql-server-data-tools-business-intelligence-for-visual-studio-2013-ssdt-bi.aspx
    http://www.microsoft.com/en-us/download/details.aspx?id=42313

    Hi cjrinpdx,
    According to the picture, it seems that we can use SSIS 2012 support is not included in SSDT-BI for VS 2013. And based on the previous versions, SSIS always different from SSRS, SSAS.
    SSDT-BI for Visual Studio 2012 supports versions of SQL Server as follows:
    SSAS project can target SQL 2012 or lower
    SSRS project can target SQL 2012 or lower
    SSIS project can target only SQL 2012
    The following blog is for your reference:
    http://blogs.technet.com/b/dataplatforminsider/archive/2013/11/13/microsoft-sql-server-data-tools-update.aspx
    Since I have no environment to test this at this moment,
    I recommend you that submit the feedback at
    https://connect.microsoft.com/SQLServer/. 
    Thank you for your understanding.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • SharePoint 2013 and SQL Server 2012

    Hi all, 
    I've looked around and not found a concrete answer to this question; or maybe I have and just haven't realised! Anyway.
    We've currently got a license for SharePoint 2013 Enterprise, and are working on introducing Business Intelligence capabilities, namely Power Pivot and Power View. We'd like the data to be refreshed regularly, meaning we need Power Pivot on the SQL Server.
     As Power Pivot and Power View are listed as features for SharePoint 2013 Enterprise, is it enough to have the Enterprise licence for SP2013, and use a SQL Server 2012 Standard License, installing the Power Pivot configuration tool along with the required
    SSRS for Power View? Or do we need a SQL Server 2012 BI / Enterprise License to make use of Power View and Data Refresh on SP 2013?
    I've also seen talks of installing SQL Server 2012 SP1 -- I'm new to all of this, but would having SQL Server 2012 Standard License alongside installing SP1 be sufficient for the above features?
    Many thanks for any help.

    PowerPivot/PowerView do require the BI or Enterprise editions of SQL 2012 (and yes, SQL 2012 SP1 is required for SharePoint 2013).  These instances must be installed on the SharePoint server, not the SQL Database Engine server.  You can use SQL
    Standard for the Database Engine server.
    Trevor Seward, MCC
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • Konesans File Watcher Task and SQL Server 2012

    Hello!
    I am trying to use the  Konesans File Watcher Task which worked perfectly for SQL 2008, to upgrade to SQL 2012. I am getting the following error
    Cannot create a task from XML for task "File Watcher Task", type Konesans.Dts.Tasks FileWatcherTask.FileWatcherTask, Koneaasans .......
    Anyone have any ideas on how to upgrade the Konesans File Watcher Task for SQL 2012?
    Thanks,
    Mike
    Mike Kiser

    Hi,
    Konesans File Watcher Task is a 3rd party tool.
    I had the same issue while upgrading SSIS 2005 packages which relied on this component to SSIS 2008.
    Solution : you'll have to install Konesans File Watcher Task 2012 on your development PC (and on the SQL Server 2012 which will run this SSIS job).
    Sebastian Sajaroff Senior DBA Pharmacies Jean Coutu

  • Startup Parameter -g in SQL Server 2012

    Can any one Explain whats the difference between the Start up parameters -g500 and -g512 in SQL Server 2012. Why we can't use both of them together.
    Thank in advance.

    see
    http://msdn.microsoft.com/en-US/library/ms190737(v=sql.110).aspx
    -g500 would reserve 500MB, -g512 512MB
    Thanks for your reply. Can you please tell me how much maximum memory we can specify in this
    parameter.
    Thanks,
    AyubKhan M

  • How to join a Domain Controller Server to an two-tier (SQL Server 2012) and Sharepoint 2013 (SP2013) farm

    Hi,
    I am trying to build a 3-tier SharePoint 2013 farm.
    1. SQL Server 2012, Windows 2012 VM
    2. DC Server, Windows 2012 VM
    3. SharePoint 2013, Windows 2012 VM
    I didn't built the DC server. Someone else did. However, I created about 14 service domain user accounts for SQL Server and SharePoint install and operation.
    I was able to join the SQL Server into the SharePoint server farm using SharePoint 2013 Product Configuration Wizard.  When I start the Central Admin, and click on Servers in the Farm, I only see the SharePoint server and SQL server,
    but the DC server is not listed.  Any suggestion on what did I miss?
    Thanks
    Jean

    You cannot join the Domain Controller to your SharePoint farm.  You must instead join each server from that farm to the domain that is served up by that DC.  You will want to uninstall SharePoint and probably SQL before you do this.  If it's
    an option, I would re-provision your VMs completely and start fresh.  Once you login to a new server, join that server to the target domain like this: 
    http://www.petri.co.il/join-windows-server-2012-to-domain.htm
    You'd have to ensure that your DNS resolves to the target domain on the server being joined to the domain.  If it doesn't, you can always use HOSTS entries to overcome that in the short term.
    Once you've joined both the future SQL and SharePoint servers to the domain, you can install SQL Server and then SharePoint on their prospective servers to create your farm.
    I trust that answers your question...
    Thanks
    C
    |
    RSS |
    http://crayveon.com/blog |
    SharePoint Scripts | Twitter |
    Google+ | LinkedIn |
    Facebook | Quix Utilities for SharePoint

  • SQL Server 2012 Management Studio:In the Database, how to print out or export the old 3 dbo Tables that were created manually and they have a relationship for 1 Parent table and 2 Child tables?How to handle this relationship in creating a new XML Schema?

    Hi all,
    Long time ago, I manually created a Database (APGriMMRP) and 3 Tables (dbo.Table_1_XYcoordinates, dbo.Table_2_Soil, and dbo.Table_3_Water) in my SQL Server 2012 Management Studio (SSMS2012). The dbo.Table_1_XYcoordinates has the following columns: file_id,
    Pt_ID, X, Y, Z, sample_id, Boring. The dbo.Table_2_Soil has the following columns: Boring, sample_date, sample_id, Unit, Arsenic, Chromium, Lead. The dbo.Table_3_Water has the following columns: Boring, sample_date, sample_id, Unit, Benzene, Ethylbenzene,
    Pyrene. The dbo.Table_1_XYcoordinates is a Parent Table. The dbo.Table_2_Soil and the dbo.Table_3_Water are 2 Child Tables. The sample_id is key link for the relationship between the Parent Table and the Child Tables.
    Problem #1) How can I print out or export these 3 dbo Tables?
    Problem #2) If I right-click on the dbo Table, I see "Start PowerShell" and click on it. I get the following error messages: Warning: Failed to load the 'SQLAS' extension: An exception occurred in SMO while trying to manage a service. 
    --> Failed to retrieve data for this request. --> Invalid class.  Warning: Could not obtain SQL Server Service information. An attemp to connect to WMI on 'NAB-WK-02657306' failed with the following error: An exception occurred in SMO while trying
    to manage a service. --> Failed to retrieve data for this request. --> Invalid class.  .... PS SQLSERVER:\SQL\NAB-WK-02657306\SQLEXPRESS\Databases\APGriMMRP\Table_1_XYcoordinates>   What causes this set of error messages? How can
    I get this problem fixed in my PC that is an end user of the Windows 7 LAN System? Note: I don't have the regular version of Microsoft Visual Studio 2012 in my PC. I just have the Microsoft 2012 Shell (Integrated) program in my PC.
    Problem #3: I plan to create an XML Schema Collection in the "APGriMMRP" database for the Parent Table and the Child Tables. How can I handle the relationship between the Parent Table and the Child Table in the XML Schema Collection?
    Problem #4: I plan to extract some results/data from the Parent Table and the Child Table by using XQuery. What kind of JOIN (Left or Right JOIN) should I use in the XQuerying?
    Please kindly help, answer my questions, and advise me how to resolve these 4 problems.
    Thanks in advance,
    Scott Chang    

    In the future, I would recommend you to post your questions one by one, and to the appropriate forum. Of your questions it is really only #3 that fits into this forum. (And that is the one I will not answer, because I have worked very little with XSD.)
    1) Not sure what you mean with "print" or "export", but when you right-click a database, you can select Tasks from the context menu and in this submenu you find "Export data".
    2) I don't know why you get that error, but any particular reason you want to run PowerShell?
    4) If you have tables, you query them with SQL, not XQuery. XQuery is when you query XML documents, but left and right joins are SQL things. There are no joins in XQuery.
    As for left/right join, notice that these two are equivalent:
    SELECT ...
    FROM   a LEFT JOIN b ON a.col = b.col
    SELECT ...
    FROM   b RIGHT JOIN a ON a.col = b.col
    But please never use RIGHT JOIN - it gives me a headache!
    There is nothing that says that you should use any of the other. In fact, if you are returning rows from parent and child, I would expect an inner join, unless you want to cater for parents without children.
    Here is an example where you can study the different join types and how they behave:
    CREATE TABLE apple (a int         NOT NULL PRIMARY KEY,
                        b varchar(23) NOT NULL)
    INSERT apple(a, b)
       VALUES(1, 'Granny Smith'),
             (2, 'Gloster'),
             (4, 'Ingrid-Marie'),
             (5, 'Milenga')
    CREATE TABLE orange(c int        NOT NULL PRIMARY KEY,
                        d varchar(23) NOT NULL)
    INSERT orange(c, d)
       VALUES(1, 'Agent'),
             (3, 'Netherlands'),
             (4, 'Revolution')
    SELECT a, b, c, d
    FROM   apple
    CROSS  JOIN orange
    SELECT a, b, c, d
    FROM   apple
    INNER  JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    LEFT   OUTER JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    RIGHT  OUTER JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    FULL OUTER JOIN orange ON apple.a = orange.c
    go
    DROP TABLE apple, orange
    Erland Sommarskog, SQL Server MVP, [email protected]

  • SQL Server 2012 Management Studio Displays Error With "New Query" and Intellisense Works Intermittenly

    I was upgrade to SQL Server 2012 and Visual Studio 2010 was upgraded with SP1 the same day.  This is x64 machine. 
    Microsoft SQL Server Management Studio      11.0.2100.60
    Microsoft .NET Framework      4.0.30319.261
    Operating System      6.1.7601
    Problem 1) With SQL Server Management Studio, selecting "New Query" a warning box is displayed: "The 'Microsoft.Practices.EnterpriseLibrary.Configuration.Design.VisualStudioIntegration2010Package, Microsoft.Practices.EnterpriseLibrary.Configuration.Design.VisualStudioIntegration2010,
    Version=1.0.0.0, Culture=netutral, PublicKeyToken=null' package did not load correctly.    The problem mayhave been cuased by a configuration change or by the installation of another extension.  You can get more information by running the
    application together with the /log parameter on the command line, and then examining the file ...\AppDate\Roaming\Microsoft\AppEnv\10.0\ActivityLog.xml'.  Continue to show this error message?
    Problem 2) In a Query Initellisense works intermittently but most of the time it will not display anything.  I have tried Edit|Intellisense|Refresh Cach size and also seperately, Edit | Intellisense | List Members but neither has helped.  Also
    tried different selections for Tools|options| T-SQL | Intellisense| Maximum Script Size; no luck either. 

    Hi WallyJim,
    For your first problem, possible workaround:
    In Programs and Features (or Add/Remove Programs), right click the Microsoft Enterprise Library 5.0 Optional Update 1 program and select change. Remove the VisualStudio2010 integration.
    Then, install the EnterpriseLibrary Configuration extension from Microsoft via the Extension Manager in VS2010. This will allow you to launch the configuration editor from VS2010, but will not be installed for SSMS.
    For more information, please refer to
    https://connect.microsoft.com/SQLServer/feedback/details/620532/error-message-on-new-query-window-opening.
    For your second problem, the following conditions might affect the behavior of IntelliSense:
    There is a code error above the cursor.
    The insertion point is inside a code comment.
    The insertion point is inside a string literal.
    The automatic options are turned off.
    For more information, refer to Troubleshooting IntelliSense (SQL Server Management Studio):
    http://msdn.microsoft.com/en-us/library/ms173434.aspx.
    Thanks,
    Maggie
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.

  • SQL Server 2012 DB Engine does not start (clean install with server 2012 and 2008 R2)

    I'm trying to do clean installation of SQL server 2012 on Server 2012 (which is runnning as a VM on ESX server) and getting this "wait on the DB engine recovery failed" message. Initially, I though this issue was related to some permission issues
    but changing the permission or service accounts didn't help. I'm not seeing any "denied" messages in the log files either. Even with Server 2008 R2 (clean built VM), the installation gives the exactly the same error messages. 
    My setup is purely for test purpose; so, the security is not a concern. Can someone help or give me a clue where to look? 
    (Summary)
    Overall summary:
      Final result:                  Failed: see details below
      Exit code (Decimal):           -2061893606
      Start time:                    2014-05-28 17:12:12
      End time:                      2014-05-28 17:19:47
      Requested action:              Install
    Setup completed with required actions for features.
    Troubleshooting information for those features:
      Next step for SQLEngine:       Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
    Machine Properties:
      Machine name:                  WIN-1V3VKPV5Q19
      Machine processor count:       1
      OS version:                    Future Windows Version
      OS service pack:               
      OS region:                     United States
      OS language:                   English (United States)
      OS architecture:               x64
      Process architecture:          64 Bit
      OS clustered:                  No
    Product features discovered:
      Product              Instance             Instance ID                    Feature                
                     Language             Edition              Version         Clustered 
    Package properties:
      Description:                   Microsoft SQL Server 2012 Service Pack 1
      ProductName:                   SQL Server 2012
      Type:                          RTM
      Version:                       11
      Installation location:         E:\x64\setup\
      Installation edition:          Evaluation
      Slipstream:                    True
      SP Level                       1
      Patch Level:                   11.1.3128.0
    Product Update Status:
      Success: KB 2674319, KB 2793634
    Product Updates Selected for Installation:
      Title:                         Service Pack 1
      Knowledge Based Article:       KB 2674319
      Version:                       11.1.3000.0
      Architecture:                  x64
      Language:                      1033
      Title:                         SQL Server 2012 SP1 GDR Product Update
      Knowledge Based Article:       KB 2793634
      Version:                       11.1.3128.0
      Architecture:                  x64
      Language:                      All
      Update Source:                 MU
    User Input Settings:
      ACTION:                        Install
      ADDCURRENTUSERASSQLADMIN:      false
      AGTSVCACCOUNT:                 NT Service\SQLAgent$TESTDB
      AGTSVCPASSWORD:                *****
      AGTSVCSTARTUPTYPE:             Manual
      ASBACKUPDIR:                   Backup
      ASCOLLATION:                   Latin1_General_CI_AS
      ASCONFIGDIR:                   Config
      ASDATADIR:                     Data
      ASLOGDIR:                      Log
      ASPROVIDERMSOLAP:              1
      ASSERVERMODE:                  MULTIDIMENSIONAL
      ASSVCACCOUNT:                  <empty>
      ASSVCPASSWORD:                 <empty>
      ASSVCSTARTUPTYPE:              Automatic
      ASSYSADMINACCOUNTS:            <empty>
      ASTEMPDIR:                     Temp
      BROWSERSVCSTARTUPTYPE:         Automatic
      CLTCTLRNAME:                   <empty>
      CLTRESULTDIR:                  <empty>
      CLTSTARTUPTYPE:                0
      CLTSVCACCOUNT:                 <empty>
      CLTSVCPASSWORD:                <empty>
      CLTWORKINGDIR:                 <empty>
      COMMFABRICENCRYPTION:          0
      COMMFABRICNETWORKLEVEL:        0
      COMMFABRICPORT:                0
      CONFIGURATIONFILE:             C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\20140528_170909\ConfigurationFile.ini
      CTLRSTARTUPTYPE:               0
      CTLRSVCACCOUNT:                <empty>
      CTLRSVCPASSWORD:               <empty>
      CTLRUSERS:                     <empty>
      ENABLERANU:                    false
      ENU:                           true
      ERRORREPORTING:                false
      FEATURES:                      SQLENGINE
      FILESTREAMLEVEL:               0
      FILESTREAMSHARENAME:           <empty>
      FTSVCACCOUNT:                  <empty>
      FTSVCPASSWORD:                 <empty>
      HELP:                          false
      IACCEPTSQLSERVERLICENSETERMS:  true
      INDICATEPROGRESS:              false
      INSTALLSHAREDDIR:              C:\Program Files\Microsoft SQL Server\
      INSTALLSHAREDWOWDIR:           C:\Program Files (x86)\Microsoft SQL Server\
      INSTALLSQLDATADIR:             <empty>
      INSTANCEDIR:                   C:\Program Files\Microsoft SQL Server\
      INSTANCEID:                    TESTDB
      INSTANCENAME:                  TESTDB
      ISSVCACCOUNT:                  NT AUTHORITY\Network Service
      ISSVCPASSWORD:                 <empty>
      ISSVCSTARTUPTYPE:              Automatic
      MATRIXCMBRICKCOMMPORT:         0
      MATRIXCMSERVERNAME:            <empty>
      MATRIXNAME:                    <empty>
      NPENABLED:                     0
      PID:                           *****
      QUIET:                         false
      QUIETSIMPLE:                   false
      ROLE:                          <empty>
      RSINSTALLMODE:                 DefaultNativeMode
      RSSHPINSTALLMODE:              DefaultSharePointMode
      RSSVCACCOUNT:                  <empty>
      RSSVCPASSWORD:                 <empty>
      RSSVCSTARTUPTYPE:              Automatic
      SAPWD:                         *****
      SECURITYMODE:                  SQL
      SQLBACKUPDIR:                  <empty>
      SQLCOLLATION:                  SQL_Latin1_General_CP1_CI_AS
      SQLSVCACCOUNT:                 NT Service\MSSQL$TESTDB
      SQLSVCPASSWORD:                <empty>
      SQLSVCSTARTUPTYPE:             Automatic
      SQLSYSADMINACCOUNTS:           WIN-1V3VKPV5Q19\Administrator
      SQLTEMPDBDIR:                  <empty>
      SQLTEMPDBLOGDIR:               <empty>
      SQLUSERDBDIR:                  <empty>
      SQLUSERDBLOGDIR:               <empty>
      SQMREPORTING:                  false
      TCPENABLED:                    1
      UIMODE:                        Normal
      UpdateEnabled:                 true
      UpdateSource:                  MU
      X86:                           false
      Configuration file:            C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\20140528_170909\ConfigurationFile.ini
    Detailed results:
      Feature:                       Database Engine Services
      Status:                        Failed: see logs for details
      Reason for failure:            An error occurred during the setup process of the feature.
      Next Step:                     Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
      Component name:                SQL Server Database Engine Services Instance Features
      Component error code:          0x851A001A
      Error description:             Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
      Error help link:               http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=11.0.3128.0&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026&EvtType=0xD15B4EB2%400x4BDAF9BA%401306%4026
      Feature:                       SQL Browser
      Status:                        Passed
      Feature:                       SQL Writer
      Status:                        Passed
      Feature:                       SQL Client Connectivity
      Status:                        Passed
      Feature:                       SQL Client Connectivity SDK
      Status:                        Passed
    Rules with failures:
    Global rules:
    Scenario specific rules:
    Rules report file:               C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\20140528_170909\SystemConfigurationCheck_Report.htm
    (Error Log)
    2014-05-28 17:17:26.64 spid8s      0 transactions rolled back in database 'msdb' (4:0). This is an informational message only. No user action is required.
    2014-05-28 17:17:26.73 spid9s      Starting up database 'model'.
    2014-05-28 17:17:28.24 spid9s      Error: 9004, Severity: 23, State: 6.
    2014-05-28 17:17:28.24 spid9s      An error occurred while processing the log for database 'model'.  If possible, restore from backup. If a backup is not available, it might be necessary to rebuild the log.
    2014-05-28 17:17:28.24 spid9s      SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.
    (Details)
    (01) 2014-05-28 17:17:28 Slp: Exception type: Microsoft.SqlServer.Configuration.SqlEngine.SqlEngineConfigException
    (01) 2014-05-28 17:17:28 Slp:     Message: 
    (01) 2014-05-28 17:17:28 Slp:         Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
    (01) 2014-05-28 17:17:28 Slp:     HResult : 0x851a001a
    (01) 2014-05-28 17:17:28 Slp:         FacilityCode : 1306 (51a)
    (01) 2014-05-28 17:17:28 Slp:         ErrorCode : 26 (001a)
    (01) 2014-05-28 17:17:28 Slp:     Data: 
    (01) 2014-05-28 17:17:28 Slp:       SQL.Setup.FailureCategory = ConfigurationFailure
    (01) 2014-05-28 17:17:28 Slp:       WatsonConfigActionData = INSTALL@CONFIGRC@SQL_ENGINE_CORE_INST
    (01) 2014-05-28 17:17:28 Slp:       WatsonExceptionFeatureIdsActionData = System.String[]
    (01) 2014-05-28 17:17:28 Slp:     Stack: 
    (01) 2014-05-28 17:17:28 Slp:         at Microsoft.SqlServer.Configuration.SqlEngine.SqlServerServiceBase.WaitSqlServerStart(Process processSql)
    (01) 2014-05-28 17:17:28 Slp:         at Microsoft.SqlServer.Configuration.SqlEngine.SqlServerServiceSCM.StartSqlServer(String[] parameters)
    (01) 2014-05-28 17:17:28 Slp:         at Microsoft.SqlServer.Configuration.SqlEngine.SqlEngineDBStartConfig.ConfigSQLServerSystemDatabases(EffectiveProperties properties, Boolean isConfiguringTemplateDBs, Boolean useInstallInputs)
    (01) 2014-05-28 17:17:28 Slp:         at Microsoft.SqlServer.Configuration.SqlEngine.SqlEngineDBStartConfig.DoCommonDBStartConfig(ConfigActionTiming timing)
    (01) 2014-05-28 17:17:28 Slp:         at Microsoft.SqlServer.Configuration.SqlConfigBase.SlpConfigAction.ExecuteAction(String actionId)
    (01) 2014-05-28 17:17:28 Slp:         at Microsoft.SqlServer.Configuration.SqlConfigBase.SlpConfigAction.Execute(String actionId, TextWriter errorStream)
    (01) 2014-05-28 17:17:28 Slp: Watson Bucket 1 
     Original Parameter Values 
    (01) 2014-05-28 17:17:28 Slp: Parameter 0 : SQL Server 2012@RTM@ 
    (01) 2014-05-28 17:17:28 Slp: Parameter 1 : Microsoft.SqlServer.Configuration.SqlEngine.SqlServerServiceBase.WaitSqlServerStart 
    (01) 2014-05-28 17:17:28 Slp: Parameter 2 : Microsoft.SqlServer.Configuration.SqlEngine.SqlServerServiceBase.WaitSqlServerStart 
    (01) 2014-05-28 17:17:28 Slp: Parameter 3 : Microsoft.SqlServer.Configuration.SqlEngine.SqlEngineConfigException@1306@26 
    (01) 2014-05-28 17:17:28 Slp: Parameter 4 : Microsoft.SqlServer.Configuration.SqlEngine.SqlEngineConfigException@1306@26 
    (01) 2014-05-28 17:17:28 Slp: Parameter 5 : SqlEngineDBStartConfigAction_install_configrc 
    (01) 2014-05-28 17:17:28 Slp: Parameter 6 : INSTALL@CONFIGRC@SQL_ENGINE_CORE_INST 
    (01) 2014-05-28 17:17:28 Slp: 
     Final Parameter Values 
    (01) 2014-05-28 17:17:28 Slp: Parameter 0 : SQL Server 2012@RTM@ 
    (01) 2014-05-28 17:17:28 Slp: Parameter 1 : 0xD15B4EB2 
    (01) 2014-05-28 17:17:28 Slp: Parameter 2 : 0xD15B4EB2 
    (01) 2014-05-28 17:17:28 Slp: Parameter 3 : 0x4BDAF9BA@1306@26 
    (01) 2014-05-28 17:17:28 Slp: Parameter 4 : 0x4BDAF9BA@1306@26 
    (01) 2014-05-28 17:17:28 Slp: Parameter 5 : SqlEngineDBStartConfigAction_install_configrc 
    (01) 2014-05-28 17:17:28 Slp: Parameter 6 : 0x9C5770A6 

    Hi Nababoya:
    As you are telling this is a test installation process...
    In the logs i m seeing the error message "An error occurred while processing the log for database 'model'.  If possible, restore from backup. If a backup is not available, it might be necessary to rebuild the log.".
    1) If the SQL Services was installed successfully and SQL Service was not able to start because of model database issue...
        1.1) If you have model database SQL back file, start the SQL Server in single user mode with minimum configuration and try to restore MODEL database
    http://blogs.msdn.com/b/sqlserverfaq/archive/2011/05/11/inf-hey-my-sql-server-service-is-not-starting-what-do-i-do.aspx
        1.2) If you don't have backups., try to rebuild the system databases but make sure that you are not losing any data critical data on master and SQL Jobs on MSDB
    http://msdn.microsoft.com/en-us/library/dd207003%28v=sql.110%29.aspx#RebuildProcedure
    2) As if this is a new installation try to repair the instance with the help of setup media file
    3) If the repair option fails., the last option wipe out the complete SQL Server components from Services.msc and Registries and start new installation.
    4) Make sure when you are doing un-installation all the required SQL Server components on services.msc should be in stop state.
    Hope this helps and let me know any questions...
    Thanks,
    Thanks, Satish Kumar. Please mark as this post as answered if my anser helps you to resolves your issue :)

  • Try to do my first XML Schema in SQL Server 2012 Mangement Studio(SSMS2012)-How to execute the xsd and xml files in SSMS2012?

    Hi all,
    I learmed the basic stuff of XML, DTD, DOM, etc. long time ago. Now, I came back to resume my XML journey and try to learn the XML Schemas, XPath and XQuery. I have Microsoft SQL Server 2012 Management Studio (SSMS2012) in our computer network. From
    Page 221 of the old Book "Beginning XML 2nd Edition" written by David Hunter, et.al., (published by Wrox), I copied the name5.xsd and name5.xml :
    <?xml version="1.0"?>
    <schema xmlns=http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.wrox.com/name" xmlns:target="http://www.wrox.com/name"
    elementFormDefault="qualified">
    <element name="name">
    <complexType>
    <sequence>
    <element name="first" type="string"/>
    <element name="middle" type="string"/>
    <element name="last" type="string"/>
    </sequence>
    </complexType>
    </element>
    </schema>
    <?xml version="1.0"?>
    <name
    xmlns=http://www.wrox.com/name"
    xmlns:xsi="http://www.wrox.org/2001XMLSchema-instance"
    xsi:schemaLocation="http://www.wrox.com/name name5.xsd"
    title="Mr.">
    <first>John</first>
    <middle>Frizgerald</middle>
    <last>Doe</last>
    </name>
    How can I execute these two files in my SSMS2012 for doing my first XML Schema trial?
    Please kindly help, advise and respond.
    Thanks in advance,
    Scott Chang

    Hi Eric Zhang, Thanks for your nice response.
    1) I saw the CREATE XML SCHEMA COLLECTION (Transact-SQL) and tried  its first example "Create XML schema collection in the database" in my SQL Server 2012 Management Studio (SSMS2012):
    -- Create a sample database in which to load the XML schema collection.
    -- Copied this set of code stsments from Microsoft Library (ms176009)
    -- ColesMS12_20a.sql (saved in C:/Documents/SQL Server Management Studio)
    -- 19 March 2015 1145 AM
    CREATE DATABASE SampleDB
    GO
    USE SampleDB
    GO
    CREATE XML SCHEMA COLLECTION ManuInstructionsSchemaCollection AS
    N'<?xml version="1.0" encoding="UTF-16"?>
    <xsd:schema targetNamespace="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
    xmlns ="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
    <xsd:complexType name="StepType" mixed="true" >
    <xsd:choice minOccurs="0" maxOccurs="unbounded" >
    <xsd:element name="tool" type="xsd:string" />
    <xsd:element name="material" type="xsd:string" />
    <xsd:element name="blueprint" type="xsd:string" />
    <xsd:element name="specs" type="xsd:string" />
    <xsd:element name="diag" type="xsd:string" />
    </xsd:choice>
    </xsd:complexType>
    <xsd:element name="root">
    <xsd:complexType mixed="true">
    <xsd:sequence>
    <xsd:element name="Location" minOccurs="1" maxOccurs="unbounded">
    <xsd:complexType mixed="true">
    <xsd:sequence>
    <xsd:element name="step" type="StepType" minOccurs="1" maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="LocationID" type="xsd:integer" use="required"/>
    <xsd:attribute name="SetupHours" type="xsd:decimal" use="optional"/>
    <xsd:attribute name="MachineHours" type="xsd:decimal" use="optional"/>
    <xsd:attribute name="LaborHours" type="xsd:decimal" use="optional"/>
    <xsd:attribute name="LotSize" type="xsd:decimal" use="optional"/>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>' ;
    GO
    -- Verify - list of collections in the database.
    select *
    from sys.xml_schema_collections
    -- Verify - list of namespaces in the database.
    select name
    from sys.xml_schema_namespaces
    -- Use it. Create a typed xml variable. Note collection name specified.
    DECLARE @x xml (ManuInstructionsSchemaCollection)
    GO
    --Or create a typed xml column.
    CREATE TABLE T (
    i int primary key,
    x xml (ManuInstructionsSchemaCollection))
    GO
    -- ////The following code statements are not used in order to create SampleDB
    -- Clean up
    ---DROP TABLE T
    ---GO
    ---DROP XML SCHEMA COLLECTION ManuInstructionsSchemaCollection
    ---Go
    ---USE Master
    ---GO
    ---DROP DATABASE SampleDB
    It worked and I got the following results:
    1 4 NULL sys 2009-04-13 12:59:13.390 2012-02-10 20:16:02.097
    65536 1 NULL ManuInstructionsSchemaCollection 2015-03-19 11:47:17.660 2015-03-19 11:47:17.660
    http://www.w3.org/2001/XMLSchema
    http://schemas.microsoft.com/sqlserver/2004/sqltypes
    http://www.w3.org/XML/1998/namespace
    http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions
    But, I don't undertand (i) what SCHEMA COECTION is, (ii) what <xsd:schema targetNamespace=.....</xsd:complexType> are, (iii) How I can specify my "project specific" schema in the Microsoft SCHEMA COLLECTION to check my xml file.
    2) I dived in the XQuery programmimng in SSMS2012 in the last few weeks. I used the examles of Ad-Hoc XML File Query by Seth Delconte (in
    httpS://www.simple-talk.com/content/print.aspx?article=1756) in my SSMS2012. They worked. But I don't understand the (i) Importing XML data using a function, (ii) Using the XQuery contans()
    function to find substrings, (iii)Efficiency comparisons in the article.
    Please kindly help me in enlightening me to resolve the difficulties listed in 1) and 2).
    Thanks,
    Scott Chang

  • SharePoint 2010 and SQL Server 2012 issue

    Hi,
    I have SharePoint 2010 integrated with SQL Server 2008 R2 in my machine. I wanted to use Power View feature, so I went for SQL Server 2012 installation. Now when I try to create the SQL Server Reporting service service application, it says, this feature
    is not supported by current version of database.
    Please let me know how to fix the issue. Do I need to reinstall SharePoint 2010 once again using SQL Server 2012 ?
    thanks
    Tarique

    http://social.technet.microsoft.com/Forums/sharepoint/en-US/9eacbd00-f264-4f55-bd27-55cf0761cbd7/power-view-is-not-supported-in-this-edition-of-reporting-services?forum=sharepointadmin
    The only requirements for SSRS Integrated mode/PowerView are that you're using SharePoint Enterprise and SQL Enterprise/BI and that SharePoint be installed and joined to the farm on the server where you're also installing SSRS.
    You need to reconfigure your sharepoint farm farm to use SQL server 2012 
    http://technet.microsoft.com/en-us/library/ee210640.aspx
    Business intelligence features are not all available in all editions of SQL Server 2012

  • SQL Server 2012: Import and Export Wizard - Exporting Multiple Result Sets at Once?

    I'm working in SQL Server 2012 trying to export some data from our database into an Excel file. My SQL statement has two separate Select statements. They are not joined by a union. When I Execute them inside of SQL Server Management Studio, with Results
    set to go to a Grid, I get two result sets back. Two full tables of data.
    However, when I use the Import and Export Wizard, the Excel sheet only has the first set of data.
    What do I need to do to have it so both result sets show up in the excel file?

    Why cant use merge them using union/union all if intention is to get them to same sheet? Is it like the metadata is different so that they cant be merged to single sheet?
    If that being the case you need to do it in two steps. 
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • SQL Server 2012 Installed KB2793634 and it completed successfully but display error in the event log

    Hi
    Running SQL Server 2012 with SP1 on Windows 7 x64 SP1
    One of the machines that this is installed displayed that the Windows Installer was starting repeatedly, like every 30 secs
    I installed KB2793634 and everything completed successfully.  No errors in any of the Summary, Detail, etc and all check marks at the end.  I went throught the event viewer and in the application log and saw the following
    Product: SQL Server 2012 Database Engine Services - Update '{4023B523-7241-4B6D-83A4-92105B0A3DC8}' could not be installed. Error code 1642. Windows Installer can create logs to help troubleshoot issues with installing software packages. Use the
    following link for instructions on turning on logging support:
    Is this something with the KB.  How do I find what the issue is and what do I do to fix it? Or is this a real error?
    I brought up SQL Server and the issue that the KB resolves seems to been resolved.  I can connect to the instance just fine, the version of the KB has been applied to the instance so now it is at 11.0.3128
    Any information will be greatly appreciated.

    Hi,
    According to the description, I know the patch that was successfully installed after the msiinstaller error.
    1. Per
    KB304888 and mentioned the possibility that the hotfix was launched a second time after the initial successful update.
    I suspect if you have installed any hotfixes or Cumulative updates after installing Service Pack 1 for SQL Server 2012.
    Reference:
    http://support.microsoft.com/kb/2793634
    2. Check the application log. Is the error happening intermittently?
    Thanks.
    Tracy Cai
    TechNet Community Support

  • SQL Server 2012 express istallation failing to install "Database Engine Service" and "SQL Server Replication"

    I ran SQL Server 2012 express setup as user with administrator privileges and still it's failing to install "Database Engine Service" and "SQL Server Replication".
    Any and every ideas on how to resolve this issue is greatly appreciated.

    Three weeks passed and I am yet to find a fix for the the failed installation of the database engine on sql server 2012 express installation. I have tried various work-around including uninstalling, deleting all the directory paths, and reinstallation. Still
    not able to successfully install sql server 2012 express.
    I will greatly appreciate any and every contribution towards resolving this issue. Thanks in advance.
    Here is the content of log file after the latest failed installation:
    Overall summary:
      Final result:                  Failed: see details below
      Exit code (Decimal):           -2061893607
      Start time:                    2013-12-23 14:42:45
      End time:                      2013-12-23 15:07:51
      Requested action:              Install
    Setup completed with required actions for features.
    Troubleshooting information for those features:
      Next step for SQLEngine:       Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
      Next step for Replication:     Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
    Machine Properties:
      Machine name:                  mymachine1
      Machine processor count:       4
      OS version:                    Windows 7
      OS service pack:               Service Pack 1
      OS region:                     United States
      OS language:                   English (United States)
      OS architecture:               x86
      Process architecture:          32 Bit
      OS clustered:                  No
    Product features discovered:
      Product              Instance             Instance ID                   
    Feature                                  Language            
    Edition              Version         Clustered
      SQL Server 2012      SQLEXPRESS_GT        MSSQL11.SQLEXPRESS_GT          Database Engine Services                
    1033                 Express Edition      11.0.2100.60    No        
      SQL Server 2012      SQLEXPRESS_GT        MSSQL11.SQLEXPRESS_GT          SQL Server Replication                  
    1033                 Express Edition      11.0.2100.60    No        
      SQL Server 2012                                                         
    Management Tools - Basic                 1033                 Express Edition     
    11.0.2100.60    No        
    Package properties:
      Description:                   Microsoft SQL Server 2012 Service Pack 1
      ProductName:                   SQL Server 2012
      Type:                          RTM
      Version:                       11
      Installation location:         C:\9b6607e524727c7fe1defd80\x86\setup\
      Installation edition:          Express
      Slipstream:                    True
      SP Level                       1
    Product Update Status:
      Success: KB 2674319
    Product Updates Selected for Installation:
      Title:                         Service Pack 1
      Knowledge Based Article:       KB 2674319
      Version:                       11.1.3000.0
      Architecture:                  x86
      Language:                      1033
      Update Source:                 MU
    User Input Settings:
      ACTION:                        Install
      ADDCURRENTUSERASSQLADMIN:      true
      AGTSVCACCOUNT:                 NT AUTHORITY\NETWORK SERVICE
      AGTSVCPASSWORD:                *****
      AGTSVCSTARTUPTYPE:             Disabled
      ASBACKUPDIR:                   Backup
      ASCOLLATION:                   Latin1_General_CI_AS
      ASCONFIGDIR:                   Config
      ASDATADIR:                     Data
      ASLOGDIR:                      Log
      ASPROVIDERMSOLAP:              1
      ASSERVERMODE:                  MULTIDIMENSIONAL
      ASSVCACCOUNT:                  <empty>
      ASSVCPASSWORD:                 <empty>
      ASSVCSTARTUPTYPE:              Automatic
      ASSYSADMINACCOUNTS:            <empty>
      ASTEMPDIR:                     Temp
      BROWSERSVCSTARTUPTYPE:         Disabled
      CLTCTLRNAME:                   <empty>
      CLTRESULTDIR:                  <empty>
      CLTSTARTUPTYPE:                0
      CLTSVCACCOUNT:                 <empty>
      CLTSVCPASSWORD:                <empty>
      CLTWORKINGDIR:                 <empty>
      COMMFABRICENCRYPTION:          0
      COMMFABRICNETWORKLEVEL:        0
      COMMFABRICPORT:                0
      CONFIGURATIONFILE:             
      CTLRSTARTUPTYPE:               0
      CTLRSVCACCOUNT:                <empty>
      CTLRSVCPASSWORD:               <empty>
      CTLRUSERS:                     <empty>
      ENABLERANU:                    true
      ENU:                           true
      ERRORREPORTING:                false
      FEATURES:                      SQLENGINE, REPLICATION, CONN, BC, SDK, ADV_SSMS, SNAC_SDK
      FILESTREAMLEVEL:               0
      FILESTREAMSHARENAME:           <empty>
      FTSVCACCOUNT:                  <empty>
      FTSVCPASSWORD:                 <empty>
      HELP:                          false
      IACCEPTSQLSERVERLICENSETERMS:  true
      INDICATEPROGRESS:              false
      INSTALLSHAREDDIR:              c:\Program Files\Microsoft SQL Server\
      INSTALLSHAREDWOWDIR:           <empty>
      INSTALLSQLDATADIR:             <empty>
      INSTANCEDIR:                   C:\Program Files\Microsoft SQL Server\
      INSTANCEID:                    SQLEXPRESS
      INSTANCENAME:                  SQLEXPRESS
      ISSVCACCOUNT:                  NT AUTHORITY\Network Service
      ISSVCPASSWORD:                 <empty>
      ISSVCSTARTUPTYPE:              Automatic
      MATRIXCMBRICKCOMMPORT:         0
      MATRIXCMSERVERNAME:            <empty>
      MATRIXNAME:                    <empty>
      NPENABLED:                     0
      PID:                           *****
      QUIET:                         false
      QUIETSIMPLE:                   false
      ROLE:                          <empty>
      RSINSTALLMODE:                 DefaultNativeMode
      RSSHPINSTALLMODE:              DefaultSharePointMode
      RSSVCACCOUNT:                  <empty>
      RSSVCPASSWORD:                 <empty>
      RSSVCSTARTUPTYPE:              Automatic
      SAPWD:                         <empty>
      SECURITYMODE:                  <empty>
      SQLBACKUPDIR:                  <empty>
      SQLCOLLATION:                  SQL_Latin1_General_CP1_CI_AS
      SQLSVCACCOUNT:                 NT Service\MSSQL$SQLEXPRESS
      SQLSVCPASSWORD:                <empty>
      SQLSVCSTARTUPTYPE:             Manual
      SQLSYSADMINACCOUNTS:           MH\gt038676t
      SQLTEMPDBDIR:                  <empty>
      SQLTEMPDBLOGDIR:               <empty>
      SQLUSERDBDIR:                  <empty>
      SQLUSERDBLOGDIR:               <empty>
      SQMREPORTING:                  false
      TCPENABLED:                    0
      UIMODE:                        AutoAdvance
      UpdateEnabled:                 true
      UpdateSource:                  MU
      X86:                           false
      Configuration file:            C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\20131223_144132\ConfigurationFile.ini
    Detailed results:
      Feature:                       Management Tools - Complete
      Status:                        Passed
      Feature:                       Client Tools Connectivity
      Status:                        Passed
      Feature:                       Client Tools SDK
      Status:                        Passed
      Feature:                       Client Tools Backwards Compatibility
      Status:                        Passed
      Feature:                       Management Tools - Basic
      Status:                        Passed
      Feature:                       Database Engine Services
      Status:                        Failed: see logs for details
      Reason for failure:            An error occurred during the setup process of the feature.
      Next Step:                     Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
      Component name:                SQL Server Database Engine Services Instance Features
      Component error code:          0x851A0019
      Error description:             Could not find the Database Engine startup handle.
      Error help link:               http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=11.0.3000.0&EvtType=0xE53883A0%400xBE03358B%401306%4025&EvtType=0xE53883A0%400xBE03358B%401306%4025
      Feature:                       SQL Server Replication
      Status:                        Failed: see logs for details
      Reason for failure:            An error occurred for a dependency of the feature causing the setup process for the feature to fail.
      Next Step:                     Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
      Component name:                SQL Server Database Engine Services Instance Features
      Component error code:          0x851A0019
      Error description:             Could not find the Database Engine startup handle.
      Error help link:               http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=11.0.3000.0&EvtType=0xE53883A0%400xBE03358B%401306%4025&EvtType=0xE53883A0%400xBE03358B%401306%4025
      Feature:                       SQL Browser
      Status:                        Passed
      Feature:                       SQL Writer
      Status:                        Passed
      Feature:                       SQL Client Connectivity
      Status:                        Passed
      Feature:                       SQL Client Connectivity SDK
      Status:                        Passed
    Rules with failures:
    Global rules:
    Scenario specific rules:
    Rules report file:               C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\20131223_144132\SystemConfigurationCheck_Report.htm

  • SQL Server 2012 Management Studio: Creating a Database and a dbo Table. Inserting VALUES into the table. How to insert 8 Values for future use in XQuery?

    Hi all,
    In my SQL Server 2012 Management Studio (SSMS2012), I tried to create a Database (MacLochainnsDB) and a dbo Table (marvel). then I wanted insert 8 VALUES into the Table by using the following code:
    USE master
    IF EXISTS
    (SELECT 1
    FROM sys.databases
    WHERE name = 'MacLochlainnsDB')
    DROP DATABASE MacLochlainnsDB
    GO
    CREATE DATABASE MacLochlainnsDB
    GO
    CREATE TABLE [dbo].[marvel] (
    [avenger_name] [char] (30) NULL)
    INSERT INTO marvel
    (avenger_name)
    VALUES
    ('Hulk', 1),
    ('Iron Man', 2),
    ('Black Widow', 3),
    ('Thor', 4),
    ('Captain America', 5),
    ('Hawkeye', 6),
    ('Winter Soldier', 7),
    ('Iron Patriot', 8)
    I got the following error Message:
    Msg 110, Level 15, State 1, Line 5
    There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
    How can I correct this problem?
    Please kindly help and advise.
    Thanks in advance,
    Scott Chang
    P. S.
    The reason I tried to create the Database, dbo Table, and then to insert the VALUES is to learn the following thing:
    You can query the entire node tree with the following xquery statement because it looks for the occurrence of any node with the /* search string:
    DECLARE @x xml;
    SET @x = N'<marvel>
    <avenger_name>Captain America</avenger_name>
    </marvel>';
    SELECT @x.query('/*');
    You can query the avenger_name elements from the marvel_xml table with the following syntax:
    SELECT xml_table.query('/marvel/avenger_name')
    FROM marvel_xml;
    It returns the following set of avenger_name elements:
    <avenger_name>Hulk</avenger_name>
    <avenger_name>Iron Man</avenger_name>
    <avenger_name>Black Widow</avenger_name>
    <avenger_name>Thor</avenger_name>
    <avenger_name>Captain America</avenger_name>
    <avenger_name>Hawkeye</avenger_name>
    <avenger_name>Winter Soldier</avenger_name>
    <avenger_name>Iron Patriot</avenger_name>
    You can query the fourth avenger_name element from the marvel_xml table with the following xquery statement:
    SELECT xml_table.query('/marvel[4]/avenger_name')
    FROM marvel_xml;
    It returns the following avenger_name element:
    <avenger_name>Thor</avenger_name>

    Hi Scott,
    The master database records all the system-level information for a SQL Server system, so best practise would be not to create any user-defined
    object within it.
    To change your default database(master by default) of your login to another, follow the next steps so that next time when connected you don't have to use "USE dbname" to switch database.
    Open SQL Server Management Studio
    --> Go to Object explorer(the left panel by default layout)
    --> Extend "Security"
    --> Extend "Logins"
    --> Right click on your login, click "propertites"
    --> Choose the "Default database" at the bottom of the pop-up window.
    --or simply by T-SQL
    Exec sp_defaultdb @loginame='yourLogin', @defdb='youDB'
    Regarding your question, you can reference the below.
    SELECT * FROM master.sys.all_objects where name ='Marvel'
    --OR
    SELECT OBJECT_ID('master.dbo.Marvel') --if non empty result returns, the object exists
    --usually the OBJECT_ID is used if a if statement as below
    IF OBJECT_ID('master.dbo.Marvel') IS NOT NULL
    PRINT ('TABLE EXISTS') --Or some other logic
    What is the sys.all_objects? See
    here.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

Maybe you are looking for

  • How much RAM should I get in my FIRST Macbook Pro?

    Finally ready to pick up my first Macbook.  I've been a Windows junkie until now.  I have iPads, iPhones, iPods, etc and now it's time to go all in.  My question is RAM.  I've already decided to go with the Macbook Pro with the Retina display but I'm

  • Hi. how does one make sure photos have been uploaded to I cloud

    trying to update to IOS 8 on my iphone 4s from IOS 7.1.2. cannot due to storage requirements. asking me to delete items. what should I do?  most are photos  how do I make sure they are now in cloud and can be safely deleted from phone storage.

  • Safari web process - memory leak?

    Mac Pro seemed to have slowed to a crawl. Safari 5.1.2 on SL 10.6.8 Activity Monitor showed I was low on memory - over 7GB was being used by 'safari web process' - slowly close all open pages until only left with two - one was simply the 'bing' home

  • Before posting in MB01

    I want to add the exception to prevent the inspection lot creation for good receipt of materials from third party purchase orders. I wan to find a userexit, or enhancement point where I can add this exception. Thanks in advance. Banu

  • Daylight Time Saving - SQL Server 2008 Mirroring

    Dear SQL Forum Group Members, 1) Could anyone clarify me, will there be any issues in SQL server 2008 Mirroring because of Daylight Time saving ?? Also, will there be any impact on Tlog backup scheduled jobs which will be running in 15 Minutes interv