Nondeterministic CONVERT function (when working with dates). What does it mean?
Msdn reference states that CONVERT with styles 0 or 100 when casting date and time types to strings and vice versa returns nondeterministic results. ("These style values return nondeterministic...
View ArticleRemove Last part
i have this data ELECT [item_id] ,[f2] from [Regions] 1. ُEgypt 1.1. Cairo 1.1.21. New Cairoi want to remove last part like in Egypt remove 1.and on Cairo remove last 1.and on New Cairo last 21.
View ArticleNeed to write the query for following conditions
Need to write a query to display the ENAME, SAL, COMM, HIREDATE, NEW_SAL. The NEW_SAL will be calculated by the following rule:a. If the employee has joined more than 30 years (as of the date...
View ArticleRemoving punctuation from a list of values in a 2 column table with around...
Hi I have a table with two columns and i need to bring back the 1st column as is and the 2nd column needs to come back with all the punctuation's and spaces removed. Below is an example of the values....
View ArticleGenerate ColumnStore Index through tsql
I am using partition switching for data retention. I would like to truncate the staging table, but the table has a column store index so I need to drop and recreate that columnstore index. Does anyone...
View ArticleGet only whose rows that contains max Date
Hi All,I have query that looks something like this :select 1 as Id, '2014-05-25' as ToDate union select 1 as Id, '2014-05-26' as ToDate union select 2 as Id, '2014-05-25' as ToDate union select 2 as...
View ArticleHelp Using Parameters in Query
I need to run a parameterized query. I was trying the below - but it tells me 0 rows inserted. Which piece is incorrect? I am wanting to set @BankID = to the MAX possible value of BankID then select...
View ArticleTrying to add month with a Date
Hi All,I am trying to add month with a date. it will take the earlier month and add one month . Here is my codedeclare @CollectionDate date='10-30-2014' select @CollectionDate ;WITH CTemp AS ( SELECT...
View ArticleRecord locking issues and error handling framework
Hi all,I have a number of stored procedures that are called in parallel by SSIS to rebuild tables during an overnight process in a data warehouse. I am using a common table (named PL_ProcessLog) to log...
View ArticleSet value of a field in TABLE1 to NULL - where the join between TABLE1 and...
I am working on a database where I am not able to change any of the table names / attributes / joinsI have had a look on the forum on lots of similar issues, but none really hit the nail on the head,...
View ArticleTimeout expired error when inserting into a mirrored server
We have 3 SQL Server 2012 servers. All 3 SQL Server has the same database, ie myDB. In 2 of the servers (say server A and B), myDB is mirrored, and on the 3rd server myDb is NOT mirrored. When the...
View Articleenter a value or leave blank for all
I have spent time unsuccessfully to find out how to write this t-sql on sql server 2008R2, "Enter the Empl code or leave blank for all". It's easy to do in Access query, but I don't know how to do...
View ArticleGetting an error 'sql server instead of triggers do not support direct...
Hi, I am getting the above error when i am trying to call an instead of insert triiger.What i am doing is1. I have a table EMPLOYEE.2. Created a view on that table named 'EMPLOYEE_VIEW'3. Created a...
View ArticleReturning results that fall within the current financial year
Hi Everyone,I am using MSSQL Server 2008R2 and I am interested in returning rows from a 'financial' table that fall within the current year (each row contains a 'Entered Date'). I am located in...
View ArticleSQL Server: SP become very slow, raw SQL query from the SP is still very fast
Hi! We are struggling with a strange problem: a SP become extremely slow when raw SQL is executed fairly fast. 1. we have -MS SQL Server 2008 R2 Express Edition SP1 10.50.2500.0 with several...
View ArticleQuery to rebuild index
Hi, Can anyone give me simple query to rebuild or re organise index based on fragmentation.
View ArticlePerformance Improvment for CTE
I have below query which is used in a View which checks duplicate rows and selects it for further processingwith MyCTETable (JobDefListPKey, BpaPKey,JobDefId,TacticKey,cnt) as (select...
View ArticleDisplaying column based on Random number
Hi,I have been struggling with this for hours and still can't come up with the solution. What I am looking is to display a column from the below query which equals to the random number generated from...
View ArticleSQL Server Date Time Query
Hi I have a Table which contains a date time column and has 1 row 1 columnvalue is 2009-11-13 16:27:54.000SELECT* FROM [dbo].[Audit]WITH(NOLOCK)WHERE Occurred>'2009-11-13...
View ArticleUnable to eliminate non-numeric values before CAST as numeric
HiI am trying to run a script to extract addresses which fall within a rectangle, as defined by latitude and longitude. To do this I need to be able to compare latitude and longitude values which are...
View Article