I am using SQL Server 2014 and I am working with a column from one of my tables, which list arrival dates. It is in the following format: ArrivalDate 2015-10-17 00:00:00.000 2015-12-03 00:00:00.000 …
Tag: sql-server
SQL Server – Deleting rows between a date range using SQL. Date conversion fails
This is the DELETE statement I wrote. There is an error that says: Conversion failed when converting date and/or time from character string. I know I have to write the correct date format, but I am not sure how that goes. This question has not been answered elsewhere because the answers I saw did not specify …
Assign Data to a User-Defined Table type from Select Query?
I have a stored procedure which retrieves three columns from multiple tables. I want to get the results in a user defined multi-valued table and pass the variable to another procedure to perform operations on the variable data. However it is not working. Any idea why it this not working? Answer The problem is…
How do identify the first character of a string as numeric or character in SQL
I need to identify the first character in my data as numeric or character in SQL Server. I am relatively new to this and I don’t know where to begin on this one. But here is what I have done to this point. I had data that looked like this: I used the right function to remove the ‘transfer fromR…
How to select from User Defined Table Type?
The above query returns me data but when I try to query the data within, it says dbo.udt_test not exists? https://msdn.microsoft.com/en-us/library/ms131086.aspx Referred to the above link, there should be no problem with the select query to display data. May I know if I missing something obvious here? Answer …
Hibernate @GeneratedValue null error for primary key
I am using Hibernate to save an object in the database. I am generating my primary key with @GeneratedValue annotation. Here is my code Vendor class I am using MS SQL Server 2012 where I have a vendor table with following columns Unchecked means its NOTNULL = true, it doesnt allow null values. Here is the cod…
SQL Server indexing includes questions
I’ve been trouble shooting some bad SQL calls in my works applications. I’ve been reading up on indexes, tweaking and benchmarking things. Here’s some of the rules I’ve gathered (let me know if this …
SQL Server – group by with row number – Gaps and Islands
I have a table with data like this I need to create a view on top of this table to have data formatted in the below format for the Flag, basically the duration for which the Flag was Y or N. (EndDateSID – 0 is currently active, so today’s date) Most customers only have a change in their Flag once,
How can I get the last 12 months from the current date PLUS extra days till 1st of the last month retrieved
Getting the last 12 months from a specific date is easy and can be retrieved by the following command in SQL-server. Its answer is 2014-08-17. What I want is to get the last 12 months but ending at 2014-08-01 (in the above case) instead of any where in the middle of the month. Answer Using DATEADD and DATEDIF…
Group rows of data from table based on a column
I want to achieve the below using SQL can anyone please help: TOP BOTTOM Rocksymbol 0 5 l 5 10 l 10 15 ml 15 20 ml 20 25 …