Skip to main content

All Questions

Tagged with
2 votes
2 answers
3k views

SQL query to obtain totals and subtotals

The query works fine but I'm just intrigued to know if there is a cleaner solution. The data are results from a survey and I'm obtaining the counts per question within a zone and an overall zone count....
saj's user avatar
  • 123
3 votes
1 answer
243 views

Is it necessary to replace this cursor in SQL Server 2005?

The Problem I have a cursor that I am trying to replace (perhaps unnecessarily) in an attempt to clean up a stored procedure. Essentially what it is doing is counting each note for each member in a ...
Matt Susevich's user avatar
7 votes
1 answer
9k views

Splitting an address into fields in SQL

I have the following code to split an address string in T-SQL. Excepting the unit number, which is already in its own field, it would affect too much of the application to split the address into ...
Hannele's user avatar
  • 171
16 votes
1 answer
11k views

Conditional Create: must be the only statement in the batch

I only want to create this SQL function if the dependent Assembly exists. I can do it using dynamic SQL, but it seems messy and I lose syntax checking (in management studio). This function's ...
Brandon J. Boone's user avatar
2 votes
1 answer
153 views

Statistics updating SQL Query

I have the following SQL statement that I think could be improved in areas (I believe there may be a way to use where over having, but I'm not sure how and I'm sure there's a way to reference the last ...
Michael A's user avatar
  • 1,651
4 votes
1 answer
207 views

Returning the title of a record

I want to return the title of a record if one exists or the word 'invalid' if not: ...
mohsen dorparasti's user avatar
5 votes
1 answer
110 views

Adding a new record to the beginning of the approval chain from the delegation chain

Table Structure ApprovalOrder int EntityCode varchar CostCentre varchar DelegationCode varchar ProjectCode varchar RoleGroup varchar Position varchar ...
Michael A's user avatar
  • 1,651
3 votes
4 answers
2k views

Shifting records in SQL Database while sorting with algorithm

I have a table in a SQL Server database, which holds information of some images, and the relevant gallery of them. The columns are like: ImageId, ...
Saeed Neamati's user avatar
0 votes
2 answers
217 views

Query to compare execution performance metrics for the three most recent months

I've been working on a semi-awkward query in that it uses a very high number of functions given its relatively small size and scope. I was hoping to get some feedback on any ways I could format or re-...
Michael A's user avatar
  • 1,651
5 votes
1 answer
284 views

SQL - How's my formatting?

I'm somewhat new to SQL (using it in the past but only being exposed to it heavily in my current role). Unfortunately nobody at my current company has really given me any advice on formatting. How can ...
Michael A's user avatar
  • 1,651
2 votes
3 answers
149 views

Query for combining results of same query running across multiple databases

I wrote a query to run the same query across multiple databases and combine the results. While it seems plenty quick I was wondering if there is a better way to do this. ...
Dan Snell's user avatar
  • 123
5 votes
4 answers
437 views

Reduce the code in a WHERE clause without using dynamic SQL

How can I write the following T-SQL query part in a shorter way without using dynamic SQL? ...
Mithun Sreedharan's user avatar

15 30 50 per page
1
10 11 12 13
14