Wednesday, April 17, 2013

[SQL server issues] Created Issue: AdventureWorksDW2012 Download file corrupt [19063]

There seams to be an issue with the AdventureWorksDW2012 Data file download. When I try to run this SQL statement:

CREATE DATABASE AdventureWorksDW2012 ON (FILENAME = 'E:\MSSQL11.SQL02\MSSQL\DATA\AdventureWorksDW2012_Data.mdf') FOR ATTACH_REBUILD_LOG;

This is the error I get:

Msg 5172, Level 16, State 15, Line 1
The header for file 'E:\MSSQL11.SQL02\MSSQL\DATA\AdventureWorksDW2012_Data.mdf' is not a valid database file header. The FILE SIZE property is incorrect.

Thanks,Dan

There seams to be an issue with the AdventureWorksDW2012 Data file download. When I try to run this SQL statement:

CREATE DATABASE AdventureWorksDW2012 ON (FILENAME = 'E:\MSSQL11.SQL02\MSSQL\DATA\AdventureWorksDW2012_Data.mdf') FOR ATTACH_REBUILD_LOG;

This is the error I get:

Msg 5172, Level 16, State 15, Line 1
The header for file 'E:\MSSQL11.SQL02\MSSQL\DATA\AdventureWorksDW2012_Data.mdf' is not a valid database file header. The FILE SIZE property is incorrect.

Thanks,Dan


.

sqlserversamples.codeplex.com

[SQL Server Data Warehousing] How would my fact and dim tables look like in this example?


Please bear with me.


This is a very simplified example, but it's more or less the foundation.


We get hourly data for several cells, for example ORLFL-1-123-1. This cell is a combination of AREA-CAB-SITE-SECTOR.


Data analysts want to get several KPIs from all the data coming from these cells, but by AREA, CAB, SITE, SECTOR (not cell). And the smallest date range is daily (daily, weekly, monthly, etc).


Let's say the KPIs are KPI_ABC, KPI_NDO, KPI_DRT, KPI_QRR.


I have DimDate, DimSite, DimArea, DimCab, DimSector. I assume that's correct.


My question are the Fact tables. I was thinking of creating one Fact table for each KPI (FactKPI_ABC, FactKPI_NDO, etc). Each Fact table would have the total per site per day, plus the attributes for the site. For example the fields for FactKPI_ABC would be:



Datekey
Site
KPI_ABC
Area
Cab
Site
Sector

The problem I see (if it's a problem) is that all the tables would be exactly the same, since the only value that changes is the actual KPI total.


Is this the correct way to go? Any help is greatly appreciated.


Thanks.




VM



.

social.technet.microsoft.com/Forums

[Articles] The Patch Wild, Wild West

[Articles] The Patch Wild, Wild West


The Patch Wild, Wild West

Posted: 16 Apr 2013 11:00 PM PDT

Microsoft might be changing their patching process for applications. This has Steve Jones worried they may move towards an Apple/iOS like model, which would not be good for server systems.

[MS SQL Server] Moving server to different zone in Datacenter

[MS SQL Server] Moving server to different zone in Datacenter


Moving server to different zone in Datacenter

Posted: 16 Apr 2013 11:38 AM PDT

I am involved in moving some servers to different zone within the same data-center. There are no IP changes, so I would think this is the same as normal server shutdown. The server will be out for more than 24 hours.In terms of DBA perspective, I was thinking about stopping the SQL services before they shutdown windows box, and start the SQL services after server up and running.Anyone have any other suggestions? Also, from app server side, do they need to be shutdown as well? If you had similar experience, or if you know the actual steps, please share.Thanks in advance,SueTons.

Data Warehouse Backup Strategy

Posted: 17 Apr 2013 02:21 AM PDT

We're migrating from SQL server 2000 to 2008 and I'm trying to come up with a backup strategy for our data warehouse on the new servers. I'm particularly focused on one DB that is most frequently used. I want to minimize the size of the backup file(s) and the impact that the backup has on the servers. Here is the background info:- We're a relatively small shop and so have limited resources (time). No dedicated full time DBA.- We currently load 100+ flat files each night to 100 + SQL tables. We're talking about 60-75 GB of data for these files/tables. We don't have access to only the changed records from the source systems, so the tables are dropped and re-created during each nightly load.-We also have numerous tables that persist – typically these are tables where the data files from the source system are so large they can't possibly be dropped/created each night. Instead, we extract a subset from the source system and insert/update the persistent tables. These tables account for about 150 GB.- The remaining tables in the DB take up another 100 GB. It's a mixed bag here in terms of availability requirements – some are important (in the event of failure, restore would need to be within 24 hours) others could wait a week or more.- In the current SQL 2000 environment, using a simple backup model, the backup is about 350GB uncompressed. This goes nightly to a SAN, and from there to tape offsite.For a multitude of reasons, we're not performing an all-at-once migration, so we'll have one SQL2K and two SQL2008 servers running simultaneously. If we took the overall same approach as we did in the past, that would amount to about 1.25 TB of backups…not desirable! Especially since much of the data is dropped/recreated.Aside from utilizing compression software (considering Redgate SQL Backup Pro), are there other ways to reduce backup overhead (processing resources and storage resources)? I thought perhaps we might do file backups with the persistent tables on primary, then the drop/load tables on secondary file(s), but it doesn't seem you can (safely/reliably) restore only some of the file groups. I've seen 'undocumented' ways of doing that, but I like to sleep at night…I thought about truncating the tables each night before the backup, but that will require significant redesign of existing processes in terms of timing etc. and resources are tight. I could do this with some of the largest tables that we drop/reload, but we also have some larger tables that we don't drop/recreate each night. That means this approach will help a bit.Any ideas that don't involve a complete redesign of the DB? If I had unlimited time and energy, I can see where separate DBs would be best (and not just for the backup strategy), but that's not practical for us.Also, This is my first post...so suggestions on etiquette/process are greatly appreciated.

CU installed or not?

Posted: 16 Apr 2013 05:55 AM PDT

We single node cluster running SQL 2008 R2 SP2. We noticed the Application Even Log contianing thousands of messages likeInformation DateTime SQLAgent$Name 53 Failover "[sqagtres] LooksAlive request."Information DateTime SQLAgent$Name 53 Failover "[sqagtres] CheckServiceAlive: returning TRUE (success)" I found [url=http://support.microsoft.com/kb/2718920]KB2718920[/url] which recomends installing Cunulative Update 3 for SQL 2008 R2 SP2. The Install reports that it failed. But when I restarted SQL serivce, it went into script update mode, and minutes later came online and reports that it is now version 10.50.4266.0. The end of the summary.txt file contains the following 2013-04-16 06:56:17 Slp: Attempting to run patch request for instance: MSSQLSERVER2013-04-16 07:11:30 Slp: Error: Failed to run patch request for instance: MSSQLSERVER (exit code: -595541211)2013-04-16 07:11:41 Slp: Error result: -5955412112013-04-16 07:11:41 Slp: Result facility code: 11522013-04-16 07:11:41 Slp: Result error code: 49957Much earlier in the file...2013-04-16 06:52:44 Slp: Package ID sql_fulltext_ctp6_Cpu64: Discovery: Package version data are " Installed Version: 10.52.4000.0 MinVersion: 10.0.1400 MaxVersion: 10.50.1599.1"2013-04-16 06:52:44 Slp: Package ID sql_fulltext_ctp6_Cpu64: Discovery: Package version data are " Installed Version: 10.52.4000.0 MinVersion: 10.0.1400 MaxVersion: 10.50.1599.1".....013-04-16 06:52:51 Slp: Patch Id KB2754552_sql_engine_core_shared_Cpu64 - NotInstalled on the baseline msi package sql_engine_core_shared_Cpu64. Detail description of this patch package is: PatchId=KB2754552_sql_engine_core_shared_Cpu64 PatchVersion=10.52.4266.0 BaselinePackageId=sql_engine_core_shared_Cpu64 BaselineVersion=10.52.4000.0; PatchFileName=sql_engine_core_shared.msp PatchCode={A9F26DCE-10E2-4224-AC5F-2F78F1321DDD}2013-04-16 06:52:51 Slp: Patch Id: KB2754552_sql_as_Cpu64 - The baseline msi is not installed. The patch package is ignored.There seems to be a mismatch between the version of SQL installed and the version this installer was expecting, though I checked the links and the files I downloaded should be correct. Is anyone not confused by this? And is the instance I tried to install to trustworthy?

Why powershell?

Posted: 16 Apr 2013 09:01 PM PDT

Hi all experts,I have being reading about Powershell a lot this days. What i came to know about powershell is that , it is a powerfull tool to automate the daily process which a DBA usually Do.But when we do have Sp's running through Job , to do the same task, then why do we need PowerShell. Is this a redundant functionality given by SQL Server. Or am i missing the purpose of PowerShell?

Report Services / Upgrade from Standard to Enterprise

Posted: 16 Apr 2013 05:36 AM PDT

Hello - I am trying to do a an upgrade from Standard to Enterprise using the SQL Server Installation center (Maintenance | Edition upgrade)During setup I get the following error: "The service cannot be started, either because it is disabled or because it has no enabled devices associated with it."The summary file (shown in C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20130416_141115) shows it fails when it gets to report services.I followed the steps to remover report services http://msdn.microsoft.com/en-us/library/ms143518(v=sql.90).aspxStill, same error - I then tried installing Report Services to make it happy - but the setup thinks report services is still there. Any advice on either installing it or getting rid of Report Services so I can upgrade would be appreciated.Thanks in advance Dave

[SQL 2012] New Relic - realtime application monitoring software

[SQL 2012] New Relic - realtime application monitoring software


New Relic - realtime application monitoring software

Posted: 17 Apr 2013 03:27 AM PDT

Hi -We're using New Relic to monitor our application along with application servers. The application provides extensive realtime monitoring and it is quite nice.It provides in depth analysis for both applications and application stored procedures.Has anyone in the SQL community actually installed the agent on a production SQL Server?Thanks in advance.

Alway on error

Posted: 17 Apr 2013 01:22 AM PDT

Hi All,I am getting below error in SQL Server errorlog.Timeout occurred while waiting for latch: class 'HADR_BACKUP_LOCK_RESQUEUE_TABLE'.Thanks,Praful

Tabular - aggregate data in the fact table?

Posted: 17 Apr 2013 01:51 AM PDT

HelloI'm currently designing a new tabular model which contains sales data. The sales data is received at a low level hierarchically speaking (Day, Store, SKU). The reports for this dataset however are not required at such a low level. The requirement is to view the data by month, county and product group. Should I aggregate the data in the fact table to month, county and product (using a view or a SQL statement) or should I allow tabular to use the hierarchies in the warehouse to aggregate the data? Any advice would be appreciated.

Do you need Visual Studio for 2012 SSMS?

Posted: 16 Apr 2013 07:10 AM PDT

Everyone on my team has Visual Studio 2010 installed on their computers. We just upgraded from SQL Server 2005 to 2012. I have a couple of other users that only need SQL Server Studio Manager for 2012. The 2005 version they have does not work with our upgrade.Do they need Visual Studio installed in order to use it? That seems like a lot of overhead just to view a table or create a query. But someone is instisting they do. I just wanted to know before I did the install.Thanks.

[SQL Server Data Warehousing] Forms templates for documenting DW analysis & design, + naming conventions


you need to check some structural principles like how they implemented Slowly Changing Dimension, Incremental Load, Late Arriving Fact tables ... and any other challenge-able parts of data warehouses. you will get some good ideas about how these concepts should be considered after reading Kimball books (the Data Warehouse toolkit , and ETL book)


for naming conventions, there are some naming conventions that you might find by googling. for example this is good naming convention for SSIS:


http://consultingblogs.emc.com/jamiethomson/archive/2006/01/05/SSIS_3A00_-Suggested-Best-Practices-and-naming-conventions.aspx


and for SSAS:


http://cwebbbi.wordpress.com/2010/04/07/naming-objects-in-analysis-services/



http://www.rad.pasfu.com



.

social.technet.microsoft.com/Forums

[T-SQL] Show Results When more than just my result shows up.

[T-SQL] Show Results When more than just my result shows up.


Show Results When more than just my result shows up.

Posted: 17 Apr 2013 01:06 AM PDT

Hey Guys, I'm trying to Show All location changes in our system in the last 5 days, now all active items are stored in a table called OITM and when updated the last iteration of the item is stored in a table called AITM however this can be any change to the product, not just a location change. Which means that I can have the same location show up multiple times. The second issue is that the update date is stored on the actual item and the previous update then moves to AITM however if there are 2 changes during this period I would like them all to show up as well. Here is a [url=http://sqlfiddle.com/#!3/22869/1] SQL FIDDLE[/url] of what I have so far, otherwise I will show the tables below:[code="sql"] CREATE TABLE AITM ([ItemCode] varchar(9), [FrgnName] varchar(11), [UpdateDate] datetime, [LogInstanc] int); INSERT INTO AITM ([ItemCode], [FrgnName], [UpdateDate], [LogInstanc])VALUES ('1513360GD', 'STACK-105', '2012-12-30 00:00:00', 1), ('1513360GD', 'STACK-105', '2013-04-12 00:00:00', 2), ('SEW-3035', NULL, '2013-03-21 00:00:00', 1), ('SEW-3035', NULL, '2013-04-13 00:00:00', 2), ('SEW-3035', 'D-34-35-B-M', '2013-04-14 00:00:00', 3), ('SEW-3035', 'b-13-b', '2013-04-15 00:00:00', 4), ('SEW-3035', 'B-13-B', '2013-04-15 00:00:00', 5);CREATE TABLE OITM ([ItemCode] varchar(9), [FrgnName] varchar(6), [UpdateDate] datetime, [LogInstanc] int); INSERT INTO OITM ([ItemCode], [FrgnName], [UpdateDate], [LogInstanc])VALUES ('1513360GD', 'FW-66', '2013-04-15 00:00:00', 0), ('SEW-3035', 'B-13-B', '2013-04-16 00:00:00', 0); [/code]And here is my current code:[code="sql"]SELECT DISTINCT T0.ItemCode, T1.FrgnName as [From Location], T0.FrgnName as [To Location], T0.UpdateDateFROM OITM T0 Left JOIN (Select ItemCode, FrgnName, UpdateDate From AITM A Where LogInstanc in (Select Max(LogInstanc) From AITM B Where A.ItemCode = B.ItemCode) Group By ItemCode, FrgnName, UpdateDate) as T1 ON T0.ItemCode = T1.ItemCode WHERE ISNULL(T0.FrgnName, 0) <> ISNULL(T1.FrgnName, 0)Group By T0.ItemCode, T1.FrgnName, T0.FrgnName, T0.UpdateDateHaving Max(T0.UpdateDate) > GETDATE()-4ORDER BY 4, 1[/code]The results now show like this:[code="other"]ITEMCODE FROM LOCATION TO LOCATION UPDATEDATE1513360GD STACK-105 FW-66 April, 15 2013 00:00:00+0000[/code]I would like the results to show all changes within that period only if the location changed as such:[code="other"]ITEMCODE FROM LOCATION TO LOCATION UPDATEDATE1513360GD STACK-105 FW-66 April, 15 2013 00:00:00+0000SEW-3035 NULL D-34-35-B-M April, 13 2013 00:00:00+0000SEW-3035 D-34-35-B-M B-13-B April, 14 2013 00:00:00+0000[/code]

Stored Procedure execution with parameters

Posted: 16 Apr 2013 10:24 PM PDT

While checking our production plan cache, I noticed that over half of the entries were like the following:exec mt_amstask7 'AMS','78609072','1045458320','20130417 05:05','AMH','20130417 05:07','U'exec mt_amstask7 'AMS','78609072','1045458304','20130417 05:05','AMH','20130417 05:07','U'exec mt_amstask7 'AMS','78609072','1045458320','20130417 05:05','AMH','20130417 05:06','U'etc.Of the 20,563 cached plans, 11,449 were of this type. It is obvious to me that the only difference is the value(s) of the parameters.My question: Is it possible to execute a stored procedure with parameters using sp_executesql? I haven't been able to make this work. I've tried this:DECLARE @SQL NVARCHAR(2048);DECLARE @SQLParms NVARCHAR(2048);DECLARE @SQLParm1 INT;DECLARE @Parm1 INT;DECLARE @SQLParm2 VARCHAR(10);DECLARE @Parm2 VARCHAR(10);DECLARE @SQLParm3 DATETIME;DECLARE @Parm3 DATETIME;SET @Parm1 = 1;SET @Parm2 = 'ABC';SET @Parm3 = '1958-11-14 04:25';SET @SQL = N'TestProc @SQLParm1=@Parm1,@SQLParm2=@Parm2,@SQLParm3=@Parm3;';EXECUTE sys.sp_executesql @SQL,@SQLParms,@SQLParm1,@SQLParm2,@SQLParm3;Msg 137, Level 15, State 2, Line 1Must declare the scalar variable "@Parm1".I'm thinking the DECLAREd parameters are out of scope for the execution.Any help would be appreciated.~ Jeff

How do I use group by on one column which is having many entries?

Posted: 16 Apr 2013 08:34 PM PDT

Hi,I want to use group by on one column which is having many entriestable_a Name price AAA 12 BBB 13 AAA 0 CCC 24 AAA 0 DDD 0Now I want to find out `Name` which is having `Price` as `0`but as I'm having entries `AAA` 3 times I can't directly write simple sql with condition `NOT Equal to 0`Please help me I want to print result for above table_a should beonly `D` as it is having `0` as `price`.

Compare date?

Posted: 16 Apr 2013 04:03 PM PDT

Hi All,Is it possible to copare dete in format 10:30 AM.for example i want to find out the date which is in between 10:30 AM to 11:30 AM.Thanks

loading massive files

Posted: 16 Apr 2013 06:57 AM PDT

I'm loading server large data files into a db. Some records in some table have carrage returns in the data which is acting like an end of line for the import process. does anyone know a way around this? i'm using bcp

Help with SQL code

Posted: 16 Apr 2013 05:13 AM PDT

Hello,I have my data in the below format but this is just a sample(but I am looking at data for the last 6 months):CCDATA ||||CCDATAcompletedTIme54 ||||2013-04-16 13:56:0052 ||||2013-04-16 13:55:0017 ||||2013-04-16 13:55:0011 ||||2013-04-16 13:55:0036 ||||2013-04-16 13:55:0073 ||||2013-04-16 13:55:0080 ||||2013-04-16 13:55:0047 ||||2013-04-16 13:55:0022 ||||2013-04-16 13:55:00235 ||||2013-04-16 13:55:0049 ||||2013-04-16 13:55:0016 ||||2013-04-16 13:55:0034 ||||2013-04-16 13:55:0072 ||||2013-04-16 13:55:0043 ||||2013-04-16 13:55:0050 ||||2013-04-16 13:55:001 ||||2013-04-16 13:55:0064 ||||2013-04-16 13:55:0081 ||||2013-04-15 13:54:0014 ||||2013-04-15 13:54:00103 ||||2013-04-15 13:54:0093 ||||2013-04-15 13:54:0031 ||||2013-04-15 13:54:001022 ||||2013-04-15 13:54:0020 ||||2013-04-15 13:54:0064 ||||2013-04-15 13:54:00142 ||||2013-04-14 13:53:0026 ||||2013-04-14 13:53:0023 ||||2013-04-14 13:53:009 ||||2013-04-14 13:53:0032 ||||2013-04-14 13:53:00991 ||||2013-04-14 13:53:0024 ||||2013-04-14 13:53:00123 ||||2013-04-14 13:53:0026 ||||2013-04-14 13:52:00113 ||||2013-04-13 13:51:0014 ||||2013-04-13 13:51:0066 ||||2013-04-13 13:51:0083 ||||2013-04-13 13:51:0027 ||||2013-04-13 13:51:0023 ||||2013-04-13 13:51:0040 ||||2013-04-13 13:51:0031 ||||2013-04-12 13:51:001 ||||2013-04-12 13:49:0066 ||||2013-04-12 13:48:0033 ||||2013-04-12 13:45:0049 ||||2013-04-12 13:45:0018 ||||2013-04-12 13:45:00133 ||||2013-04-12 13:45:0033 ||||2013-04-11 13:45:00I need to convert it to the following format:WEEK_Number ||MOnday_Averages||Tuesday_Averages||Wednesday_Averages||Thursday_Averages||Friday_Averages||Saturday_Averages||Sunday_AveragesIs this possible?Thanks for your help in advance

Help to get record for MAX REV ID

Posted: 16 Apr 2013 06:07 AM PDT

Hi friends,I ave 3 tables-1) JP,2) WO, the JP and WO are rellated by column : JP IDNow the problem Im facing is that a JP can have mutiple WOs example-JP1234 , WO67,WO69 and each WO has a revision # - say REV#1, and REV#2 and per my business requirement I want to get the WO with the highest REV# FROM JP -when I join these tables but that is not happening-below is the Left Inner Join I'm using---FROM JP-join on [WO] with [JP] left outer join [WorkForce_WorkOrder] on [JP].[JP_ID] = [WO].[JP_JP]THANKSdHANANJAY

Store proc Help

Posted: 16 Apr 2013 05:19 AM PDT

Hi, I have written a procedure to update and Insert data by checking row by row. Unfortunately the query updating the records but not inserting the new data. Could you please help to modify the query.I have to update and Insert the data.-------------------------------------------------------------------ALTER PROCEDURE [dbo].[InsUpd_AppId]AS BEGINDECLARE @MaxRow INTDECLARE @Count INTDECLARE @ServerName NVARCHAR(510)DECLARE @AppCount INTDECLARE @ACount INTDECLARE @ApplicationId NVARCHAR(510)SET @MaxRow =( SELECT MAX(ID) FROM dbo.LUT2013 )SET @Count = 1WHILE (@Count <= @MaxRow)BEGIN SELECT @ServerName = [SERVER NAME] ,@ApplicationId = [Application ID] FROM dbo.LUT2013 WHERE LUT2013.Id = @Count IF EXISTS(SELECT 1 FROM dbo.ApServer WHERE [ServerName] = @ServerName AND @ApplicationId IS NULL) BEGIN SELECT ID = IDENTITY(INT,1,1),* INTO #temp FROM ApServer WHERE [ServerName] = @ServerName SELECT @AppCount = (SELECT MAX(tmp.ID) FROM #temp tmp) SET @ACount = 1 WHILE(@ACount <= @AppCount) BEGIN IF(@ACount = @AppCount) BEGIN UPDATE LUT2013 SET LUT2013.[Application ID] = tmp.[Application ID] FROM LUT2013 INNER JOIN #temp tmp ON tmp.[ServerName] = LUT2013.[Server Name] AND tmp.ID = @AppCount AND LUT2013.[Application ID] IS NULL END ELSE BEGIN INSERT LUT2013([Server Name] ,[Application ID] ) SELECT [ServerName] ,[Application ID] FROM #temp WHERE ID = @ACount END SET @ACount = @ACount + 1 DROP TABLE #temp END END --To iterate while Loop SET @Count = @Count + 1 ENDEND ------------------------------------------------------------------

UniqueIdentifiers

Posted: 06 Jan 2011 05:49 AM PST

We have the "update" table with the clients' "client_fk" (format 'ntext') number that relates to the "client_pk" (format 'uniqueidentifier") number residing in the "client_demo" table. When I do a query and try join the tables on these two, I am told that I cannot use the ntext field in a comparison with '=' and it is not compatible with the uniqueidentifier. The actual raw string in the fields are the same. Is there any way around this ?Thank you !

Practical Used Of XML Path

Posted: 16 Apr 2013 03:58 AM PDT

Hi all experts,Every passing day i am learning new stuff in SQL Server. Since last few days i am learning XML with SQL Server. I am able to query SSMS for XML , if a problem statement is given to me.I am not able to exactly figure it out what would be practical used of XML with SQL Server.

Search This Blog