Create a scalar function (or not)
I always assumed that there would not be much difference of performance between selecting a complex expression and selecting a scalar function encapsulating the expression until I encountered the...
View ArticleDate Field Calculation Logic
Can somebody please help with this issue.../*Here’s the problem: Let's say we had a table of all US Presidents, with the date they took office and the date they died. Let's say I want to get the...
View ArticleKeeping huge free spaces in data file can make query slower?
Dear All,I need some info for the following 2 questions. Any idea please?1. Keeping huge free spaces in the data file can make my query performance slower?2. If I stop DB shrink function, how to...
View ArticleFind substring that includes the second dash, plus one character
ok, getting weird here.I need to join on this column:AUTO_VALUE5S4T-12A522-ABut the field with the join value is the Prod_ID in another table. That PROD is like:5S4T-12A522-AB or 5S4T-12A522-ACD, etc.I...
View ArticleData population slows down application performance
We need to load data from source table to summary tables on daily basis. But we don't want to slow down our application performance while data population as the data is fetched from summary table using...
View ArticleFunction Information
I wrote this for a user on another forum. I figured I'd drop it here too in case anyone might find it useful.[code language="sql"]SELECT o.name, o.
View ArticleSSIS not loading all Rows to the destination table
Hi Guys,I am new to the SSIS world and creating a simple package to load data from Flat File OLE DB connection to OLEDB SQL Server Destination. I am running into a weird issue that my Data Flow Task...
View ArticleTSQL query suddenly taking hours to run
Hi,I have a query that has suddenly started taking hours to run instead of a few minutes. I have tried updating statistics and forcing a recompile but it's still performing really badly. Looking at...
View ArticleRecursive CTE for Supervisor Hierarchy WITH Effective Date of Reporting...
I have a standard recursive CTE for getting my current supervisory hierarchy. I use it to rollup timesheet "utilization" information under some level of manager based on whether someone was working on...
View Articledoes use of large datatypes where much smaller ones will do, affect performance?
when a table has one hundred columns, where 40 of them have datatypes far exceeding the max(len()) of data actually in them, will this alone impact query performance?Breakdownvarchar(100) - 19 ha
View ArticleSubtracting in dynamic SQL
I was updating a stored procedure to change the reporting time to clients timezone. The stored procedure is comprised of a dynamic SQL, which contains the time @timeoffset parameter of smallint data...
View ArticleHow to overcome missing 0x for varbinary?
I have a virbinary(MAX) column which contains an encrypted data. We use standard encryption method EncryptByKey(Key_GUID.... to decrypt the data. All works well, but for some of the records the...
View ArticleCorrectly using AVG() for partial table samples
I track base station performance in an RF network by storing SSI values in this table:[code language="sql"]TABLE BASE_SSI: wayside BIGINT timestamp datetime re
View ArticleBEGIN vs BEGIN TRY
I just want to be 100% sure... Do the following two statements execute identically? Meaning, can I use the 2nd one, or do I need the extra BEGIN/END as in the 1st one? Thanks![code language="sql"]IF @blab
View Article[N]Varchar(4000) and Performance
Hi,What are the disadvantages of using many columns with varchar (4000) or nvarchar (4000) in terms of performance, DB size, index size (CI, NCI, CCI) and IO? Some developers argue that anyway only the...
View ArticleSelect only one register with condition
Hi Guys,I need a help for a query development that returns only one record according to the condition. But if condition is not true, query should select other value. for example:SELECT Field FROM...
View ArticlePowerShell Scripts Passing Multiple Variable to SQL Scripts Encounter Errors
Hi experts,I'm new in SQL Server, I hope you can give me some guideline.I got issue when passing 2 variables from Powershell script to SQL Script. I really no idea what is went wrong. The error
View ArticleHow to create a calculated column that encodes in base64
I am trying to create a calculated column which is a single other column but encoded in base64. I have seen select statements that use FOR XML to return a base64 encoded string, however I get a syntax...
View ArticleData conversion of linked sets
I have a table that lists linked warehouse locations. The previous design was to link each location id to every other location in it's set. I want to convert this to a master location id and child ids...
View Article