I have a particular problem, I am working with ASP.NET MVC in C# and SQL Server. The idea is that on the main screen you see a text box and a button, entering a number that brings us our data. By bringing that data, the person can choose whether they want to see if that data in a PDF. But,
Tag: sql-server
Converting a C# SQL string into a SQL stored procedure
In my C# code I have the following piece of code that I am looking at converting into SQL in a stored procedure: StringBuilder sql = new StringBuilder(“SELECT * FROM MyDatabase WHERE 1 = 1”); if (!…
How to delete sub-folder database in SQL Server?
When I create a new database, a lot of sub-folders and some tables are created, I want to ask if they are needed or not? I have tried to find ways to delete some unnecessary things but did not find a way? Answer You cannot delete them: Hide System Objects in Object Explorer Options -> Environment/Startup -…
Converting month name to month number in SQL Server
I have a column (says Period_name ) that accepts varchar value. Inside the column, I have inputs likeJan-19, Feb-19, etc. I need an SQL instruction whenever left of Period_name comes like Jan, Feb then it should convert into corresponding month number. For example Input Output The SQL query condition is as fo…
How to insert the result in the desired row? SQL Server
I need the result that I got to be inserted in the right row. That is, instead of WHERE id_prod = 1, there was something that inserted the desired result in all rows. I’m not sure I made myself clear, but I hope that you will understand. Answer I think you want There is no need to use a variable
SQL Column ID value jumps 10000 times
The ID column index jumps 10000 times. For example: From index : 5 goes to 10006 and the continues 10007 , 10008 , 10009 and then goes to 20003 , 20004 …. How I could fix the ID values and …
How to alias column into another operation
I want to use the Elias column startdate into anthor operation to calculate Answer Use CROSS APPLY to define the alias in the FROM clause. Then it is available throughout the query: Note that I added table aliases so the query is easier to write and read.
SQL Server how to find specific data across entire database
I have this script which finds all tables that contain data in column RGNCODE. I’m trying to amend this to find tables that contain a specific value for rgncode across all tables. So RGNCODE = ‘UK’. Unsure where to add this in? Answer A dynamic statement, using system catalog views, is an op…
SQL select records with current month
I have a field name textbook date field name NewMonth The data like this My goal to select the records with current month (2020-04-XX) My query and not working. Can some one correct my query. Thank you I think -1 for current month, -2 for last 2 months , -3 for last 3 months andso on Answer My goal to
How can I join a table to itself to get the values needed?
So I have a table that I’m trying to join to and I’m not quite getting everything I need. So I have a table that looks like this. I want to see if there is a way to join this table to itself to get the rest, so I see that when I see the code ‘0013’ then I should