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 …
Tag: sql-server
Check If Date Falls In Period With Year Unspecified
I’ve got a table that defines several non-overlapping date periods using only month and day. It’s basically a “stocking” table for inventory items that allows you to stock different amounts across the year for seasonal businesses. Here’s an example of how a single item’s st…
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…
Create trigger to insert a column value into other column of same table SQL Server 2005
How to create trigger to insert a value in a column same as value of another column of same table of a newly inserted row in the table. Suppose I have table like below I want columnB value to be inserted into ColumnA as soon as row gets inserted into table or columnB value gets updated . But it should
SqlCommand INSERT INTO query does not execute
Hello guys I have got this code: It should insert data from textboxes: kname, ksurname, but it closes the form without showing them in MS SQL table klient Answer Missing the ExecuteNonQuery call A command should be executed to update the database…
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
Conversion failed when converting the varchar value ‘N’ to data type int
I have been finding original balances on bonds from an “Acquisition” table, for individual “performance” quarters. It has worked for every quarter, but when I attempted to run my query on 2010Q1, I received this notice: My query is: Zero balance code is telling how the bond defaulted, …
Convert Date format into DD/MMM/YYYY format in SQL Server
I have a query in SQL, I have to get a date in a format of dd/mm/yy Example: 25/jun/2013. How can I convert it for SQL server? Answer I’m not sure there is an exact match for the format you want. But you can get close with convert() and style 106. Then, replace the spaces: