Skip to content

Tag: sql-server

Is this possible to calculate this?

Is this possible to store the decimal type value in number column. 1/12 will be 0.083 and wants to store that in that column. create table test(number1 int,number2 int,number float) insert into test …

Split string value and use in INSERT and UPDATE command

I Implemented a small ERP system for our kitchen. The system is used to track our groceries, so it contains the goods (referred as food) with its name and UPC code. Over the time the names and upcs started to overlap and creating a data problem. In a first attempt we started to add the manufacturer into the n…

Pivoting a string from a table function in different columns

I have a task to create a table function that receives a string and sorts it into different columns. The string itself may vary, but the columns are supposed to be the same always. The string is: ‘100^TEst¬200^TEst2¬300^Test3’, but for example if I add “¬400^Test4” that should be in th…

Query on how to replace numerical data from a string/column

I have values in my column as below. Can anyone help me with how to replace any numeric data present in a column or string to blank using SQL Server query? Below is the column data. How do I replace the numbers to blank and display only underscores. Answer You could approach this by counting the number of und…

Stored Procedure not working with variables

I have a stored procedure as follows: When I run the above by passing the search variable as 04029125070527 I get no results. But if I edit my stored procedure as follows, I get a result. The only difference is in the above I’m trying to send the variable and in the second its hard coded (not what I wan…

SQL Update Multiple columns with counts

We currently have SQL update statements that works for our needs and updates the tbl_rprt table. Below are some of the update queries, there are several others like them. I was wondering if there was another way to get this done, maybe combining all of them into one SQL statement. #tbl_rprt is a report of all…