I want to set a default value to a column while declaring a table , but the value is not constant , actually it’s based on some other data from another table . I’m interested to know if there is such …
Tag: sql
How to bypass NULL in a Lookup Table using JOIN?
In SQL (SSMS), I am trying to do a lookup using a ranging table (similar to Point_Lookup below) and what I need is to bypass the NULL scenario. Firstly, please use below SQL codes to replicate the …
Count the number of times a date appears between 2 dates. SQL
I have 2 Dates for various items that are stored in a database as such (dd-mm-yyyy): ItemID|Date Arrived|Date Left 1 |01-02-1985 |01-06-2000 2 |01-02-1985 |01-04-2000 These item should …
why does SQL server consider SS as an Umlaut-S (ß)?
When I run the below query: it returns a 6. I specifically chose ß for a function as I thought it very unlikely to appear in any of my data. This was working perfectly fine for several weeks but now all of the sudden it’s detecting ß where there is no ß and therefore screwing up my function. Will someon…
need to have data till 3 dots in SQL
I am having data query with me it gives version of windows update DECLARE @variable VARCHAR SET @variable = ‘Windows client Update’ SELECT DISTINCT (v_GS_WINDOWSUPDATEAGENTVERSIO.Version0) AS …
SQL to select records from multiple table using joins
I want a SQL select query for below scenario. I have 6 tables. 1) University Univ_id University_Name 2)College College_id College_Name Univ_id (FK) 3)Department Dept_id Dept_name College_id (FK) …
INSERT into table wherever update_time is latest
I have a table that has data about session. I want to insert hardcoded values for every new session row added at the latest time. for example, given this table with 3 session rows information added …
Calculate Duration of Two time
Hi I am new to my sql I am trying to compute the duaration of two time ex: timestart = 21:00 timeend = 03:00 result will be 06:00 my query is like this for compute but it gives me result of 18:00 I …
Query won’t convert a nvarchar(30) to a decimal
I have the following query, that when it is run gives the following error: Conversion failed when converting the nvarchar value ‘247.300’ to data type int. The query is as follows: SELECT UD….
SQL Statement // between with datetime
I have following query: select s.ScreenID, s.ScreenName, ps.ScheduleDate from Screens s left join PerformanceSchedules ps on ps.ScreenID = s.ScreenID where s.TheatreID = 2 and ((ps.ScheduleDate not …