Skip to content

Database

Discussions on database access, SQL, and ADO

This category can be followed from the open social web via the handle database@forum.codeproject.com

17.1k Topics 61.8k Posts
  • How to replace six chracters from middle from any string ??

    tutorial question
    4
    0 Votes
    4 Posts
    0 Views
    K
    SELECT STUFF('9334459875',3,6,'******')
  • 0 Votes
    13 Posts
    0 Views
    M
    I use id_memberships GUID PRIMARY KEY DEFAULT GenGUID() NOT NULL But I can do in Update Request SQL :( Have you an idea how do the Update ?
  • Send email from a stored procedure

    database sharepoint sql-server sysadmin question
    8
    0 Votes
    8 Posts
    0 Views
    L
    Please read here Try Catch in SQL - Reporting stored procedure error in email and also log the error in a table[^] You can see an error mechanism also in that link. Cheers :)
  • 0 Votes
    5 Posts
    0 Views
    B
    Let me add another important step to Richard's answer: divide and conquer Split the problem into smaller pieces until you can solve each of those smaller pieces. If you can't solve it yet, try to split it further. In case you are later stuck with a specific problem, come back to this site and ask a specific question.
  • Delete duplicate fingerprint

    mysql com question announcement
    3
    0 Votes
    3 Posts
    0 Views
    B
    Not sure with self-joins in MySQL. This query should show you all the duplicates (assuming ID is the identifier in the table): SELECT * FROM fingerprint t1 inner join fingerprint t2 on t1.created_date=t2.created_date and t1.created_time = t2.created_time and t1.employee_number=t2.employee_number Where t1.ID Next, change SELECT * to SELECT t1.ID to get the ID values of the duplicates only, then do a delete query with a subquery: DELETE FROM fingerprint WHERE fingerprint.ID IN ( SELECT t1.ID FROM ... (see query above) )
  • SSRS - Problem with sorting

    question sql-server algorithms help
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • 0 Votes
    2 Posts
    0 Views
    M
    This will be a permissions issue. Your executing sp doors not have permission to use master system procedures Never underestimate the power of human stupidity RAH
  • alphanumeric number generation

    database question
    5
    0 Votes
    5 Posts
    0 Views
    G
    You are welcome.
  • How do I sort the table? like the sample

    question database
    3
    0 Votes
    3 Posts
    0 Views
    G
    See this link for a good example and syntax help. SQL ORDER BY Keyword[^]
  • Select records between day, time 05:00:00 and day+1 until time 05:00:00

    help
    18
    0 Votes
    18 Posts
    0 Views
    C
    select * from Staging.[dbo].AD where DATE_CREATED between '2013-03-08 05:00:00' and '2013-03-09 05:00:00' -- I hope i will help u...
  • Employee Year Calculation

    database com help tutorial question
    7
    0 Votes
    7 Posts
    0 Views
    Kornfeld Eliyahu PeterK
    That does not matter to SQL - it has the requested knowledge to handle the 29th of February... In fact if you are working with 365 days you have to know when to add 365 or 366 to land on the right date - otherwise you will always get 28 of February. If you work with year you will move between 28 and 29 as it proper to the year... I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
  • HTML content to be formatted

    html css help tutorial
    3
    0 Votes
    3 Posts
    0 Views
    K
    Please go through my first line. "I have HTML content in string variable (from to ) within store procedure" As i mentioned, this need to be achieved in STORE PROCEDURE. How to do this?
  • MySQL CREATE EVENT Question

    question mysql com announcement
    2
    0 Votes
    2 Posts
    0 Views
    L
    Jassim Rahma wrote: and can you rely on MySQL ..well, if they say they implement a timer, you can rely on it that it works as described in the manual :) Jassim Rahma wrote: or it's better to have a process in Windows task Scheduler That depends on your needs. If you are modifying data at a specified interval, then it might best be done in the database. If it doesn't need the database, then it would be better of in the task scheduler. Another big difference (does not make one better than the other) is how they are managed, and the person who has those permissions. For the task-scheduler that's the local Windows-admin, for MySQL it is probably the MySQL SA. Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
  • 0 Votes
    3 Posts
    0 Views
    Richard DeemingR
    I'm repeating myself here: Don't use string concatenation to build a dynamic SQL query. Your code will be susceptible to SQL Injection[^]. If you really need to use a dynamic query, use sp_executesql[^] to execute it: CREATE Procedure sp_EmployeeSelect @EmployeeName nvarchar(50) AS Declare @SQLQuery as nvarchar(2000) SET @SQLQuery = N'SELECT * from Employee Where (1=1)' If @EmployeeName <> '' Set @SQLQuery = @SQLQuery + N' AND (EmployeeName LIKE N''%'' + @EmployeeName + N''%'')' Exec sp_executesql @SQLQuery, N'@EmployeeName nvarchar(50)', @EmployeeName However, in this case, as with all of your QA questions, you don't need a dynamic query: CREATE Procedure sp_EmployeeSelect @EmployeeName nvarchar(50) AS SELECT * FROM Employee WHERE @EmployeeName = N'' Or EmployeeName Like N'%' + @EmployeeName + N'%' "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • How to calculate annual leave - please advise

    tutorial com announcement
    3
    0 Votes
    3 Posts
    0 Views
    L
    See http://www.codeproject.com/Messages/4895088/Re-calculating-total-time-betweem-time-ranges.aspx[^]. Not exactly the same issue but the principle should be the same.
  • Problem with SSIS 2012

    database sql-server help c++ visual-studio
    15
    0 Votes
    15 Posts
    1 Views
    A
    hi, i answer myself because i found the solution: with sql server native client 10 we can't add param with subquery but this problem is resolved with SQL native client 11 (sql server 2012) thank you ;) ;) ;)
  • 0 Votes
    2 Posts
    0 Views
    L
    Does the user "SQLSERVERAGENT" have the same rights as the user that is using the command-line? Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
  • 0 Votes
    1 Posts
    0 Views
    No one has replied
  • 0 Votes
    7 Posts
    2 Views
    P
    Thanks for the tips. I definitely agree that being flexible, as far as possible, and changing things in response to design challenges that arise is important.
  • 0 Votes
    2 Posts
    0 Views
    J
    Insert new tasks like this: insert into jobs select top(1) @TaskName, groupid from jobs group by groupid order by count(*),groupid Wrong is evil and must be defeated. - Jeff Ello[^]