Skip to content

Tag: sql-server

WHERE CASE WHEN statement with Exists

I am creating a SQL query having WHERE CASE WHEN statement. I am doing something wrong and getting error. My SQL statement is like I am getting error as Msg 512, Level 16, State 1, Line 11 Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or …

How to execute SQL statements saved in a table with T-SQL

Is it possible to execute a SQL statement Stored in a Table, with T-SQL? The statements that are stored in the table are ad-hoc statements which could be SELECT TOP 100 * FROM ATable to more complex statements: I want to execute the @Query Variable that I declared from T-SQL. Is this possible? (I am running a…

Use Aggregate Function in UNION ALL result set

How can I use aggregate Functions in UNION ALL Resultset FOR EXAMPLE Result Set Would Be When I tried to get MAX(A) it returns 3. I want 6. When I tried to get MAX(B) it returns 4. I want 7. Other than Max(), Can I get another aggregate function which user defined? For example: (SELECT TOP 1 A WHERE B=5)

update data with connected ado.net layer

I’m trying to perform update operation on winform using connected ado.net layer. here’s the code using this query I’m getting exception $exception {“Dynamic SQL ErrorrnSQL error code = -104rnToken unknown – line 1, column 15rn(“} System.Exception {FirebirdSql.Data.FirebirdC…

SQL server Nvarchar parameters

I Have created an SP to search against many tables in the db based on string sent form ado the Vb code and the SQL SP is : As you can see I have declared argument in VB as Nvarchr and SQL parameter @SearchKey as Nvarchar also if I send english data in @SearchKey search returns correct data, but if