I am trying to run a sql select code as below. I am trying to fetch the trans_date which will either be in asutrans or asuhistr. But the below code doesnt give me any value and nor does it fail. Do you think we can use CASE statement like that? If I run the codes separately, then it does give
Tag: sql-server
SQL Server Convert Varchar to Datetime and Find Max Value
I try to find max date from a DATE column, the column format is YYYY-MM and its of type varchar. I tried with the following SQL code: Answer You can try the below way –
Insufficient user permission performing an operation on Sql Server Azure
I am trying to re-run migration on a newly created DB in azure. DB, User, and all privileges were created from scratch. I basically granted all operation permission to the user including DB admin …
How do I extract a value from an XML column in SQL Server
I have a column SCORERESULTS in table CSE_ARCHIVEDCREDITSCORE. Score results is an XML column. <Profile id="Navigation" version="1" num="4" …
LAST_VALUE function causing error: “Invalid in the select list…” SQL
I need to pull the most recent value for a given field as dictated by entry date. When I try to use LAST_VALUE function, I get the following error message “An Error occurred while executing the …
How to findout a number between two column in SQL Server 2008
Suppose I have table called dbo.tbl_Search Id From To ——————- 1 200 210 2 212 220 3 203 215 4 225 240 Suppose, I search for No.-205 then I would to …
Looping in SQL with TempTable
I am new to SQL Server, can you please help me to write query for my scenario? I have this Table1 : Input to my stored procedure is a PolicyNumber e.g 1234 and the code should return 5 rows. I need to cover these cases: If the first payment is not cancelled, I need return that row. If the first
Pivoting Days/Hours in SQL Server From Header to Row Level
I have a list of hours that are under headings from and to. I need to Pivot those to be by days with from and to headings. I’ve tried unpivoting in Excel and Pivot in SQL Server, nothing is working. …
Receiving this error: The multi-part identifier “c.hrmort” could not be bound
All solutions point to the fact that if I’ve assigned aliases in my code, I should be using them instead of the table name itself. I have assigned alias and I AM trying to use the alias, however, I am still receiving this error. Does this have to do with using an left join? My code is as follows: Answer
How to exclude a specific row from an SQL Count
I need to exclude a certain row from a COUNT in SQL Server. This is what I have: If I remove the last AND GuestStayDetails.GuestId != @GuestId; it gives me the expected COUNT however I must exclude one of the GuestIDs. Any suggestions? Answer It looks like you are looking for overlapping time intervals —…