Skip to content

Knowledgebase

Close Button

Tag: T-SQL

How to correctly use select top 1 inside a inner join of an update statement in T-SQL.

11 July, 2012 Roel van Lisdonk 0 Comments Uncategorized 09:17

And the answer is: don’t use select top 1, instead use the row_number() function and the OVER clause. Lets assume we have a table structure like:     Table [Observation] Multiple observations during a TimeSpan…

Read More

How to get table schema / structure information with T-SQL

13 April, 2012 Roel van Lisdonk 0 Comments Uncategorized 11:47

If you want to get table schema / structure information with T-SQL, you have several options, the most commonly used by me are: Using the system stored procedure sp_help exec sp_help '<your table name>'  …

Read More

How to insert the result of a stored procedure in a table variable

2 April, 2012 Roel van Lisdonk 0 Comments Uncategorized 16:32

Found the solution at: http://stackoverflow.com/questions/653714/how-to-select-into-temp-table-from-stored-procedure The following T-SQL code executes the system stored procedure sp_helpfile and stores the result in the table variable @temp.   declare @temp table (     name varchar(255),     field varchar(255),…

Read More

How to name primary key and foreign key constraints, when creating a table with T-SQL.

26 March, 2012 Roel van Lisdonk 0 Comments Uncategorized 16:53

When trouble shouting error’s thrown by T-SQL, naming your primary and foreign keys, proves to be handy. When creating tables with T-SQL, I use the naming format PK_MyTable_MyColumn1_MyColumn2 and FK_MyTable_MyColumn3_MyColumn4: if object_id('[dbo].[Address]') is null begin…

Read More

How to create a stored procedure with T-SQL

7 February, 2012 Roel van Lisdonk 4 Comments Uncategorized 08:46

Well for ages, I created mine stored procedures like: if exists (select 1 from sys.objects where name = 'GetSales' and type = 'p') begin drop procedure [Reporting].[GetSales] end go create procedure [Reporting].[GetSales] @parameter1 int, @parameter2…

Read More

Microsoft SQL Server DBCC reseed does not take into account the existing ID’s

5 December, 2011 Roel van Lisdonk 0 Comments Uncategorized 20:23

A colleague of mine (Mattijs ter Heijde) created a simple script to verify Microsoft SQL Server DBCC RESEED does not take existing ID’s into account, here’s the T-SQL Code:create table #test (id int not null…

Read More

Create table in T-SQL with named primary key and foreign key

11 November, 2011 Roel van Lisdonk 0 Comments Uncategorized 12:18

Just a simple example of creating a table by using T-SQL: if not exists(select 1 from sys.objects where object_id = object_id('Product')) begin   create table [dbo].[Product]   (     [Id] [int] not null identity (1,…

Read More

Drop all connections to a SQL Server database with T-SQL

1 July, 2011 Roel van Lisdonk 0 Comments Uncategorized 16:24

If you want to drop all connections to a database by using T-SQL, connect Microsoft SQL Server Management Studio to the master database, open a new query editor window and execute the following T-SQL code:…

Read More

How to search for a value, in all columns of a Microsoft SQL Server Database

7 February, 2011 Roel van Lisdonk 0 Comments Uncategorized 16:55

If you want to search in for a specific value in all columns of a Microsoft SQL Server Database, you can use the following T-SQL stored procedure:  CREATE PROC SearchAllTables( @SearchStr nvarchar(100) ) AS BEGIN…

Read More

Convert datetime to string in format HH:mm:ss in T-SQL

26 November, 2010 Roel van Lisdonk 0 Comments Uncategorized 14:12

CONVERT(VARCHAR(8),GETDATE(),108) Result 14:12:30 Other examples print convert(varchar(30),getdate(),121) -- Result: 2011-05-09 12:04:31.883 print convert(varchar(30),getdate(),113) -- Result: 29 Apr 2011 13:41:23:327

Read More

Posts pagination

Previous page Page 1 Page 2 Page 3 Page 4 Page 5 Next page

Tags

Angular (16) AngularJS (28) ASP .NET (66) C# (191) Chrome (7) CSS (27) Entity Framework (17) Excel (9) HTML (8) IIS (29) Integration Services (18) Internet Explorer (11) Javascript (70) jQuery (7) Kendo (6) Kendo UI (16) LINQ (10) LLBLGen (13) MVC (7) NAnt (9) Outlook (19) Outsystems (6) PowerPivot (9) PowerShell (31) Reporting Services (21) Setup Packages (14) SharePoint (28) Silverlight (15) SQL Server (88) SSIS (17) T-SQL (44) Telerik (12) TFS (11) TypeScript (13) Unit tests (15) Visual Studio (101) Visual Studio Code (8) VMWare (10) WCF (12) WCF RIA Services (7) Windows (11) Windows 7 (34) Windows 8 (12) WPF (8) XML - XSLT - XPath (8)

Archive

  • January 2023 (1)
  • June 2022 (1)
  • December 2021 (1)
  • November 2021 (2)
  • October 2021 (1)
  • September 2021 (1)
  • August 2021 (1)
  • July 2021 (3)
  • June 2021 (1)
  • April 2021 (2)
  • March 2021 (26)
  • October 2020 (1)
  • September 2020 (5)
  • August 2020 (5)
  • July 2020 (7)
  • June 2020 (18)
  • May 2019 (1)
  • March 2019 (1)
  • February 2019 (5)
  • January 2019 (7)
  • December 2018 (3)
  • November 2018 (1)
  • October 2018 (5)
  • September 2018 (5)
  • July 2018 (2)
  • June 2018 (3)
  • May 2018 (1)
  • January 2018 (1)
  • December 2017 (1)
  • November 2017 (5)
  • October 2017 (2)
  • September 2017 (2)
  • July 2017 (1)
  • June 2017 (5)
  • May 2017 (1)
  • April 2017 (1)
  • March 2017 (1)
  • February 2017 (3)
  • January 2017 (2)
  • November 2016 (2)
  • October 2016 (5)
  • September 2016 (2)
  • August 2016 (2)
  • July 2016 (4)
  • June 2016 (6)
  • May 2016 (6)
  • April 2016 (4)
  • March 2016 (3)
  • February 2016 (4)
  • January 2016 (5)
  • December 2015 (9)
  • November 2015 (4)
  • October 2015 (10)
  • September 2015 (10)
  • July 2015 (4)
  • June 2015 (7)
  • May 2015 (7)
  • April 2015 (3)
  • March 2015 (6)
  • February 2015 (3)
  • January 2015 (6)
  • December 2014 (9)
  • November 2014 (12)
  • October 2014 (12)
  • September 2014 (5)
  • August 2014 (1)
  • July 2014 (14)
  • June 2014 (14)
  • May 2014 (7)
  • April 2014 (8)
  • March 2014 (5)
  • February 2014 (1)
  • January 2014 (9)
  • December 2013 (5)
  • November 2013 (9)
  • October 2013 (8)
  • September 2013 (22)
  • August 2013 (5)
  • July 2013 (1)
  • June 2013 (13)
  • May 2013 (5)
  • April 2013 (10)
  • March 2013 (2)
  • February 2013 (3)
  • January 2013 (3)
  • December 2012 (5)
  • November 2012 (9)
  • October 2012 (8)
  • September 2012 (2)
  • August 2012 (2)
  • July 2012 (9)
  • June 2012 (3)
  • May 2012 (12)
  • April 2012 (4)
  • March 2012 (14)
  • February 2012 (8)
  • January 2012 (11)
  • December 2011 (16)
  • November 2011 (14)
  • October 2011 (11)
  • September 2011 (3)
  • August 2011 (7)
  • July 2011 (2)
  • June 2011 (7)
  • May 2011 (16)
  • April 2011 (10)
  • March 2011 (4)
  • February 2011 (3)
  • January 2011 (15)
  • December 2010 (6)
  • November 2010 (15)
  • October 2010 (9)
  • September 2010 (13)
  • August 2010 (22)
  • July 2010 (8)
  • June 2010 (27)
  • May 2010 (11)
  • April 2010 (17)
  • March 2010 (40)
  • February 2010 (12)
  • January 2010 (24)
  • December 2009 (29)
  • November 2009 (3)
  • October 2009 (23)
  • September 2009 (13)
  • August 2009 (10)
  • July 2009 (4)
  • June 2009 (31)
  • May 2009 (81)
  • April 2009 (14)
  • March 2009 (25)
  • February 2009 (4)
  • January 2009 (4)

Search

Archives

  • January 2023
  • June 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • April 2021
  • March 2021
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • July 2018
  • June 2018
  • May 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009

Meta

  • Log in

Categories

  • Learned Today
  • Uncategorized

Construction WordPress Theme By Themespride