Skip to content
Advertisement

Tag: tsql

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

How to implement a do-while loop in tsql

I’m trying to figure how to implement this in TSQL The only iterative control flow sentence provided by Transact-SQL is while (condition) sentences that first evaluates the condition and if that condition is true then execute the sentence. I’m thinking in a scenario like execute a UPDATE statement over a table until some condition triggered y the last UPDATE executed

T-SQL – Aliasing using “=” versus “as” [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago. This post was edited and submitted for review last month and failed to reopen the post: Original close reason(s) were not resolved Improve this

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

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

Advertisement