0
votes
0answers
617 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 ...
0
votes
0answers
23 views

Difference Between SP with BEGIN/END and without BEGIN/END [migrated]

I have found some SP(stored procedure) written as, CREATE PROCEDURE [dbo].[XXX] ( -- Parameters ) BEGIN --- Actual Work END and some as CREATE PROCEDURE [dbo].[XXX] ( -- Parameters ) --- ...
2
votes
1answer
80 views

How can I improve the following stored procedure?

I have created the following stored procedure which duplicates a record in a table and also all its related records in other tables however since I am a newbie to SQL I would appreciate it if someone ...
-1
votes
1answer
61 views

Using xp_cmdshell

Am I doing it fine?? Its only for setup not executed repeatedly CREATE TABLE #temp ( id INT IDENTITY(1, 1), name_file VARCHAR(500), depth_tree ...
2
votes
1answer
265 views

Returning Key Values from Stored Procedures

I wonder which is better practice when I need to return the primary key value of a newly inserted record from a SQL stored procedure. Consider the following implementations: As Return Value CREATE ...
0
votes
1answer
47 views

Daily, Weekly, Monthly Individual Tech time in task Repoert

I'm trying to create daily, monthly and weekly SQL Query report to our services time we spent int task and total billing time just want to see if I'm on right track GO --Daily SELECT ...
1
vote
1answer
79 views

Sql query to obtain totals and subtotals

I'm interested in knowing if there's a better/cleaner/more efficient way, to obtain totals and subtotals within a query, than my solution below. The query works fine but I'm just intrigued to know if ...
3
votes
1answer
84 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 ...
3
votes
2answers
116 views

Any way to speed up this UPDATE?

SQL: CREATE FUNCTION dbo.fnRandomForeNames () RETURNS VARCHAR(50) AS BEGIN RETURN ( SELECT TOP 1 [FirstName] FROM [tmp_ForeNames] ORDER BY (SELECT new_id from ...
5
votes
1answer
842 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 ...
0
votes
1answer
630 views

Data Structure for Categories and SubCategories

I have this relationship: Many Objects to One Category One Category to Many SubCategories I am looking for the best way to store this in my Relational Database? Here were some of the ways I was ...
3
votes
1answer
132 views

Getting rows from several tables where one table doesn't include the rows from the next tables

I have some entity that is spread across three tables. I have to get in a single result the following values: All the values that are in the first table but not on the second nor the third. All ...
2
votes
1answer
109 views

Refactor my simple SQL Statement

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 ...
2
votes
1answer
74 views

Critique my SQL

Table Structure ApprovalOrder int EntityCode varchar CostCentre varchar DelegationCode varchar ProjectCode varchar RoleGroup varchar Position varchar ...
1
vote
3answers
218 views

How can I improve this sorting 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, GalleryId, Order I have a unique key on ...

1 2
15 30 50 per page