Locking during debugging stored procedure in Visual Studio 2005

I had this weird situation for almost two days whilst debugging a stored procedure in Visual Studio 2005. Just after a few minutes, over and over again at the same line, I got an error popping up:

Failed to retrieve data for this request.
Lock request time out period exceeded.

So obviously it had something to do with locking which is not unusal but it shouldn't give me an error from within Visual Studio right?
I'm working on a standalone instance here, so no interferance from other applications or people with open connections in SSMS.

When I looked at the Activity Monitor in SSMS, I could see a LCK_M_S key lock caused by the query below which is not part of my stored procedure(It almost looks like Visual Studio is executing this query).
SELECT
db_name() AS [Database_Name],
udf.name AS [Name],
SCHEMA_NAME(udf.schema_id) AS [Schema],
udf.object_id AS [ID],
CAST(
 case 
  when udf.is_ms_shipped = 1 then 1
  when (
    select 
      major_id 
    from 
      sys.extended_properties 
    where 
      major_id = udf.object_id and 
      minor_id = 0 and 
      class = 1 and 
      name = N'microsoft_database_tools_support') 
    is not null then 1
  else 0
end     
       AS bit) AS [IsSystemObject],
CAST(CASE WHEN ISNULL(smudf.definition, ssmudf.definition) IS NULL THEN 1 ELSE 0 END AS bit) AS [IsEncrypted],
(case when 'FN' = udf.type then 1 when 'FS' = udf.type then 1 when 'IF' = udf.type then 3 when 'TF' = udf.type then 2 when 'FT' = udf.type then 2 else 0 end) AS [FunctionType],
usrt.name AS [DataType],
sret_param.name AS [DataTypeSchema],
ISNULL(baset.name, N'') AS [SystemType],
CAST(CASE WHEN baset.name IN (N'nchar', N'nvarchar') AND ret_param.max_length <> -1 THEN ret_param.max_length/2 ELSE ret_param.max_length END AS int) AS [Length],
CAST(ret_param.precision AS int) AS [NumericPrecision],
CAST(ret_param.scale AS int) AS [NumericScale],
case when amudf.object_id is null then N'' else asmbludf.name end AS [AssemblyName],
case when amudf.object_id is null then N'' else amudf.assembly_class end AS [ClassName],
case when amudf.object_id is null then N'' else amudf.assembly_method end AS [MethodName],
CASE WHEN udf.type IN ('FN','IF','TF') THEN 1 WHEN udf.type IN ('FS','FT') THEN 2 ELSE 1 END AS [ImplementationType]
FROM
sys.all_objects AS udf
LEFT OUTER JOIN sys.sql_modules AS smudf ON smudf.object_id = udf.object_id
LEFT OUTER JOIN sys.system_sql_modules AS ssmudf ON ssmudf.object_id = udf.object_id
LEFT OUTER JOIN sys.all_parameters AS ret_param ON ret_param.object_id = udf.object_id and ret_param.is_output = 1
LEFT OUTER JOIN sys.types AS usrt ON usrt.user_type_id = ret_param.user_type_id
LEFT OUTER JOIN sys.schemas AS sret_param ON sret_param.schema_id = usrt.schema_id
LEFT OUTER JOIN sys.types AS baset ON baset.user_type_id = ret_param.system_type_id and baset.user_type_id = baset.system_type_id
LEFT OUTER JOIN sys.assembly_modules AS amudf ON amudf.object_id = udf.object_id
LEFT OUTER JOIN sys.assemblies AS asmbludf ON asmbludf.assembly_id = amudf.assembly_id
WHERE
(udf.type in ('TF', 'FN', 'IF', 'FS', 'FT'))
ORDER BY
[Database_Name] ASC,[Schema] ASC,[Name] ASC

The query started to show up in the Activity Monitor as soon as I expanded the stored procedure node from the Server Explorer pane where you connect to a database. I guess Visual Studio 2005 uses the info from the resultset to build the nodes in the Server Explorer/Database connection.

I started experimenting with the Visual Studio settings including the time out setting but I didn't make any progress until I decided to switch to Visual Studio 2010.
The query responsable for the locking did no longer appear.

Posted by Steve with no comments
Filed under:

Denali - Import Text Editor settings from Visual Studio

Up until SQL Server 2008 R2, you had to customize the font and background colors manually in SSMS.

SQL Server Denali lets you import your Visual Studio settings such as the custom colors in the Text Editor.
The fact that the Denali SSMS splash screen shows Powered By Visual Studio probably has a lot to do with that.

In Visual Studio go to Options, Environment, Import and Export Settings and copy the location where your settings are stored with the .vssettings extension.

Visual Studio Export Settings

 

Next open SSMS, go to Options, Environment, Import and Export Settings and locate your .vssettings file you copied from Visual Studio using the team settings file option.

SSMS Import Settings

Posted by Steve with no comments
Filed under: ,

Dive into the Summer with TechNet

Dive into the Summer with TechNet

What about some light reading on virtualizing SQL Server during the holidays whilst sipping a nice cocktail?

Sure, your wife might be rolling her eyes when she sees you reading a Hyper-V whitepaper but hey, nowadays virtualized SQL Servers are everywhere so virtualization has become a technology that needs to be mastered by SQL Server experts as well and not only by system administrators.

TechNet has started its summer campaign with the first part on virtualization. You won't have to spend the entire afternoon by the swimming pool reading white papers. There's material for the ones having only half an hour to spend, half a day and a full day (be careful on the cocktails!)

A good document to start with is Hyper-V Getting Started Guide followed by Hyper-V: Using Hyper-V and Failover Clustering and Virtualizing SQL Workloads 

Read why Hyper-V is the Best Virtualization Solution for SQL Server Whitepaper which covers the advantages over VMware such as performance, high availability, management, monitoring and costs.

Read all about SQL Server in a virtualized environment here.

Happy holidays!

Posted by Steve with no comments
Filed under: ,

Be careful with cloned VMs of SQL Server production servers

Imagine this,

You're handed a new clean and crisp full functioning copy of a SQL Server production server VM which you can use to experiment with.

Of course the clone has a new computer name. You might want to execute a select @@servername to see what the actual name is which is used by SQL Server itself.
Unless the original server has been dropped from table sysservers en replaced with the new server name, you will still see the server name of the production server.

Now, be very carefull when executing statements on the cloned VM where @@servername is used in the code. Sometimes the @@servername variable is used to dynamically build file paths...

Use the following statements to change the server name:

sp_dropserver <'old_name\instancename'>

GO

sp_addserver <'new_name\instancename'>, local

GO

Also check: Rename a computer that hosts a stand-alone instance of SQL Server

 

Posted by Steve with no comments

!= gets converted to <> in Query Designer

One of my colleagues today asked me why != is accepted in a query but gets automatically converted into <> when it's written using the Query Designer.

I didn't have an immediate answer but found out that some of the server-specific syntax gets converted into ANSI standard syntax.

Read more about the Query Designer Considerations for SQL Server Databases

No, it's not a bug!

Posted by Steve with no comments
Filed under: , ,

Setup SSRS in SharePoint Integrated Mode

This post is about configuring SQL Server Reporting Services in SharePoint Integrated mode the quick and clean way with no fuzz in 40 steps.

I'm not discussing the default values, I will only talk about the values which need to be changed or selected in order to get SSRS set up in the least amount of steps.


The scenario:
  • SharePoint 2010 Enterprise Edition + named instance SQL Server 2008 Express Edition which is deployed during the SharePoint setup. Name of the SQL Server instance: SHAREPOINT.
  • Separate default SQL Server 2008 R2 instance (Enterprise Edition).
  • SSRS currently installed in native mode on the SQL Server 2008 R2 default instance.
  • AdventureWorksDW2008R2 hosted on the SQL Server 2008 R2 default instance.

The procedure contains 5 parts:

A. SSRS Configuration {SQL Server}
B. Web application {SharePoint}
C. Site collection {SharePoint}
D. SSRS integration {SharePoint}
E. Content types {SharePoint}
Let's start!

A. SSRS Configuration {SQL Server}
  1. Log on to your SharePoint 2010 box.
  2. Fire up the SQL Server Reporting Services Configuration Manager.
  3. Connect to the Report Server instance. In my case this is the default SQL Server 2008 R2 instance (MSSQLSERVER)
  4. The first thing you will notice is the Report Server Status. Check the Report Server Mode. It should say Native (we start from native mode in this scenario).
  5. Click Database in the left pane.Click Change Database. Select Create a new report server database.
    Enter the proper credentials.
  6. Enter a database name and select SharePoint Integrated mode.
  7. Enter the credentials and do not forget the <domain name>\<username> (.\<username> will do as well).
  8. Choose Report Manager URL in the left pane and click the apply button. This will configure the Report Manager virtual directory.
  9. Backup the encryption keys.

B. Web application {SharePoint}
  1. Open the SharePoint Central Administration website.
  2. Choose Application Management > Manage web applications.
  3. Click the New button in the ribbon. This will bring up the Create new web application popup.
  4. Keep the default values to keep things simple except for:
    1. Choose a name for the new IIS Website. I will choose SSRSDemo in this example.
    2. Choose a name for the application pool. I will again choose SSRSDemo.
    3. Make sure you connect to the right database instance. In my example I will connect to the named SQL Server 2008 Express Edition instance named SHAREPOINT.
    4. Choose a database name or keep the default value with the GUID suffix. I will call the database WSS_Content_SSRSDemo.
    5. Hold your horses before you hit the OK button when this information pops up:

The Microsoft SharePoint Foundation Web application has been created. 

If this is the first time that you have used this application pool with a SharePoint Web application, you must wait until the Internet Information Services (IIS) Web site has been created on all servers. By default, no new SharePoint site collections are created with the Web application. If you have just created a Forms Based Authentication (FBA) Web application, then before creating a new site collection, you will need to perform some additional configuration steps. 

Learn about how to configure a Web application for FBA. 

Once you are finished, to create a new site collection, go to the Create Site Collection page. 


5. Click Create Site Collection page to move on to C. Site collection {SharePoint}


C. Site collection {SharePoint}
  1. Enter a title for the site collection. SSRSDemo for example.
  2. Choose a template. I will choose Business Intelligence Center because I want to store my SSRS reports in a BI related environment.
  3. Enter a username for Primary Collection Administrator. Make sure you enter the full domain name. e.g.: <domain name>\<username> (.\username  won't work here).
D. SSRS integration {SharePoint}

  1. Go to the SharePoint Central Administration website > General Application Settings > Reporting Services > Reporting Services Integration.
  2. Enter the Report Server Web Service URL which you can find the SQL Server Reporting Services Configuration Manager.
  3. Choose the Authentication Mode. I will choose Windows Authentication. Entering .\<username> will do.
  4. Go to the SharePoint Central Administration website > General Application Settings > Reporting Services > Add a Report Server to the Integration.
  5. The server name should already be provided and enter the name of the SQL Server instance which hosts the report server database.
  6. Enter the credentials.

E. Upload a report {SharePoint}
  1. Open your new top level web site we created in C. Site collection {SharePoint}
  2. In case you forgot the URL of the web site, go to SharePoint Central Administration > Web Application and look for the URL.
  3. Go to All site Content > Documents.
  4. In the ribbon, go to Library Tools > Library.
  5. Click Library Settings.
  6. Click Advanced Settings.
  7. In Content Types, check Yes for Allow Management of content types and click OK.
  8. In the columns section, click Add from existing site columns.
  9. In the Select site columns from drop-down box, select Report Server Content Types.
  10. Select all available site content types and click the Add button followed by OK.
  11. Go back to All site content > Documents.
  12. Click the Add Document link.
  13. Browse for a Report provided by the AdventureWorksDW200R2 samples from CodePlex.
  14. Enter a title for the report.
There is also the option to create a report yourself if you don't have the reports from the sample reports. It only takes a few seconds to create a report using the Report Builder (see screenshot below).
 

You have now finished the complete setup. Click the report you have uploaded to view the result.

 

TechDays 2011 - Ask The Experts

I will be joining the people at Ask The Experts at TechDays 2011 in Belgium, 26 to 28 April. So, bring your SQL Server questions to the Ask The Experts corner and we will have a look.

See you there!

 TechDays 2011

 

Posted by Steve with no comments
Filed under:

The workshop you need to master PowerPivot!

The PowerPivot Workshop is coming to the Kohera/Oak3 Campus in Brussels on 19-20 May, 2011. All attendees will receive a copy of the new book "Microsoft PowerPivot for Excel 2010: Give Your Data Meaning" authored by Marco Russo and Alberto Ferrari, who are the trainers of the workshop.

This 2-day intensive course is aimed to IT professionals and Excel power users (Information Workers) who want to take the most out of PowerPivot. The course will cover all aspects of PowerPivot, from basics to the most advanced topics, including an extensive coverage of the new DAX language, which will be also used by BISM (BI Semantic Model) in the next version of Analysis Services.

Full details and registration information can be found on http://www.powerpivotworkshop.com.

Kohera is the exclusive authorized training center for the PowerPivot Workshop in Belgium. Keep an eye on our website for more announcements on the PowerPivot workshop in the coming weeks.

If you have any questions regarding this workshop or PowerPivot in general, don’t hesitate to contact us at info@kohera.be.

 

 

Posted by Steve with no comments
Filed under:

TechDays 2011

TechDays 2011 is coming up in April, 26 to 28.

Dandy Weyn (Blog | Twitter), Microsoft will speak about SQL Server Denali and upgrading to SQL Server 2008 R2 and SQL Server Denali.

Discount for early birds has runs until February 28th
Register here.

Posted by Steve with no comments

SQLUG.BE: SQL Server Forensic Analysis - Playing CSI with databases, February 28th

 

I'm happy to announce our first user group session of 2011...CSI style! 

Tom Van Zele will bring us SQL Server Forensic Analysis - Playing CSI with databases

You get a call from a colleague who thinks that his financial information system has been hacked. Of course this system uses a SQL Server Database back-end. In this session we'll uncover the basics of digital forensics: how to find out whether the system has been accessed by the intruder? What data has been accessed? Was there anything modified? We'll learn on how to find evidence of what happened and also on how to create a report that can be served as evidence in a court of law. 

About Tom Van Zele 

Tom is a seasoned IT professional with more than 10 years experience, first in large scale Active Directory implementations, later moving on to SQL Server. His focus lies on infrastructure & security.
You can follow Tom on his blog www.synsol.eu/blog and Twitter @tvanzele

Registration is open here

 

Posted by Steve with no comments

SSMS 2008 cannot connect to a SSIS 2005 instance

Read the title carefully and take it literally. I had discussions with people trying to convince me this is indeed possible. What they were trying to explain to me is the following:

Let's take a SQL Server Management Studio 2008 and connect to a SQL Server Integration Services 2005 instance. Proof can be found here.

It won't work. One would think it's backward compatible but it's not.
However, there is somewhat a workaround: connect to SSIS 2008 instance through SSMS 2008 which of course should work AND within the stored packages node, you are indeed able to connect to 2005 packages.

Literally, SSMS 2008 cannot connect to a SSIS 2005 instance

 

Posted by Steve with 1 comment(s)
Filed under: ,

SQL Server Day 2009

On Thursday, the 3rd of December 2009 SQLUG.BE (The Belgian SQL Server User Group) and Microsoft are teaming up to organize the second Belgian SQL Server Day. Focus of the day is off course SQL Server.

Last year, SQL Server Day 2008 was the biggest community driven SQL Server event in the Benelux, with more than 200 attendees.

Date and hours:
December, 3rd, 2009
Registration opens at 9.00 AM. The opening keynote starts at 10.00 AM.
The event is free, but registration is required.

Sessions:
The event will kick-off with an international speaker positioning the SQL Server data platform, today and tomorrow.

We have 6 break-out sessions with technical content on SQL Server. The speakers are recognized international SQL Server experts.

During the lunch break our gold partners will present their solutions and offerings in the lightning sessions .

We conclude the day with a closing keynote on Gemini, the new breakthrough Self-Service Business Intelligence (BI) capabilities being delivered in SQL Server 2008 R2.

The full agenda can be found here.

Location:
Utopolis Mechelen
Spuibeekstraat 5
2800 Mechelen

Posted by Steve with no comments
Filed under:

SQL Server MVP Deep Dives

I'm about to preorder a copy of SQL Server MVP Deep Dives at Amazon.

53 SQL Server MVP's have been working on the book for the past year or so. Among the authors are Paul Nielsen, Hugo Kornelis, Itzik Ben-Gan, Bob Beauchemin, Erland Sommarskog, Brad McGehee, Tibor Karaszi, Aaron Bertrand, Joe Webb, Kevin Kline

Now, where did I leave my Master Card?

Posted by Steve with no comments

SQL Server Management Studio Hack

Database administrators are lazy by nature. And although Books Online is a very good resource I'd like to get my own mini overview of most used statements in a new query template such as this one:

 

So whenever I hit "New Query" I get my template. It's also usefull when you want to send your script to a colleague so you won't have to tell him/her what server they need to connect to and which database to select.

You might want to give it a try.

1. Open file 'C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\SQL\SQLFile.sql' in Management Studio and copy the code below and save.

-- ! Please execute in SQLCMD mode ! click SQLCMD Mode on the SQL Server Management Studio Query menu,

SET NOCOUNT ON
:CONNECT <servername>

USE <databasename>
GO

 
/*

 DBCC SQLPERF(LOGSPACE)WITH NO_INFOMSGS
 DBCC OPENTRAN WITH TABLERESULTS
 DBCC INPUTBUFFER ( session_id )
 DBCC SHOW_STATISTICS ("Person.Address", AK_Address_rowguid) WITH HISTOGRAM;
 DBCC SHOWCONTIG ("HumanResources.Employee");
 DBCC FREEPROCCACHE WITH NO_INFOMSGS;
 DBCC DROPCLEANBUFFERS [ WITH NO_INFOMSGS ]
 DBCC CHECKCONSTRAINTS ("Production.CK_ProductCostHistory_EndDate");
 DBCC DBREINDEX ("HumanResources.Employee", " ", 70);
 DBCC INDEXDEFRAG (AdventureWorks, "Production.Product", PK_Product_ProductID)
 DBCC CHECKDB;
 DBCC CHECKTABLE ("HumanResources.Employee") WITH PHYSICAL_ONLY;

 EXEC sp_helpfile
 EXEC sp_spaceused
 EXEC sp_change_users_login 'Report';
 EXEC master.dbo.xp_fixeddrives

*/
 

Posted by Steve with no comments
Filed under: ,

Community Day 2009

 

Community Day is back again, are you ready for our Third Edition of Microsoft Community Day?
 
Eleven Microsoft User Groups combine their efforts to organize this unique networking and knowledge sharing
event. A unique opportunity to learn about Microsoft’s latest developments and technologies like Exchange
2010, Silverlight 3, Visual Studio 2010, SQL Server 2008, Windows 2008R2, Powershell V2, Forefront
Identity Manager 2010, XNA 3.1. and OCS R2.
 
Microsoft Community Day will take place on Thursday 25th June 2009 in Utopolis, Mechelen, where we will
bring together 300 IT Pro’s and developers.
 
The Microsoft Community Day 2009 is supported by BESUG, BIWUG, IT-Talks, MVUG, Pro-Exchange, SCUG, SQLUG, VBIB, Visug, WinSec, XNA-BUG.

(Original source: www.mscommunity.be)

 

Posted by Steve with no comments
Filed under:
More Posts Next page »