Tag: Microsoft SQL Server

SQL Server Length Function Equivalent

SQL Server Length Function Equivalent

The purpose of the Length function in SQL The SQL LENGTH function returns the number of characters in a string. The LENGTH function is available in many Database Management Systems (DBMS). The LENGTH Function Syntax LENGTH(string) LENGTH Function Notes If the input string is empty, the LENGTH returns 0. If the input string is NULL, the LENGTH returns NULL. Length Function Across Databases When working as a technical consultant, one has to work with customer’s databases and as you move from one database to another you will find that the function commands may vary–assuming the database has an equivalent function.

Continue reading

SQL Server – how to know when a stored procedure ran last

This week I needed to know if a stored procedure was running when expected during our batch.  So, here is a quick couple of SQL to answer the question: When a Stored Procedure was run last This version of the SQL gives the date for the last time the Stored Procure was run: select distinct   top 1     s.last_execution_time from  sys.dm_exec_query_stats s cross apply sys.dm_exec_query_plan (s.plan_handle) p where  object_name(p.objectid, db_id(‘<<DATABASE_NAME>>’)) = ‘<<STORED_PROCEDURE_NAME>>’ Order by s.last_execution_time desc Get a list of when Stored Procedure has been run This version of the SQL provides a list of dates of when Stored Procure has

Continue reading

SQL server table Describe (DESC) equivalent

Microsoft SQL Server doesn’t seem have a describe command and usually, folks seem to want to build a stored procedure to get the describe behaviors.  However, this is not always practical based on your permissions. So, the simple SQL below will provide describe like information in a pinch.  You may want to dress it up a bit; but I usually just use it raw, as shown below by adding the table name. Describe T-SQL Equivalent Select *   From INFORMATION_SCHEMA.COLUMNS Where TABLE_NAME = ‘<<TABLENAME>>’; Related References Microsoft SQL Server – Useful links SQL Server – Basic SQL Server Object Naming

Continue reading

Microsoft SQL Server – Useful links

Here are a few references for the Microsoft SQL Server 2017 database, which may be helpful. Table Of Useful Microsoft SQL Server Database References Reference Type Link SQL Server 2017 Download Page https://www.microsoft.com/en-us/sql-server/sql-server-downloads SQL SERVER version, edition, and update level https://support.microsoft.com/en-us/help/321185/how-to-determine-the-version–edition-and-update-level-of-sql-server-a SQL Server 2017 Release Notes https://docs.microsoft.com/en-us/sql/sql-server/sql-server-2017-release-notes SQL Server Transact SQL Commands https://technet.microsoft.com/en-us/library/ms189826(v=sql.90).aspx Related References SQL Server – Basic SQL Server Object Naming Convention Guidance

Continue reading

SQL Server – Basic SQL Server Object Naming Convention Guidance

Microsoft doesn’t provide macro guidance for naming convention, however, sometimes it is useful to have a place to start.  Also, there are times when flexibility with naming conventions are necessary.  So, here is a quick set of SQL Server naming conventions, which may be helpful if you find yourself working with a customer who doesn’t have an established set of naming convention standards and you need to assemble a set fast. Basic SQL Server Object Naming Convention Guidance Each project will have its own schema. Schema represents the project First letter of each word in table/Column starts with Uppercase. Put Underscore(_)

Continue reading
%%footer%%