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
  • Table Name

    asp-net csharp delphi database linq
    2
    0 Votes
    2 Posts
    0 Views
    M
    It is an excellent naming convention underscores (_) were invented because the devil (Oracle) could not work out what lower case is. Never underestimate the power of human stupidity RAH
  • command implement loop

    database oracle help tutorial
    9
    0 Votes
    9 Posts
    0 Views
    M
    Thanx. ;-)
  • 0 Votes
    2 Posts
    0 Views
    Richard DeemingR
    And what has this got to do with databases? You'll stand more chance of getting an answer if you post your question in the correct forum[^]. "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • sum of time per month

    database
    4
    0 Votes
    4 Posts
    0 Views
    K
    :thumbsup: refer this link for adding time
  • putting column 00:00

    database
    3
    0 Votes
    3 Posts
    0 Views
    M
    When building these type of query I break it down to getting the primary list (employees) and getting the data you are reporting (timesheet information) then I use a left outer join between the primary and data queries and use ISNULL to display the default values (00:00). Never underestimate the power of human stupidity RAH
  • 0 Votes
    2 Posts
    0 Views
    L
    Lefteris Gkinis wrote: 1.What is the Roles for a programmer? "SQL Server provides server-level roles to help you manage the permissions on a server. These roles are security principals that group other principals. Server-level roles are server-wide in their permissions scope. (Roles are like groups in the Windows operating system.)" Source[^] Lefteris Gkinis wrote: 2.What is the role of the Schemas owned by this… which related with them? "CREATE SCHEMA can create a schema, the tables and views it contains, and GRANT, REVOKE, or DENY permissions on any securable in a single statement." Source[^] Lefteris Gkinis wrote: 3.What is the meaning and the use for Securables in Roles "Securables are the resources to which the SQL Server Database Engine authorization system regulates access. For example, a table is a securable. Some securables can be contained within others, creating nested hierarchies called "scopes" that can themselves be secured. The securable scopes are server, database, and schema." Source[^] Lefteris Gkinis wrote: 4.Why we add Users to a Role? "Roles can simplify security administration in databases with a large number of users or with a complex security system." Source[^] Lefteris Gkinis wrote: 5.How we may handle the Roles in conjunction with to the Users, inside of a project? That depends on the project, and it's specific needs. There's no alternative but to read the entire thing[
  • NFL Hits Fox tonight

    sharepoint visual-studio com
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • How to get last 3 values from Mysql table

    mysql tutorial
    4
    0 Votes
    4 Posts
    0 Views
    L
    Member 10263519 wrote: am adding new record for every transaction,then how to get the last 3 transaction values You can't get them at transaction-level, as they don't exist at that level. A transaction can touch multiple tables, so those 3 "last values" might be all in different tables (or in the same record). If you're trying to write an audit, look into triggers. Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
  • Prevent users from playing with MySQL database

    csharp question database mysql com
    4
    0 Votes
    4 Posts
    0 Views
    J
    You move all your SQL and DML over to Stored Procedures, add one user to the database that only has permissions to use these procedures and no permissions on any tables at all. Now call these procedures from your application using this user. Make sure that the clients don't have access permissions to the database via the OS. <edit>Eddy is of course right, there's no safe way to do it, you can only make it harder for the users. Next step is to consider encryption of the tables, but the problem here is of course the same. If the database is on the machine, so are the encryption key.</edit> Wrong is evil and must be defeated. - Jeff Ello[^]
  • Complex SQL Query for Inventory. Need Help

    database help tutorial
    5
    0 Votes
    5 Posts
    1 Views
    Richard DeemingR
    chichocojo wrote: I need to generate a table with 365 records/days per year per hotel as follows: You do realise than some years have 366 days, right? :) You can generate a list of all days in a given year by using a tally-table (or a common table expression which generates a tally table), along with the DateAdd function: DECLARE @Yearint = 2014; -- Get 1st January in the specified year: DECLARE @StartDate date = Convert(date, Convert(char(4), @Year + '0101'); WITH cte1 (N) As ( SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 -- 8 rows ), cte2 (N) As ( SELECT TOP 366 ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) - 1 FROM cte1 As A CROSS JOIN cte1 As B CROSS JOIN cte1 As C -- 8 * 8 * 8 = 512 rows ), cteDates (Value) As ( SELECT DateAdd(day, N, @StartDate) FROM cte2 -- 366 rows WHERE -- If this isn't a leap-year, we only need 355 rows: Year(DateAdd(day, N, @StartDate)) = @Year ) SELECT Value FROM cteDates ORDER BY Value ; "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • Create multiple tables with a single SQL query

    database java question
    7
    0 Votes
    7 Posts
    0 Views
    K
    you can do by using loop statement
  • join query

    database tutorial
    4
    0 Votes
    4 Posts
    0 Views
    K
    refer this:~
  • database projects

    database sql-server visual-studio sysadmin xml
    2
    0 Votes
    2 Posts
    0 Views
    M
    I have trouble with the whole idea that you the owner of the database do not control who and when the code is changed. You should be controlling who ans when someone or an application updates the code Never underestimate the power of human stupidity RAH
  • Would an index make this query faster?

    database sales performance question
    6
    0 Votes
    6 Posts
    0 Views
    K
    Shameel wrote: khun_panya wrote: Because it looks like we have to scan entire Customer table anyway. What makes you think so? If execution plan shows a table scan, then either an index does not exist or the number of rows is very less to warrant an index seek. I have not checked for real execution plan. But above query do select with "no filter". So it would have to iterate all the rows in table. That's why I doubt that an index helps in this situation.
  • Optimizing a query

    question help database code-review
    2
    0 Votes
    2 Posts
    0 Views
    J
    1. You use a join. Something like this: Untested! SELECT DISTINCT CC_STRINGENTEREXIT(ems.passdatetime,emsqi.PLATENUMBER) as DetailEnterExit, CC_DURATIONENTEREXIT(emsqi.PLATENUMBER, ems.passdatetime) as DurationInZone FROM EMSINFO ems JOIN EMSQUIRKINFO emsqi ON emsqi.emsinfoid = ems.emsinfoid WHERE trunc(ems.passdatetime) = trunc(to_date('26-DEC-13 11.46.56', 'DD-Mon-YY HH24:MI:SS')) AND CC_GETNEXTENTER(ems.EMSINFOID, emsqi.PLATENUMBER, ems.PASSDATETIME) <> 0 AND CC_CheckForExit(ems.PASSDATETIME, ( SELECT ems2.PASSDATETIME from EMSINFO ems2 WHERE ems2.EMSINFOID = CC_GETNEXTENTER(ems.EMSINFOID,emsqi.PLATENUMBER, ems.PASSDATETIME) ),emsqi.PLATENUMBER) <> 0 AND ems.masterplatenumber = '150444833' and rownum <100 ; 2. Use a CTE, Something like this: Still untested! WITH bla AS ( SELECT CC_STRINGENTEREXIT(ems.passdatetime,emsqi.PLATENUMBER) as DetailEnterExit, CC_DURATIONENTEREXIT(emsqi.PLATENUMBER, ems.passdatetime) as DurationInZone CC_GETNEXTENTER(ems.EMSINFOID,emsqi.PLATENUMBER, ems.PASSDATETIME) GetNextEnter FROM EMSINFO ems JOIN EMSQUIRKINFO emsqi ON emsqi.emsinfoid = ems.emsinfoid WHERE trunc(ems.passdatetime) = trunc(to_date('26-DEC-13 11.46.56', 'DD-Mon-YY HH24:MI:SS')) AND ems.masterplatenumber = '150444833' ) SELECT DISTINCT DetailEnterExit, DurationInZone WHERE GetNextEnter <> 0 AND CC_CheckForExit( ems.PASSDATETIME, ( SELECT ems2.PASSDATETIME from EMSINFO ems2 WHERE ems2.EMSINFOID = GetNextEnter ) ,emsqi.PLATENUMBER) <> 0 AND rownum <100 ; Now, keep in mind that I don't have a clue what your functions do, so my suggestions is only to show you the methodology, It's up to you to see if it gives the right result. But you want as much of the filtering in the CTE as possible to keep the amount of data down. Wrong is evil and must be defeated. - Jeff Ello[^]
  • Conditional SQL commands: Good? Bad?

    database sql-server design sysadmin tutorial
    17
    0 Votes
    17 Posts
    0 Views
    Kornfeld Eliyahu PeterK
    Here it comes... I got a personal info table - containing id, name, user, password, address, email and phone - with 19,245,718 records. The table has PK and indexes... Run an insert/update of 108,382 records of which 32,190 where duplicated (same id). With your method it took an average of 26.77 ms/record. With the @@ROWCOUNT approach it took an average of 13.07 ms/record. Both test run on the same machine with local SQL after restart. The computer is a bit old one (one I can spare) with 4x2.93 CPU and 8GB memory, but I believe that the differences are real... I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
  • Analyser index recommendations

    database sql-server sysadmin debugging tutorial
    3
    0 Votes
    3 Posts
    0 Views
    L
    As Mycroft suggests, create the most granular index first. Indexes tend to be more useful when the distribution of data in the indexed column(s) is high. And create one index at a time and rerun the query to see how much performance improvement you've gained, if any. This way, if you find that the query has actually slowed down (which may happen sometimes), you can always disable or drop the index and proceed with the next one.
  • send mail

    sharepoint database com
    5
    0 Votes
    5 Posts
    0 Views
    L
    No, definitely spam. Veni, vidi, abiit domum
  • Database Design Tools?

    database design tools help question
    6
    0 Votes
    6 Posts
    1 Views
    C
    Thanks.
  • MS-Access finding unmatched records

    database design question
    5
    0 Votes
    5 Posts
    0 Views
    L
    If the result is correct, then yes :-\ Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]