Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago. Improve this question I have a stored procedure which update records. Can anyone help me how to …
Tag: sql-server
Percentage from Total SUM after GROUP BY SQL Server
I have these results: With the table like: These are grouped by the person. Now I’m looking to add a column with the percentages for each person calculated from the total of all of their sums. For example: the total sum is 300, and hence I need a result like this: I have looked at code online and I have
Convert time float to format HH:mm sql server
I need to format a float decimal number into a time format hour:minute. I wrote this Scalar-Value Functions with an input float and output varchar(6): It looks like great, but not for everything records. This is my output: As you can see from the results, there are 3 wrongs conversion: 0.33 = 00:19 // 0.58 = …
Getting error while creating View in SQL server
Hi Could any one please help me while creating a view in SQL server toad I’m getting below error.Thanks in Advanced. Error:- SQL Server Database Error: Incorrect syntax near the keyword ‘with’. Answer A CTE must be the first part of the batch, docs are here. Change the body of your view to s…
MySQL result Group by two values
I need some help for a query to group some rows, I’m trying the whole day and find no solution and I’m sure it’s easy. Maybe some one can bring me light in the dark: My Table: id | Bid | Cid | value …
SQL Server – How to alter column nvarchar length without drop
I’m trying to alter the length of the column “Body” in table “Post” like this: ALTER TABLE Post ALTER COLUMN Body nvarchar(8000) NOT NULL; The column is defined as nvarchar(4000) and it gives me …
Execute procedure in statement in NOT IN()
I have the following stored procedure in SQL Server CREATE PROCEDURE storedProcedureExample (@displayName NVARCHAR(256)) AS SELECT users.id –user.id is INT FROM users WHERE users….
SQL extract data to Excel using Powershell
I want to extract data from SQL server to a new excel file using powershell . For small data set my code works but some tables has more than 100.000 rows and this will take ages. The reason why I don’t use the utility in SQl server is because I want to extract mutilple tables. Is there a way to
Msg 242: conversion of a varchar data type to a datetime data type resulted in an out-of-range value
I have gone through a bunch of posts here with this error and tried changing data types and used Convert but nothing seems to fix this. So I would like to ask for some help here. I will try to give as much info, but feel free to ask if its not enough. This is where I am getting the
Sql query to Count Total Consecutive Years from latest year
I have a table Temp: I want to calculate the total consecutive years starting from the most recent Year. Result should look like this: Answer e.g. for ID=1: As long as there’s no gap, both sequences increase the same. Now check for equal sequences and count the rows: Edit: Based on your year zero commen…