I need to do something like this in sql: How can I do the above correctly in SQL? Basically, my startdate and enddate are strings and not datetimes because my business logic is referencing string column in another table with a date as the name of the column-But I need to loop through a bunch of columns, each column having
Tag: sql-server-2005
Trunc(sysdate) in SQL Server
What is the equivalent of: …in SQL Server 2005? Answer Recommended: This is another alternative, but it’s risky because of casting to a FLOAT. It’s also been demonstrated to not scale performance as well as the DATEADD/DATEDIFF approach.
How to detect and remove a column that contains only null values?
In my table table1 there are 6 columns Locations,a,b,c,d,e. Locations [a] [b] [c] [d] [e] [1] 10.00 Null Null 20.00 Null [2] Null 30.00 Null Null Null i need the result like …
How to use DATEDIFF to return year, month and day?
How can I use DATEDIFF to return the difference between two dates in years, months and days in SQL Server 2005 How to result that: 2 year 3 month 10 day Can anyone complete this t-sql? Answer Here’s my solution to Eric’s function: Good call on the use of ABS to handle if the start date is after the end
Selecting COUNT(*) with DISTINCT
In SQL Server 2005 I have a table cm_production that lists all the code that’s been put into production. The table has a ticket_number, program_type, program_name and push_number along with some other columns. GOAL: Count all the DISTINCT program names by program type and push number. What I have so far is: This gets me partway there, but it’s counting
Changing INT to BigInt
I have a warehouse table with 16 tons of data in it. I have a few Integer columns in it. We have to cast these into BIGINT for every query we write, because the SUM is too large to fit in an INT. We now have a new datamart under development. So we thought, why not change all these columns
Incorrect syntax near the keyword ‘with’…previous statement must be terminated with a semicolon
Im using SQL Server 2005 . I have 2 WITH Clauses in my stored procedure But the error occurs Incorrect syntax near the keyword ‘with’. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon. What are my options? Is there any splitter I don’t know about? Answer Use
Access sometimes jumps to existing record on save new record – Access2k FE/SQL2005 BE
I am really posting this out of desperation after searching around a lot for an answer and trying a few different things with no success. I have an Access database where I have recently migrated the tables to SQL 2005, Access continues to function to the users as a front-end providing forms, reports, and queries. However, since moving to the
How do I ‘subtract’ sql tables?
Its not really a subtraction I’m looking for. And I know its not a union or intersection… I have been given a long and complex stored procedure that returns a table of active and inactive documents. I have also been given a similar stored procedure that returns another table that contains only the active documents. How could I get a
SQL, How to Concatenate results?
I currently have a SQL query that returns a number of fields. I need one f the fields to be effectively a sub query sub that. The Problem in detail: If I have a table X with two columns, ModuleID and say ModuleValue, how can I write a SQL query to take the results and Concatenate it into one field: