Skip to content

Tag: sql-server

How to create Audit history table table [closed]

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 …

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 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

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…