Alter DB modify log file.
I can run this command to make changes for 1 DB [code="sql"]USE [master]GOALTER DATABASE [DBName] MODIFY FILE ( NAME = N'Name_log', FILEGROWTH = 10000KB )GO[/code]Is it possible to create a script...
View ArticleFind last working day based on given start date and number of working days
Hello all,I have a business need to come up with a function that calculates the last working day (monday-friday). The reason I need this is for comparison between this year and last years data. The...
View ArticleLocal variable execution plan change.
Hi AllNot sure if I am missing something obvious here.......Who do these 2 queries generate 2 different execution plans? Query 1 generates an index seek with a lookupQuery 2 generates a clustered index...
View ArticlePartitioning - Swapin & Swapout Staging
I found this article and it was very helpful.[code="sql"]Partitioning ExampleI'm not using Staging Tables in this case.Users will be entering data directly into the partitioned Table.I should the code...
View ArticleMissing Index proposed by SQL Execution Plan
Good day,Should I create all the proposed missing index by the SQL Execution Plan? Could these slow other queries?What is the best approach for this?Thanks in advance!
View ArticleUpdate using Case Statement
Hi,From the attached 4 Tables Schema DiagramWill the below query Reduce me the ListPrice by 20% if i didn't receive the order for the last 2 years ? Jammed :(SELECT...
View ArticleError converting data type varchar to smalldatetime.
Hi All, I have a small test stored proc. I keep getting an error saying Error converting data type varchar to smalldatetime.create procedure test @TestDate smalldatetime AS if @TestDate >...
View ArticleHow to build string from column
I am trying to default a multi-select parameter in and SSRS report to be what the user selected the last time they ran a report. I query the ExecutionLogStorage table to get the row of the last run...
View ArticleShow First Order With All of User Orders
HiI Have This Table [code="sql"]CREATE TABLE [dbo].[Table_1]( [UId] [int] NULL, [Orderid] [int] NULL, [OrderMonth] [int] NULL)[/code]With These Data : [code="sql"]INSERT [dbo].[Table_1] ([UId],...
View ArticleBad performance when inserting to memory optimized table
When using normal (not natively compiled) SQL to insert values into a memory-optimized table-valued variable the performance is lower than expected.There seems to also be some kind of concurrency...
View ArticleSQL Power of 2
Hi,Can any one tell me how can I get from this [code="sql"]CREATE TABLE #Param (Name sysname NOT NULL, Value NVARCHAR(max)NULL, DefaultValue NVARCHAR(50) null)INSERT #Param ( Name, Value, DefaultValue...
View ArticlePrimary key and unique indexes question
Hi all,If I have 1 table like this currently:[code="sql"]CREATE TABLE [dbo].[tbl_MyTable]( [VhID] [int] NOT NULL, [CreatedUTC] [datetime2](3) NOT NULL, [ExtID] [varchar](50) NOT NULL, [ORS] [tinyint]...
View ArticleSSISDB question
I created a stored proc that is used to pass parameters and run an SSIS Pacakge. This proc initializes the execution, sets the parameters and finally starts the package. One of the issues I am running...
View ArticleCreate identity column in an already populated table
I need to make an already existing field an identity field. Currently, it's just an integer field, but it does contain all unique values. The database is already populated, and I can't risk losing any...
View ArticleQuery to run in TEMPDB or Stored Procedure
Two questions:* Why is it quicker to create a TEMPDB - select into that tempdb then query it than it is to just query the DB???* Can I create the table in a temp stored procedure, will this be quicker...
View ArticleNested loop join operator estimate rows is 10000 in compatibility level 2014.
A simple query joining 2 tables:[code="sql"]select * from t1 join t2 on t1.id = t2.id[/code]t1 is a table with only column id with a user defined statistic with norecompute. t1 is very volatile and...
View ArticleNeed to DELETE records from JOIN statement from both tables
Hello, I can't figure out how to delete records from both tables that are joined. The results I need to delete are based on the WHERE clause that returns the data. My delete statement is only deleting...
View ArticleHierarchy design to have equal levels in each tree.
Hi All,I have a requirement, where i need to have a equal levels in each hierarchy. I am trying to use the recursive CTE's but could not get the exact logic.I have a table as below:product_cd...
View ArticleWhere does the calculation logic is on the “SUPPLY” column come from this SQL
Hello All, I am not so very expert in SQL, Need you experts help. I have a SQL query view created long back, which has SUPPLY column being created. Want to know what is the calculation logic for it....
View Article