I passed this stored procedure into ssrs to generate a report but kept getting error converting data type nvarchar to int, while i don’t even have any parameter that’s nvarchar type. end Answer I definitely would not write it off as just random, you don’t want this popping back up when certa…
Tag: sql-server
Finding employees who are not managers
I have a table where we have staff_id and manager_id. Attached screenshot. I found managers by using this query: select e.first_name as employee , m.first_name as manager from sales.staffs E inner …
How to substract Table1 values from Table2?
Table1 contains ColumnA, Table2 contains ColumnA and ColumnB. How do I remove(delete) rows in Table2 that contain ColumnA values in both tables?
How to merge two rows having same data?
i have a table with some data i want to merge the identical row i.e.as shown in image two identical rows having same tDateWorked,empid,jobid i want to merge this records so that OT and ST should …
Extract only dates for first Day of Month from a daily Date Dimension Table without nesting
I am using SQL Server 2014 and I have the following T-SQL query which retrieves the dates of the first day of each month (based on my filters) from a Date Dimension Table: SELECT * FROM ( SELECT …
Can we Apply Group By on two columns in Sql Server 2017?
How to get last message of all users who did chat with UserID 1. I want to apply group by on two feilds. The Database is like: MessageID Message MessageCreatorUserID MessageRecieverUserID …
datediff for row that meets my condition only once per row
I want to do a datediff between 2 dates on different rows only if the rows have a condition. my table looks like the following, with additional columns (like guid) Id | CreateDateAndTime | …
Selecting all foreign rows for each row useing a N-N table
I have a N-N table, lets say as an example Teachers and Subjects: There is a Teacher table as follows: There is a Subject table as follows: And there is a TeacherTeachesSubject as follows: Only that each table has more than 10000 entries. I need to make a query which returns me something like this: What I am …
Pivot Table with Dynamic
My quest might be answered in somewhere here but I couldn’t find. So, sorry if I asked in vain. I have a Table that’s populate automatically with precisely date/time in SQL Server and looks like …
Is a non-clustered index implicitly created for each foreign key in a table?
If I have a table like so: CREATE TABLE MyTable ( Id INT PRIMARY KEY IDENTITY(1, 1), FooId INT NOT NULL FOREIGN KEY REFERENCES Foo(Id), Data NVARCHAR(10) NOT NULL ); The following …