Skip to main content

Posts

Showing posts from September, 2011

GR8 links

Getting Started with TFS 2010 http://blogs.msdn.com/b/jasonz/archive/2009/10/21/tutorial-getting-started-with-tfs-in-vs2010.aspx Test Automation with Microsoft Visual Studio 2010: Coded UI Tests and Lab Management:    http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DEV309 Subversion: http://www.codeproject.com/KB/dotnet/SourceControl_VSNET.aspx CLR Stored Procedures - sys.assemblies: http://www.codeproject.com/KB/cs/CLR_Stored_Procedure.aspx Ajax: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/Default.aspx With the experts: http://www.virtualtechdays.com/ SQL Server 2008 Report Builder: Video:  http://msdn.microsoft.com/en-us/library/dd299411(v=SQL.100).aspx Article: http://www.simple-talk.com/sql/reporting-services/beginning-sql-server-2005-reporting-services-part-1/ http://msdn.microsoft.com/en-us/sqlserver/aa336316.aspx Export Test Cases to Excel from TFS http://exporttfs2excel.codeplex.com/releases/view/70526 Details Exported: Work

Kill all open connections to a specific database

For a list of open connections for a specific database you can run the following command: select spid from master..sysprocesses where dbid = db_id('Works') and spid <> @@spid Kill all open connections to a specific database: DECLARE @DatabaseName nvarchar(50) DECLARE @SPId int SET @DatabaseName = N'Works' DECLARE my_cursor CURSOR FAST_FORWARD FOR SELECT SPId FROM MASTER..SysProcesses WHERE DBId = DB_ID(@DatabaseName) AND SPId <> @@SPId OPEN my_cursor FETCH NEXT FROM my_cursor INTO @SPId WHILE @@FETCH_STATUS = 0 BEGIN KILL @SPId FETCH NEXT FROM my_cursor INTO @SPId END CLOSE my_cursor DEALLOCATE my_cursor

Reading XML file in SQL

To read the XML file in SQL we need to use sp_xml_preparedocument and : Syntax sp_xml_preparedocument hdoc OUTPUT -- Is the handle to the newly created document. hdoc is an integer. [ , xmltext ] -- original XML document. [ , xpath_namespaces ] Example DECLARE @hdoc INT, @params_xml XML = ' ' EXEC sp_xml_preparedocument @hdoc OUTPUT, @params_xml The above command, reads the XML text provided as input, parses the text by using the MSXML parser sp_xml_preparedocument returns a handle that can be used to access the newly created internal representation of the XML document. This handle is valid for the duration of the session or until the handle is invalidated by executing sp_xml_removedocument. A parsed document is stored in the internal cache of SQL Server. The MSXML parser uses one-eighth the total memory available for SQL Server. To avoid running out of memory, run sp_xml_removedocument to free up the memory. PUT XML into variables OPENXML provides a rowset view over an XML d

Query Active Directory from SSMS - 3 steps

Step1: Get the Servers Run the following command to get the list of all linked servers. sp_linkedservers Note: sp_helpserver can also be used to list the available servers Step 2: Add the server you want to connect to [This is important, because most people mess up here] To add a linked server we will use the following command sp_addlinkedserver EXEC sp_addlinkedserver @server=N'S1_instance1', @srvproduct=N'', @provider=N'SQLNCLI', @datasrc=N'S1\instance1'; Step 3: Query the Active Directory DECLARE @Application TABLE (cn varchar(50)); DECLARE @ApplicationCN varchar(50); DECLARE @SQLString nvarchar(MAX); DECLARE @ApplicationName varchar(20)= 'yy' -- name of the container DECLARE @Role varchar(20) = 'xxx' DECLARE @Domain nvarchar(20) = 'a.com' -- if this is a.com SET @SQLString='SELECT cn FROM OPENQUERY(ADSI,''SELECT cn FROM ''''LDAP://' +@Domain +''''