Skip to content
Code Project
CODE PROJECT For Those Who Code

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
  • nvarchar vs varchar

    question visual-studio
    5
    0 Votes
    5 Posts
    1 Views
    C
    VARCHAR is a variable length string of ASCII characters while NVARCHAR is a variable length string of UNICODE characters.Since NVARCHAR can handle unicode characters, so it allows to use multiple languages in the database. Each ASCII character takes one Byte of space while each UNICODE character takes two Bytes of space. It means NVARCHAR takes twice as much space to store to allow for the extended character set required by some other languages.
  • Retrieving the lastest instance of a record [ SOLVED]

    question database
    18
    0 Votes
    18 Posts
    0 Views
    I
    Yes PKs do have to be unique, but I was assuming that the combination of ArticleId and DateScrapped would be unique so you could include them in a compound primary key. Otherwise, you should add a identity field to uniquely identify each row. Cross Apply and Outer Apply came in with Sql Server 2005. They are great for situations like 'Show me the last 5 orders per customer' that were very difficult before with ansi sql.
  • SQL update query

    database announcement
    10
    0 Votes
    10 Posts
    1 Views
    M
    No underscores are fine they will just irritate you, most developers try and avoid them. Take a look through most sample code in the articles and things like northwind, very few underscores. Never underestimate the power of human stupidity RAH
  • HELP: I can't verify text column is empty

    database help question
    3
    0 Votes
    3 Posts
    0 Views
    C
    It worked! Thanks for a very quick help :) :) :)
  • how to write querry for expired date

    database tutorial sql-server sysadmin
    3
    0 Votes
    3 Posts
    0 Views
    D
    thanks for code project team .it helps me alot...
  • 0 Votes
    2 Posts
    0 Views
    M
    Get a book and work through some examples. Fire up query analyser and try something yourself SELECT C.ComapnyName, B.BranchName FROM Branch B INNER JOIN Company C ON C.CompanyID = B.ComapnID Never underestimate the power of human stupidity RAH
  • sample code of oracle & c#

    csharp oracle
    2
    0 Votes
    2 Posts
    0 Views
    M
    What you have asked for is not a simple request, some of the requirements are. Create an oracle database create a table in the database create a stored procedure to return some data from that table create a C# project to serve as the client create a connection to the oracle database create a method of calling the stored procedure create a process to display the data returned by the method If you have a look through the articles there are many that do precicely that, most are going to SQL Server but that is only a connection change. Do a search on northwind to see if any articles use the sample database from MS Never underestimate the power of human stupidity RAH
  • 0 Votes
    3 Posts
    1 Views
    M
    duh.. yea I always seem to hit the wrong forum.. thanks for your help!!! =)
  • T-SQL - Select with relationships

    database question
    3
    0 Votes
    3 Posts
    0 Views
    I
    Yes you still have to do a join if you want data from both tables. A Foreign Key constraint is there to only allow non-null values that are in the parent column. The FK plays no part in the query; If you were to remove it, the query would still work just as well. By the way, your chosen style of joins is not considered to be good practice and may well be deprecated in future versions of Sql Server. SELECT * FROM TableA a JOIN TableB b ON b.ID = a.ID The primary reason for this is that if you forget/remove the WHERE clause you have a CROSS JOIN. This can't happen with the suggested approach. Ian
  • Permissions Problem? [SOLVED]

    database help question
    5
    0 Votes
    5 Posts
    0 Views
    L
    John Simmons / outlaw programmer wrote: Do I *need* to set permissions? Guess so. In PHPMyAdmin, when you create a database, you have to specify what permissions you give everyone, based on username and hostname (e.g. you can restrict a user to localhost only, no remote); there are over 20 checkboxes detailing all privileges. Are you sure you are logged into your SQL Manager with the same username/password your app is running? (Not that you have to, but that should yield the same privileges). :) Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
  • 0 Votes
    5 Posts
    0 Views
    A
    And if you read the text you will find that these misgivings have been discussed with collegues and various solutions suggested. I don't think it is as one dimensional as you have implied. I don't speak Idiot - please talk slowly and clearly 'This space for rent' Driven to the arms of Heineken by the wife
  • SQL server encryption

    database sql-server sysadmin security
    5
    0 Votes
    5 Posts
    0 Views
    C
    Jörgen Andersson wrote: Sometimes people don't want the admin to be able to see the data. That's going to make the admin's job a little tough. Jörgen Andersson wrote: Being an admin I find that disturbing. I concur. :) Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
  • Database design for a private message system

    ruby database design game-dev question
    4
    0 Votes
    4 Posts
    0 Views
    W
    Sorry, didn't get the part about folder ownership. This how I would set it up Tables: folders: id int name varchar userid int messages: id int fromid int toid int message varchar(250) messagedate datetime folderid int users: id int name varchar Then when you want to look up all messages from one person (say his id is 1) to another person (id = 2) in a particular folder (say id = 1) you would have a query like this SELECT m.message FROM messages m INNER JOIN folders f ON m.folderid = f.id WHERE m.fromid = 1 AND m.toid = 2 AND f.id = 1;
  • StoredProcedures - which is fastest and why

    sharepoint agentic-ai question
    7
    0 Votes
    7 Posts
    0 Views
    M
    See thats the reason I spend time here, never heard of parameter sniffing, sounds disgusting. There are some excellent articles out there, another tool in the ongoing fight for performance. Thanks Wout. Never underestimate the power of human stupidity RAH
  • DataGridView problem with cell coloring [modified]

    database help question
    5
    0 Votes
    5 Posts
    0 Views
    M
    Fixed my problem: private void Null\_check\_Click(object sender, EventArgs e) { for (int row = 0; row < this.dataGridView.RowCount-1; row++) for (int column = 0; column < this.dataGridView.ColumnCount; column++) if (this.dataGridView.Rows\[row\].Cells\[column\].Value.ToString() == "") this.dataGridView.Rows\[row\].Cells\[column\].Style.BackColor = Color.Red; } just needed sleep I guess...
  • stored procedur to update multiple tables

    database announcement
    3
    0 Votes
    3 Posts
    0 Views
    T
    you kind of lost the thread there with your second post, however.. Either change the tables to allow nulls, Or ensure no null values are passed to the procedure, Or best of all, use isnull checks for each insert. e.g. INSERT INTO tbcontactaddress (emp_id,city,town,street, phone) VALUES ( isnull(@emp_id, '') ,isnull(@ccity, '') ,isnull(@ctown, '') ,isnull(@cstreet, '') ,isnull(@cphone, '') ) Another consideration is that rather than passing so many parameters you may be better off passing it all wrapped up in a single XML parameter. If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles]  [My Website]
  • list all host names

    database question
    2
    0 Votes
    2 Posts
    4 Views
    L
    Member 6392036 wrote: i want which hostname have logged in past AFAIK, the information isn't stored historically. If you want to know who was online when, then you'll need to add some kind of logging. I are Troll :suss:
  • stored procedur to update multiple tables

    json announcement
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • SQL query for date

    database help question
    4
    0 Votes
    4 Posts
    0 Views
    J
    Well using # worked, but actually it expects the date to be completely reversed. So if i use 'select * from journal1 where day>#15/03/2010#' it doesn't get any results, but if i use 'select * from journal1 where day>#2010/03/15#' it is working. Is it possible to change this ? Thanks.
  • 0 Votes
    3 Posts
    0 Views
    R
    Thanks for reply, Kindly suggestexample codes. Thanks rmshah Developer