Running DBCC commands on SQL Azure db
Hi All,For tuning poorly performing query on a Testing server or local SQL instance on a Laptopn, we used to run below 2 commands to free the plan cache and buffer cache to properly measure query...
View Articlecomputed columns
Hi,With some googling, I learnt that SQL Server doesn't have persisted column names (like Netezza supports, for instance), which demands each of the computed columns to be (re)calculated as standalone...
View Articleadding 365 partitions to existing scheme and fucntion in sql server 2014
HiMy tables are partitioned on business date. My requirement is to add 365 partitions for next year to existing partition function and scheme.
View ArticleHow to get TOP ID in query?
[code language="sql"]USE [iMIS_Prod]GOCREATE TABLE [dbo].[Orders]( [ORDER_NUMBER] [numeric](15, 2) NOT NULL CONSTRAINT [DF_Orders_ORDER_NUMBER] DEFAULT ((0)),&n
View ArticleRow count differences with CTE vs Temp table Vs view
Hi All,Just for curiosity to see if anyone else has come across an issue like this - SQL 2014 - not sure of the SP/CU at the momentrather similar queries 1 - single query made of 2 CTE's and final join...
View ArticleConditional CONDITION - CASE in WHERE
Hi,I have a requirement where I need a SELECTIVE condition under WHERE clause which has to be applied to "certain records" only, not all.I don't want to UNION the two sets of results, which could be...
View ArticleI got date conversion error
Dear colleagues,I got a very peculiar situation. Here is my code:[code language="sql"]Declare @startdate as datetimeDeclare @enddate as datetimeDeclare @newfee as moneyDeclaRE @oldfee
View ArticleNull Value Behaving Weird in SQL Query
Hi Guys,Need help to understand, Please help me to understand....Here is my sample dataID,FNAME,LNAME,STATUS1,Smith,Sam,Active2,Faid,Kim,Null3,Jim,Al,NullMy Simple SQL Query is
View ArticleIssues with matching pattern using LIKE
Why in God's name does this not work? expecting "dateFirst":[code language="sql"]
View ArticleTo Index a Computed Column...
Hi All,So in an effort to optimize a larger query (which I've posted about here before), I'm trying to utilize comput
View Articleproblem using stored procedure output in visual studio table adaptor
Hi guys. I'm using existing stored procedures from DB to use in Table Adapters that outputs datasets. We use these datasets as the datasource in reports. It's a routine job as you know. But I have this...
View ArticleDistinct of two columns?
Hello all,Hoping someone out there can help with this because I'm just not seeing the answer for some reason, and it seems like it should be a fairly easy one. If I can just get some ideas on the...
View ArticleCoffee sales for just 7am to 8am but for the entire year?
[code language="sql"]select * from TicketItemwhere s_item IN('Coffee', 'Espresso', 'Double Espresso', 'Decaf Espresso', 'Cappucino', 'Latte', 'Iced Coffee', 'sm coffee pot', 'lg coffee pot') and...
View ArticleSQL XML - Font colour in a case statement
Hi, I've written a few SQL XML statements before where I can change the font colour and size using case, when, then colour = xxxBut how do I code it to change colour based on the output of a case...
View ArticleUsing hardcoded database names in query when database names are different on...
I have a database 'DatabaseA' which exists on a development server and a production server (called 'DatabaseA' on both servers). I am creating stored procedures that select or retrieve data from tables...
View ArticleSplit a Record using Substring
Hi All,I have records stored in a table in below formats . Want the result in an arranged format as shown below. I tried with substring but not get it as required. Can anyone help to get it...
View Articleis there a way to auto-gen crud sprocs in ssms 2017?
Is there a way to auto-gen CRUDsprocs in SSMS 2017? For example, a basic User table might just need cookie cutter CRUD sprocs. I know there were some after-market tools that auto-genned sprocs for a...
View ArticleOverriding error message sent back
I have a table with a constraint on 2 columns (Which are keys into 2 other tables) and I want to prevent duplicationsI am using Entity Framework and message sent back to application if violation is...
View Article