Skip to main content

Posts

Showing posts from August, 2013

Internet shortcuts on Windows systems

Windows systems have the ability to create files that "open" in a browser.  Create a text file with a ".url" suffix and the following content. [InternetShortcut] URL=http://subdomain.domain.tld The system will even go out and grab the favicon.ico file from the site to use as the file's icon.  Naturally, longer URLs can also be used.  For example: [InternetShortcut] URL=http://subdomain.domain.tld/some/path A special note It's important to note that Windows systems will likely be particular about how this file is accessed.  Specifically, concerning making changes to the URL it points to and accessing it through "Save as…" dialogs.  For example, if trying to attach this shortcut to an email message the dialog will appear to do nothing and the system will be sluggish for a short while. A workaround is to use an additional filename suffix to prevent the system from "recognizing" the file as an Internet shortcut.  So, perhaps

Retrieve the definition for a stored procedure in SQL Server

Generally, once a stored procedure is created, the details of how it works can be forgotten.  Sometimes however, what a procedure does may need to be researched.  The following query makes an attempt to look-up the definition for a stored procedure in SQL Server . NOTE:   Set the value in the DECLARE line at the top to the procedure name to look for (partial strings are fine). NOTE:   SQL Server has the ability to encrypt the definition for a procedure.  A definition value of NULL likely means such is the case for this procedure. DECLARE @procedureName VARCHAR(MAX) = 'PROCEDURENAME' SELECT      sys.all_objects.name AS storedProcedureName     ,sys.all_sql_modules.definition AS storedProcedureDefinition FROM     sys.all_sql_modules     INNER JOIN sys.all_objects         ON sys.all_sql_modules.object_id = sys.all_objects.object_id WHERE sys.all_objects.name LIKE '%' + @procedureName + '%'

Identify an object type in SQL Server

SQL Server assigns the term "object" to a number of items.  These could be tables, views, columns, parameters, stored procedures, et cetera.  The following query can be used to identify the type of a SQL Server database object. NOTE:   The type is identified in the "type_desc" column. NOTE:   Set the value in the DECLARE line at the top to the object name to look for (partial strings are fine). DECLARE @search VARCHAR(MAX) = 'OBJECTNAME' SELECT * FROM sys.all_objects WHERE name LIKE '%' + @search + '%'

Identify the stored procedures a parameter belongs to in SQL Server

There may be times when it would be nice to know what stored procedures have parameters with a certain name.  For example, what procedures have a parameter named "username?"  Using SQL Server it's just a matter of querying some of the system tables to find out. NOTE:   Set the value in the DECLARE line at the top to the parameter name to look for (partial strings are fine). DECLARE @parameter VARCHAR(MAX) = 'PARAMETERNAME' SELECT      sys.all_parameters.name AS parameterName     ,sys.all_objects.name AS storedProcedureName FROM     sys.all_objects     INNER JOIN sys.all_parameters         ON sys.all_objects.object_id = sys.all_parameters.object_id WHERE sys.all_parameters.name LIKE '%' + @parameter + '%'