Skip to content
Advertisement

Tag: sql-server

SQL check if Int is null select NVarchar

I want to check if an INT is null, and if so select a different name for the value. But I keep getting a Conversion failed when converting the varchar value ‘NAME’ to data type int I want something like.. Simply, if null select the second name, otherwise if it has a value, select the first Answer Use a case

Multiple column updates in one statement – Microsoft SQL Server

I am trying to update three columns depending on three different conditions in Microsoft SQL Server. See the following example for details How would I refactor the query if I want to do it in one update statement? Appreciate your help! Answer You don’t really need the where clauses. And we can take advantage of the fact that TRY_CONVERT() will

How we can loop over SQL Column with specific condition

Explanations: In 1st picture data we have. In the 2nd picture report we want to generate using SQL. In the last we have added table and data script Column Calculation = 2(Yes)/3(Total Column Contain Yes/NO) *100 Sample data: Answer You need to unpivot the CL values first and then implement a dynamic pivot: Results:

Between the time in SQL Server and ASP.NET

I am storing STARTTIME and ENDTIME in a SQL Server table by using ASP.NET webform. Now, as you can see in the row with timeTableID = 2, the inserted time value is 8:00 & 8:30 AM, But in the row with timeTableID = 3, the inserted time value is 8:15 & 8:25 AM, I don’t want this because its within

Advertisement