I am working on modifying the existing SQL Server stored procedure. I added two new columns to the table and modified the stored procedure as well to select these two columns as well. Although the columns are available in the table, I keep getting this error: Invalid column name ‘INCL_GSTAMOUNT’ Can anyone please tell me what’s wrong here? Answer Whenever
Tag: sql-server-2008
Combining (concatenating) date and time into a datetime
Using SQL Server 2008, this query works great: Gives me two columns like this: I’m trying to combine them into a single datetime using the plus sign, like this: I’ve looked on about ten web sites, including answers on this site (like this one), and they all seem to agree that the plus sign should work but I get the
how to convert date to a format `mm/dd/yyyy`
I’m having a sql table with date column named CREATED_TS which holds the dates in different format eg. as shown below Now I want to convert these to format mmddyyyy before as i am comparing the dates in WHERE clause of my SELECT query. I tried using but got the result as, I need the result as eg. 02/20/2012 in
sql server single row multiple columns into one column
I have table like this From this I need to create a temp table or table like this: Is there a way I can do this in SQL Server? Answer Check this Fiddle If you do want NULL values in the rest, you may try the following: This is the new Fiddle And here is the code:
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 when
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:
Select random rows with no duplicates
I need to select a random amount of rows but also ensure that the rows don’t contain duplicate Image values: ImgID Image 1637 PM1371564839.jpg 1638 PM1371564839.jpg 1639 …
Calling SQL Defined function in C#
I have written this scalar function in TSQL: create function TCupom (@cupom int) returns float as begin declare @Tcu float; select @Tcu = sum (total) from alteraca2 where pedido = @cupom …
Formula to get date field in Excel sheet SQL Server query
I have data in Excel sheet and I need to update SQL Server DB table by using Excel sheet data, I am able to write SQL Server Query and get the data. However I am not getting date field in date format, it’s rendered as a normal number. Answer In cell B2 try this –
What does SQL Server do with a timed out request?
Suppose that I use C# to run a long running SQL Server stored procedure (lets say 30 minutes). Further suppose that I put a 1 hour timeout period on the query in C# such that if for whatever reason this SP takes longer than expected, I don’t end up monopolizing the DB. Lastly, suppose that this stored procedure has a