Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 11 months ago. Improve this question I have a table that has the following data id orderid 1 0 1 1 1 2 2 0 3 0 3 1 An id
Tag: sql-server
Add class and onclick function to HTML string from SQL Server
I’ve a query string to create HTML row and the output is Is there any way to add an onclick function and class from SQL itself? Answer It’s unclear where you want the attributes to go, but you could do something like this db<>fiddle
How to remove duplicates in CTE from VARIABLES and TEMPORARY TABLE
I was looking for this solution in internet and none of them worked properly. I decided to create variables, then accommodates it in the user defined function: It works properly, because for example I am able to return the top 10 Customer in the Furniture Category in 2011 and 2012 Then, I would like to have a…
Avoiding computed columns code duplication in SQL Server SELECT statement
I am trying to build a SELECT query which I will eventually turn into a view, once finished, where I am selecting a bunch of columns from a Table and then have a series of CASE statements to populate a calculated column. However, I am a novice with SQL and so not sure the best way to go about this.
I’m looking for a right solution to achieve the below scenario in SQL Server
I’ve a result set from a query like this below Court_id from to Available 7 6:00:00 7:00:00 Yes 7 7:00:00 8:00:00 No 7 8:00:00 9:00:00 Yes 8 6:00:00 7:00:00 Yes 8 7:00:00 8:00:00 Yes 8 8:00:00 9:00:00 No 9 6:00:00 7:00:00 Yes 9 7:00:00 8:00:00 Yes 9 8:00:00 9:00:00 No How can I achieve in column wise li…
Update unique value (String) for each insert when doing multiple insert
I am performing insert operation like follow on Microsoft SQL Server Management Studio: This insert is supposed to make few hundreds of insert. But here I want to insert scode like C000512, C000513, C000514 …. and C000511 being the latest scode entry previously present in contacts. How do I make this SC…
How to get list of custom user types for listed stored procedures?
I was able to find way to find custom user types for one stored procedure: How should I use this function for comma separated list of stored procedures? Answer If you have it available (SQL Server 2016 and newer), you can use STRING_SPLIT to split your list and then use CROSS APPLY to call the function for ea…
Rollback SQL transaction without returning an error
Consider the trigger below The idea is to stop any changes from being done to a Tasks record if it is tied to a Jobs record that has a value in the QuotationID field. It works because when these conditions are met, the changes are not saved. However, though, an error is returned to the application that causes…
Select to pull Zip code based both foreign and domestic
I need to write a T-SQL procedure where the parameter is zip code. We’ve got the following parameter declared. Sample data in table: postal_codes NULL 46383 074523632 B4H34 113601419 ZH/8600 A1G 9Z9 WN73R Wd3 3he 89136 etc. We’ve got a variety of addresses some having no postal code for certain fo…
sql query to exclude not null columns
I have below table and records Now i do not want to display the rows having null values in the columns except primary key column. I used below query to arrive the above result. But my orginal table having 72 columns how can i check all the columns for getting above result. / Answer You could check the length …