I have following data in SQL Need sql queue: I have 10 tags, it is continuously logging to SQl at every 10 Seconds of intervals. Now i want create report like…..User will provide time interval …
Tag: sql-server-2008
How to use order by on a calculated field in SQL?
How to use order by on a calculated field in SQL? This is giving me ‘Total1’ column does not exist but as you see I have created it and is working if I am not using the order by clause. Answer You can do what Mureinik suggests and use the ordinal notation of ORDER BY 13, which means “order by
Select certain column only if condition met
I want to have a select that will not have fixed number of columns. Column OptionalColumn should be selected only if variable @check = 1 This is what I had (syntax is bad but maybe it explains my problem) It is crucial to have it only if @Check = 1 and not having it if @Check = 0. Is it
Select all rows and ignore the first row
I’m currently using the following SQL query which is returning 25 rows. How can I modify it to ignore the first row: I’m using SQL Server 2008. Thanks. Answer You can use EXCEPT in SQL Server 2008. For SQL Server 2012 and above, you can use FETCH OFFSET
Need to combine two columns in a table [closed]
I need to combine two column in a table using alias name select firstname as fn, lastname as ln, userid, fn + ” + ln as fullname from users Error is Invalid column name …
Add emoji / emoticon to SQL Server table
I am trying to insert emoji / emoticons to a SQL Server database but it just stores ??? instead of the emoji / emoticons. I am finding only help for SQL Server not MySQL. I tried : link but not finding answers even not able to set with : SQL Server does not recognize this command. This is only for
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 date format (in the
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 Because dbo.udt_test is a Table Type, not a Table instance. The link
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 DATEDIFF: For more
SQL : remove last comma in string
I have a text memo field in SQL table that I need to remove the last character in the field if it’s a comma. So, for example, if I have these rows, I need to remove the commas from rows 2 and 4. The output would be: Any ideas? Answer Using REVERSE and STUFF: First, you want to TRIM your