I have managed to make the pagination work (thanks to @zhorov) but somehow it’s conflicting with the search/filter function. Tried to put each query in each $_post to see if the select query will …
Tag: sql-server-2008-r2
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 …
Two indexes for same column and change the order
I have a large table in Microsoft SQL Server 2008. It has two indexes. One index having column A descending order and another index having the column A ascending with some other columns. My …
Show average difference between two time fields as MM:SS in SQL
I am using SQL Server 2008. I have several rows of start_time and end_time. I want to calculate the average difference between these two times in a MM:SS format. start_time | end_time 10:15:30 …
Split column data into multiple rows
I have data currently in my table like below under currently section. I need the selected column data which is comma delimited to be converted into the format marked in green (Read and write of a …
The specified schema name either does not exist or you do not have permission to use it
I am trying to create replica of my database from SQL server to another. For that I am generating script from original server and trying to run in another server. I’ve created database manually with …
How to add and subtract value from previous rows based on condition
I have a table with values Slno Type Amount 1 P 40 2 C 20 3 P 45 4 P 20 5 C 10 …
REPLACE empty string
I discover some behavior I didn’t know before. Why this line of code does not work? I can’t even have ” in where condition. It just doesn’t work. I have this from imported Excel where in some cells are no values but I’m not able to remove them unless I used LEN(”) = 0 function. Answer There is nothing to
‘MOD’ is not a recognized built-in function name
I wanted to use MOD function in SQL Server 2008R2 and followed this link but still got the message: ‘MOD’ is not a recognized built-in function name. Error: Msg 195, Level 15, State 10, Line 2 ‘MOD’ is not a recognized built-in function name. Why I can’t use this function from the link above? Answer The MOD keyword only exists
T-SQL split string based on delimiter
I have some data that I would like to split based on a delimiter that may or may not exist. Example data: John/Smith Jane/Doe Steve Bob/Johnson I am using the following code to split this data into …