Is it possible to select 2 columns in just one and combine them? Example: select something + somethingElse as onlyOneColumn from someTable Answer Yes, just like you did: If you queried the database, you would have gotten the right answer. What happens is you ask for an expression. A very simple expression is just a column name, a more complicated
Tag: sql-server-2005
Eliminate and reduce overlapping date ranges
I have a set of date ranges consisting of both partially and fully overlapping dates, like this: Using T-SQL, I would like to create a new set of data, per user, with eliminated overlapping data, extending ranges and removing redundant data where needed, resulting in something like this: Cursors are fine if needed, but if I can do without them
SQL Server: Why do use SMO?
I have been working with SQL Server for a couple of years. I have heard about SMO but I don’t know anything about it. What are the benefits of using it? Should I learn and start using SMO in my SQL …
Getting result of dynamic SQL into a variable for sql-server
Executing dynamic SQL as follows in Stored Procedure: How do I use the count(*) column value as return value in the SP? Answer
Is a Primary Key necessary in SQL Server?
This may be a pretty naive and stupid question, but I’m going to ask it anyway I have a table with several fields, none of which are unique, and a primary key, which obviously is. This table is accessed via the non-unique fields regularly, but no user SP or process access data via the primary key. Is the primary key
insert char into string at multiple positions sql
how would i like to convert accounting GL number 99999999999999999 to 999-99999-99-9999.999 in a query to MSSQL server 2005 i dont need to update the data, just have the STRING be converted on …
How to find Expr#### in Execution Plan
When looking at the actual execution plan for a query in SQL Server Management Studio (SSMS), how do I determine what an expression such as Expr1052 represents? When I identify the costly parts of the query and look at the properties of that operation, there are often references only to these Expressions, or scalar operators. I want to be able
SQL server query to get the list of columns in a table along with Data types, NOT NULL, and PRIMARY KEY constraints
I need to write a query on SQL server to get the list of columns in a particular table, its associated data types (with length) and if they are not null. And I have managed to do this much. But now i also need to get, in the same table, against a column – TRUE if that column is a
How to return empty groups in SQL GROUP BY clause
I have a query to return how much is spent on-contract and off-contract at each location, that returns something like this: The problem is, I only get one row for locations that are all ad-hoc or all contracted expenses. I’d like to get two rows back for each location, like this: Is there any way I can accomplish this through
Use a LIKE statement on SQL Server XML Datatype
If you have a varchar field you can easily do SELECT * FROM TABLE WHERE ColumnA LIKE ‘%Test%’ to see if that column contains a certain string. How do you do that for XML Type? I have the following …