Saturday, June 8, 2013

[SQL 2012] Problem with CU 4 for sp1

[SQL 2012] Problem with CU 4 for sp1


Problem with CU 4 for sp1

Posted: 07 Jun 2013 04:54 AM PDT

I installed the recently released CU 4 for sp1 because it resolved a problem we were seeing with SSIS packages calling other SSIS packages producing a nebulous "unexpected termination".The good news is that our "unexpected termination" problem went away. The bad news is that our SSRS reports with parameter lists stopped working, i.e. they didn't render the report.When I turned on a trace, and started the report I could see the stored procedure calls that populated the parameter lists so I know it at least started to execute. When I selected my parameters to submit to the query and clicked the "Submit" button nothing happened. A brief flash of the green "loading" circle and that was it. The report stored procedure that used those parameters was never called according to my trace so it seems relatively clear that some sort of disconnect is occurring.When I uninstalled CU 4, the reporting problem went away.Now I have a chicken and egg problem. If I don't install CU 4, I can't run my ETL and if I do, I can't run my reports.I've submitted this as a bug to Microsoft Connect but I'm wondering if anyone else has noticed this behavior.

[SQL Server 2008 issues] Effect of indexes in SQL Server Performance Tuning

[SQL Server 2008 issues] Effect of indexes in SQL Server Performance Tuning


Effect of indexes in SQL Server Performance Tuning

Posted: 07 Jun 2013 03:23 PM PDT

I have a couple of questions.a) What is the effect of indexes in SQL Server Performance Tuning?b) I have a SQL statement below, which is running slow. How to tune the query?Select col1, col2 from Table TWhere col2 = 'Sydney'Here col1 is the primary key, col2 is having a non clustered index on it.

DEFAULT Constraint syntax

Posted: 06 Jan 2010 04:44 AM PST

Hi guys,I'm writing few new tables and I'd like to keep all the constraints named according to my standards. I have no problems with indexes, checks etc...but with DEFAULTIn my table definition I haveCreate Table User(...ActiveFromDate DateTime Not Null,...Constraint [DF_CMS_User_ActiveFromDate] Default (GetDate()) For ActiveFromDate,...)Message I get is Msg 102, Level 15, State 1, Line 35Incorrect syntax near 'for'.I have scripted the constraint from previous table and I've got the following:ALTER TABLE [dbo].[CMS_User] ADD DEFAULT (getdate()) FOR [ActiveFromDate]GOThank you :)

Error

Posted: 07 Jun 2013 04:23 PM PDT

i am having this errorMsg 257, Level 16, State 3, Procedure query, Line 21Implicit conversion from data type datetime to float is not allowed. Use the CONVERT function to run this query.this is the line and red one is the column that i replace from 540CAST (ABS( t4.LTime - DATEDIFF (MINUTE, t.[Timein], t.[Timeout] ) ) % 60 as varchar ) + ' min' as excesshort, -- Minutesthis column t4.LTime datatype is datetimeplease help me out

Google Analytics SQL Import

Posted: 08 May 2012 09:07 PM PDT

Hi AllI was just wondering if anyone has ever done a Google Analytics import to SQL via SSIS?A quick google brought up some C# scripts, a PHP web scraper and using the java client to export to CSV and then import it, but was wondering if anyone has managed to query the API and load it direct in SSIS to the DB?This was a task which was done a couple of years ago and I have been asked to re-ignite the flame to get it moving again and the previous way was to use xp_cmdshell to execute a file which loads it to CSV and imports it, which I have no trouble with, just wondering if anyone has a better solution.Thanks

Performace issue while updating records and trigger on table

Posted: 04 Jun 2013 03:57 PM PDT

Hi All,I am having a performance issue while updating records into sql server table,I have created below trigger to update related tables if the status of this table is updated/Changed.USE [EMEA_SERVICEMAX]GO/****** Object: Trigger [Servicemax].[ERP_ACCOUNT_DATE_UPDATE] Script Date: 06/05/2013 10:19:56 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO CREATE TRIGGER [Servicemax].[ERP_ACCOUNT_DATE_UPDATE]ON [EMEA_SERVICEMAX].[Servicemax].[ERP_ACCOUNT_STG]FOR UPDATEAS BEGINDECLARE @nOldValue varchar(20),@nNewValue varchar(20),@record_dt date,@CUST_NUM varchar(20),@SOURCE_SERVER varchar(15),@COMPANY_NO intSELECT @nOldValue=b.CUSTOMER_STATUS, @nNewValue=a.CUSTOMER_STATUS ,@record_dt=a.record_insert_dt,@CUST_NUM=a.customer_number,@SOURCE_SERVER = a.SOURCE_SERVER,@COMPANY_NO=a.COMPANY_NOFROM inserted a, deleted bIF @nNewValue = @nOldValuereturn else BEGINupdate EMEA_SERVICEMAX.Servicemax.SALES_ORDERS_STGset record_insert_dt=@record_dtwhere customer_number=@CUST_NUMand SOURCE_SERVER=@SOURCE_SERVERand COMPANY_NO=@COMPANY_NOupdate EMEA_SERVICEMAX.Servicemax.INSTALLATION_STGset record_insert_dt=@record_dtwhere LOCATION_CUSTOMER_NO=@CUST_NUMand SOURCE_SERVER=@SOURCE_SERVERand COMPANY_NO=@COMPANY_NOupdate EMEA_SERVICEMAX.Servicemax.ERP_ACCOUNT_PROJECTS_STGset record_insert_dt=@record_dtwhere customer_number=@CUST_NUMand SOURCE_SERVER=@SOURCE_SERVERand COMPANY_NO=@COMPANY_NOupdate EMEA_SERVICEMAX.Servicemax.SERVICE_CONTRACTS_STGset record_insert_dt=@record_dtwhere customer_number=@CUST_NUMand SOURCE_SERVER=@SOURCE_SERVERand COMPANY_NO=@COMPANY_NOupdate EMEA_SERVICEMAX.Servicemax.SERVICE_ORDER_STGset record_insert_dt=@record_dtwhere customer_number=@CUST_NUMand SOURCE_SERVER=@SOURCE_SERVERand COMPANY_NO=@COMPANY_NOENDENDGOAny help on this may be appreciated.Thanks,Nilesh

How to get the list of tables that has specific column name from linked server, available in SQL SERVER 2008 R2

Posted: 07 Jun 2013 01:15 AM PDT

Hi,I have an access to oracle linked server called [oracleLS]it is there under the SERVER OBJECT => LINKED SERVER => [ORACLE LS] => [CATALOG] => [DEFAUL] => [TABLES] => AND LIST OF TABLES WITH THEIR SCHEMA NAME.TABLES NAMES.I want to find out list of tables from these tables which has specific column called 'business address';I USED FOLLOWING ONE..BUT GIVES ME ERROR OF INVALID OBJECT. SELECT TABLE_NAME, COLUMN_NAME FROM ALL_TAB_COLUMNS WHERE COLUMN_NAME LIKE '%PATTERN%';I AM ALSO WONDERING WHERE I HAVE TO SPECIFY THE LINKED SERVER NAME IN ABOVE QUERY!!I would also like to try another option if you have any idea!!Please help me.thanks.

Support UTF-8 character encoding

Posted: 07 Jun 2013 07:49 AM PDT

Does SQL server 2008 R2 support UTF-8 character encoding ?Thanks.

TVCs

Posted: 07 Jun 2013 06:51 AM PDT

Table Value Constructors.... I've been trying to do some research and some tests and I haven't come across anything that tells me why I should use a TVC over anything else I normally use in T-SQL constructs.Can anyone tell me what, if any, benefits or uses TVCs fulfill aside from being able to specify multiple value row constructors for Merge and Insert statements? I mean when would you specifically use a TVC over another SQL object?Erin

Querying sys.dm_db_partition_stats instead of sys.sp_spaceused

Posted: 04 Jun 2013 10:24 PM PDT

We have a daily process that saves into a table the storage info returned by the SP, but it's procedural, slow, and requires manipulating the character output to get just the numbers. After searching your forums, I've found that the SP references the DMV above.For a table with a clustered index and no non-clustered indexes, it's very easy to match the output from each; for a table that has non-clustered index(es), it seems more complicated. Although we currently don't use multiple partitions, I suppose that might be a further complication?Just wondering if anyone has already written a query using the DMV to get the same (single line) output that the SP does (without the "KB" characters)?Thanks,~ Jeff

How to output multiple columns one column depending on its values

Posted: 07 Jun 2013 05:57 AM PDT

Hi, I have a table where I have amount and rank columns.It is basically an approval workflow. there can be several approvers for one area/unit where the level is he rank.I need to know a way of getting one column for each approving level.For example, for the CID 25756Q, I need to display the approvers as shown below.CID ID1 Amt1 ID2 Amt2 ID3 Amt3 ID4 Amt4 ID5 Amt5 ID6 Amt6 ID7 Amt725756Q 12345A 0.1 12345B 0.2 12345C 0.3 12345D 0.4 12345E 0.5 12345F 0.6 12345G 0.7This is the DDLDrop table ApproverTCREATE TABLE [dbo].[ApproverT]( [CID] [varchar](6) NULL, [ID] [char](6) NULL, [Amount] [real] NULL, [Rank] [int] NULL) Insert into ApproverT (CID, ID, Amount, Rank) Select '25756Q', '12345A', 0.10, 1 UNION ALL Select '25756Q', '12345B', 0.20, 2 UNION ALL Select '25756Q', '12345C', 0.30, 3 UNION ALL Select '25756Q', '12345D', 0.40, 4 UNION ALL Select '25756Q', '12345E', 0.50, 5 UNION ALL Select '25756Q', '12345F', 0.60, 6 UNION ALL Select '25756Q', '12345G', 0.70, 7 UNION ALL Select '93512X', '123456', 0.01, 1 UNION ALL Select '91142A', '654321', 0.10, 1 UNION ALL Select '91142A', '963852', 1.00, 2 I will appreciate any help on this.Thanks,

Certification Question: You need to ensure the successful recovery of any single database from a catastrophic failure without requiring backup data center in a different location

Posted: 06 Jun 2013 10:04 PM PDT

You need to ensure the successful recovery of any single database from a catastrophic failure without requiring backup data center in a different location.which three tasks should you include?(each correct answer presents part of the solution. choose three) A. Store all backup media offsiteB. Script SQL Login accounts and credentialsC. Install all SQL Server instances on a failover cluster.D. Maintain one list of all Windows logins and Passwords.E. Document the administrative processes and application access requirements.A, B AND E ARE THE CORRECT ANSWERS. BUT ARE THOSE REALLY THE MOST CORRECT ANSWERS?

linked server issue

Posted: 07 Jun 2013 03:08 AM PDT

Hello, I have setup a linked server between SQL Server 2008 R2 and MAS90 server and I am able to select data and see the list of mas90 tables. I am using a sql agent job to pull data from mas90 to sql server database through the linked server.The issue here is whenever a new account is added to MAS90 database the sql agent job which tries to pull data from MAS90 to SQL Server database gets hung. So the data that I am trying to pull from mas90 to sql database wont appear in the sql server database. Everytime this happens if I restart the sql server services and restart the sql agent job then it works fine. Experts I need your advice on how to fix this as this is happening quite frequently and I cannot afford to restart the sql server services everytime a new account is added. Does it have to do anything with the local DTC property settings on the SQL Server database server side? I have attached the current msdtc settings jpg file with this post. Thanks

Service Broker Question - End Conversation command

Posted: 06 Jun 2013 10:00 PM PDT

Does "END CONVERSATION" send a message back to the actual queues?The reason I'm asking is due to some code I've been looking through. There's doesn't seem to be a normal reply message to send a message back to the initiator, but a stored procedure linked to the initiator queue is definitely being triggered somehow.I've even looked through a trace and the stored procedure linked to the initiator queue is started right after the END CONVERSATION command and the CLOSED Broker:Conversation.

Invoke or BeginInvoke cannot be called on a control until the window handle has been created

Posted: 04 Nov 2009 06:44 AM PST

HiI am trying to install SQL Server 2008 Developer Edition x64 on a Windows Server 2008 VM. I run the installer for a standalone installation and this works fine for the setup support rules bit. That passes ok but then I get this error:TITLE: SQL Server Setup failure.------------------------------SQL Server Setup has encountered the following error:Invoke or BeginInvoke cannot be called on a control until the window handle has been created..------------------------------BUTTONS:OK------------------------------How can I resolve this? I am getting 2008 R2 CTP but this is just a CTP. My download is from DreamSpark.

SQL Server Transactional Replication

Posted: 06 Jun 2013 10:27 PM PDT

We did a performance audit on the system and the reports revealed we should change the Clustered index (the primary key of the table) to another index, but kept the primary key on the original column. We ran the snapshot , but we niticed that the tabke of which we changed the primary key , does not get populated , althiugh the snapshot shows that records were bulkcopied into the table . Any ideas ?

Using the same partition function and scheme for multiple tables

Posted: 04 Jun 2013 02:58 PM PDT

I have a database where most of the tables have an integer field say "SetId" denoting a batch of data.If a new SetId is created all these tables will get data related to the new SetId.SetId governs data retention, purging, it also forms part of filtering in many user queries on these tables.I am thinking of partitioning all these tables on the SetID column, which I am sure would be beneficial for performance and data maintenance.My question is, do I use a common partition function and partition scheme to partition all the tables on SetId, or is it more advisable to use separate partition functions and schemes for each tables?

Profiler shows long duration for sp but actually it is not

Posted: 06 Jun 2013 10:43 PM PDT

HiI have a sp which is timing out on my website. When i run a trace on it, duration comes ~ 80000 (ms)So it times out as it is set 30s for site. but when I run the same call after copying from trace in SSMS, it hardly takes 2-3 secs. Why profiler show long durations?I tries same thing for 5-10 calls to be sure that it is not because of cached data. but they are always fast on SSMS.Is duration column in profiler accounts for Network time or any other times in it?

prevent simultaneous update

Posted: 06 Jun 2013 11:14 PM PDT

HiI have a table where multiple Agents can assign tasks to themselves. So I basically pull the minimum TaskId which is not assigned using SELECT statement and then RUN an update to assign that task to Agent.Below is the statementUPDATE TOP(1) TaskTable SET TaskStatus = 2 , TaskOwner = @UserID WHERE TaskID = (SELECT MIN(TaskID) FROM TaskTable WHERE Assigned=0) Now there is possibility that 2 agents clicked simultaneously to assign tasks, both pulled same taskID from SELECT but as updated can't be simultaneous, so update of one agent will be overwritten by other.How to prevent it?

Error converting Varchar to Float

Posted: 06 Jun 2013 11:38 PM PDT

Hi All,I am trying to use the query below but receive the error message "Msg 8114, Level 16, State 5, Line 1Error converting data type varchar to float."Query :[b]select w.casecode,w.category,w.desc1,w.weightage,w.WACC,w.Goal_Weighing,f.Factorfrom [dbo].[Final] as w inner join[dbo].[Final01] as fon w.casecode = f.casecode[/b]I am surprised because this query is used to create a view. This view was not giving me any error message since last 1 week but suddenly today I pressed button to see results of this view and received this error message. Please help!

how to archive data based on on archive it self?

Posted: 28 May 2013 11:36 PM PDT

HiI have an archive tabel in Oracle. We copy this to a ms sql 2008 r2 database for datawarehouse purpose.The problem is that it only contains 90 days of records. I now need to archive this archive table. :-DThere is no unique key in the table. It log our load_id but one id may come several times a day even several days.I need to take a copy of the archive as is, and each day make it run thru the new transfer from oracle to figure out what has cahnged and add those lines to my copy.How to solve this the best way?BRDan

DROP PK on highly called big table

Posted: 02 Jun 2013 08:05 PM PDT

HII have a table with 80 million records with PK on an int column. A service selects data from this table multiple times/sec in live environment.I have to change the datetype of this PK column from int to BigInt. So I need to drop the PK constraint. But when I run the ALTER TABLE statement to drop it, it gets blocked by Select statements (they have NOLOCK in them). So i think it will be never ending wait.Is there any other better way to achieve it?Can I put some lock on table while altering it so that Select statements just wait for their turn but son't block the ALTER statement?thanks

Transposing a table from multicolumn to key-value

Posted: 06 Jun 2013 09:56 PM PDT

I have a transactional table with 100+ columns and each row is uniquely identified by an id column. For a data export requirement, we need to make export the table flat - aka, id/column_name/column_value format. the number of columns are dynamic in nature. By this, I mean : there could be 10 additional columns in near future. Some columns might get dropped as well. This is another reason for exporting as a name/value pair.A dynamic pivoting might be the answer - I tried using dynamic pivoting using xmlpath/cross apply and made things complex enough to get a cross joined resultset. Here is the sample schema (input/output) with sample data:http://sqlfiddle.com/#!3/f0efa/7Any help is highly appreciated.

Division problem in SQL

Posted: 06 Jun 2013 08:38 PM PDT

Hello All,Can anyone please explain why do we always get 0 when we divide 1 by any other larger number.select 1/2 gives me 0.Thank you for your help

Friday, June 7, 2013

[SQL server issues] Commented Issue: AdventureWorksDW2008R2 DimDate table has missing dates [13383]


Commented Issue: AdventureWorksDW2008R2 DimDate table has missing dates [13383]



pavanbarnala wrote Feb 23, 2012 at 10:47 AM


Hello,
Is this been taken care? If so, please share the latest data for DimDate. I'm working on some POC which requires dates in between 2008 and 2010 as well. If it is not already done, can someone let me know is there is any way I can generate the data for those missing dates in that table?



petermyers wrote Feb 26, 2012 at 5:21 AM


The attached script will fix the problem. Use the stored procedure to extend to future dates if needed.



.

sqlserversamples.codeplex.com

[SQL Server Data Warehousing] T-SQL SCD2


T-SQL SCD2



Here is the query i am using in case if it helps.


To give you little more scenario  on my request  : Our Data warehouse is very traditional approach of ETL , We have update statments that does lookup and update the Foriegn keys.


My first update statments goes and finds an employee based on a logic of Data Entry



Update dbo.SFWP
Set EmployeeID = we2.EmployeeSK
from dbo.SFWP a
Inner Join WMDM.dbo.WMDM AT
on a.AssignedTaskID = AT.AssignedTaskID
Inner join WMDM.dbo.Employee we1
on AT.EmployeeID = we1.SK
Inner Join WMDM.dbo.Employee we2
on we1.NK = we2.NK
and Src_EntryDate >= we2.EffectiveBeginDTM and
Src_EntryDate <= we2.EffectiveEndDTM

Apparently for some reason some employees cannot be matched because  our employee table has this condition not met because of missing records


and  Src_EntryDate >= we2.EffectiveBeginDTM and
Src_EntryDate <= we2.EffectiveEndDTM


So, my new query i am trying to take a previous or Next record and find employee ID and update it.



wITH CustCTE as
(
select
We2.SK,
We2.NK,
We2.EffectiveBeginDTM,
We2.EffectiveEndDTM,
ROW_NUMBER() OVER (PARTITION BY We2.NK ORDER BY We2.EffectiveBeginDTM) RowNum
from dbo.SFWP a
Inner Join WMDM.dbo.WMDM AT
on a.AssignedTaskID = AT.AssignedTaskID
Inner join WMDM.dbo.Employee we1
on AT.EmployeeID = we1.SK
Inner Join WMDM.dbo.Employee we2
on we1.NK = we2.NK
Where
Src_EntryDate < we2.EffectiveBeginDTM or
Src_EntryDate > we2.EffectiveEndDTM
and a.EmployeeID is NULL
)
,
CustCTE1 as (
Select
a.SK
,a.NK
,a.EffectiveBeginDTM
,a.EffectiveEndDTM
,a.RowNum

From CustCTE a
Union All
Select
Curr.SK
,Curr.NK
,Curr.EffectiveBeginDTM
,Curr.EffectiveEndDTM
,Curr.RowNum

From CustCTE Curr
Inner Join CustCTE1 Prev
on Curr.NK = Prev.NK
and Curr.RowNum = Prev.RowNum-1
)
select * From CustCTE1

But i am not getting the same thing as i expect..


Any help in this matter will be highly appreciated.


thank you in advance



.

social.technet.microsoft.com/Forums

[SQL Server Data Warehousing] SSAS Cube not taking the data


SSAS Cube not taking the data



Please let us know if


1. You are getting any errors


2. How frequently is data updated in your view and for how long you are using the cube?


3. Have u scheduled for process of cube regularly



.

social.technet.microsoft.com/Forums

[SQL Server Data Warehousing] Change Data Capture - Pros/Cons/Gotchas


Change Data Capture - Pros/Cons/Gotchas



My company is thinking of implementing Change Data Capture. I find many online articles, which cover the basics of Change Data Capture, but no real-life examples of using it, the pros and cons, limitations or "gotchas" encountered during actual implementation and usage, etc. I could use such info as we determine whether Change Data Capture is the right solution for our needs.


Some details about our scenario:


1. Source data: We have currently about 200 entities that use one of our applications. The entities involved are all functioning units of a larger, single business entity, but are spread out geographically. Each entity and its copy of the application stores its data in a separate database, although all copies of the database have identical data structures and tables. They post summarative data on a routine basis to a couple of main servers, however, in each case this data is still stored in separate database on the servers - thus, still about 200 databases.
2. What we would like to do: Bring together this summarative data into a single relational data store, and from there into a dimensional database. We do not want to, nor can we, eliminate the source databases, on either the geographically-distributed sites or the main servers, b/c we don't "own" them.


Is this a feasible scenario for Change Data Capture? We would need to include data column(s) to indicate data sources b/c the data, although placed in a single database, must still be identifiable by data source and data from one source never overwrites data from a different source. As I understand it, Change Data Capture would need to be enabled on the 200+ databases on the main servers, from which we would then likely use SSIS to process the data to post it to the new database we would develop.


I would appreciate any advice, based on understanding and experience, of important things to consider, things to avoid, "gotchas", best practices, etc. We have worked quite a bit with SSIS, developing dimensional data structures, etc., so although any major comments there are welcomed, our primary "need to know" is how/if Change Data Capture can be used for our scenario, as we have no experience with it.

Thanks for your assistance,
Randy



.

social.technet.microsoft.com/Forums

[SQL Server] slowly changing dimension?

[SQL Server] slowly changing dimension?


slowly changing dimension?

Posted: 07 Jun 2013 06:04 AM PDT

Hi everyone.I've got to figure out whose games scores changed the least over time. I've created DDL to illustrate[code="plain"]create table gamescores(gameNo varchar(20) not null,player varchar (20) not null,score int not null,datePlayed datetime not null,memo varchar(20) null,)insert into gamescoresvalues('Game1', 'P1', 50, getdate()-2, NULL), ('Game1', 'P2', 60, getdate()-2, NULL),('Game1', 'P3', 70, getdate()-2, NULL),('Game2', 'P1', 50, getdate()-1, NULL),('Game2', 'P2', 65, getdate()-1, NULL),('Game2', 'P3', 76, getdate()-1, NULL),('Game3', 'P1', 50, getdate(), NULL),('Game3', 'P2', 70, getdate(), NULL),('Game3', 'P3', 81, getdate(), NULL);[/code]as you can see, player 1's scores don't change. I want to write a query to capture in my bigger table, the player with No change to game scores, over a period of any 3 days. Can you show me how? Thanks.

dynamic joins

Posted: 06 Jun 2013 09:25 PM PDT

Hi ,What would be the best way to dynamically self join a table to create the example contained with the excel spreadsheet?The number of rules can vary depending on the order. Is there a way of creating a script/function that will look at all rules applied to a order and create 1 line per order with all rules applied?all suggestions would be welcomeThanks in advanceDan

Search This Blog