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
  • if - else statement in sql

    database sql-server help
    7
    0 Votes
    7 Posts
    0 Views
    H
    TRY THIS Declare @rowcount int select @rowcount = (Select count(*) from tableA A left join tableB B on B.bID = A.bID Left join tableC C on C.clientID = B.clientID where aID= 100) if @rowcount > 1 begin Select C.name as Client , B.Detail as Detail from tableA A left join tableB B on B.bID = A.bID Left join tableC C on C.clientID = B.clientID where aID= 100 else Select C.name as Client from tableA A Left join tableC C on C.clientID = A.bID where aID= 100 end Hope this will help :)
  • How To Convert Sql Query Result Into Report

    database tutorial
    2
    0 Votes
    2 Posts
    0 Views
    L
    thakrerakesh wrote: This way I want to print in PDF file Then you need to use some library to produce the PDF output; take a look at iTextSharp[^]. speaking as ...
  • 0 Votes
    5 Posts
    0 Views
    M
    You seemed to have picked up a stalker or someone objects to the unformatted code or you are getting a reaction to your sig! Never underestimate the power of human stupidity RAH
  • 0 Votes
    6 Posts
    0 Views
    N
    because i have backup and restore at runtime in asp .net, so if i get the query i can put it in sqlcommand in asp...
  • lan chat software

    csharp database help announcement lounge
    4
    0 Votes
    4 Posts
    0 Views
    P
    Member 9131839 wrote: provide code No. People are not going to just give you their code they worked hard for. You have to work on your own project and when you run into trouble with a part of it, then ask for help. "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
  • How can i select all dates between date range?

    database question tutorial
    6
    0 Votes
    6 Posts
    0 Views
    V
    DECLARE @TargetDate SMALLDATETIME DECLARE @InitialDate SMALLDATETIME SET @InitialDate = '06-19-2012' SET @TargetDate = '06-25-2012' WHILE @InitialDate <= @TargetDate BEGIN PRINT @InitialDate SELECT @InitialDate = DATEADD( D, 1, @InitialDate ) END - Happy Coding - Vishal Vashishta
  • Error 1064,.... please Help

    database help mysql sysadmin announcement
    2
    0 Votes
    2 Posts
    0 Views
    M
    jrahma wrote: VALUES (param_slip_month, param_slip_year) I cannot see where you set the values of these parameters! Never underestimate the power of human stupidity RAH
  • 0 Votes
    4 Posts
    0 Views
    M
    I'm curious, never having used UDTs, what requires you to use so many and what is in the types. Do you think the UDTs affect performance, normally I would not even ask but you seem to have a hoarde of them! Never underestimate the power of human stupidity RAH
  • 0 Votes
    7 Posts
    0 Views
    M
    Not sure why you have the second join to the history table. If each upload has a unique user and a unique history row, then user_id in the history table is useless information for this query. The second history join is giving you the redundant rows. Try and avoid using DISTINCT and its variations. It requires the server to do more work and therefore slow down your query. SELECT US.name, US.address, UP.file_path, UP.picture_path, HS.location FROM [user] US LEFT JOIN uploads UP ON (US.user_id = UP.user_id) LEFT JOIN history HS ON (US.upload_id = HS.upload_id) WHERE US.user_id = 5 ORDER BY US.user_id
  • function

    database sql-server sysadmin tutorial question
    4
    0 Votes
    4 Posts
    0 Views
    K
    Table-Valued functions are awesome, like a view with input parameters. Like this: CREATE FUNCTION [dbo].[Function_Name] (@inputParameter int) RETURNS table AS Return ( WHERE = @inputParameter []) Works in sql 2000+. "Go forth into the source" - Neal Morse
  • View might cause corruption?

    database sql-server design sysadmin sales
    6
    0 Votes
    6 Posts
    0 Views
    K
    Thanks for the feedback! The other vendor acknowledged that the statement was incorrect and will be providing the customer with the resources required (a readonly login + new views) to extract the requested information. Furthermore, they are making these changes standard for all of their customers...a resolution that works for everybody. "Go forth into the source" - Neal Morse
  • 0 Votes
    3 Posts
    0 Views
    L
    Does the term "SLOO" change? If not, then your key is built from multiple facts, and should be split into multiple columns. A simple identity-field would do nicely as a surrogate key, as suggested by MyCroft. Bastard Programmer from Hell :suss:
  • SQL Compound Primary Keys

    database sysadmin help tutorial question
    10
    0 Votes
    10 Posts
    0 Views
    K
    There will be two-way communicaation If it's not broken, fix it until it is
  • 0 Votes
    9 Posts
    0 Views
    L
    Fernando A. Gomez F. wrote: MSSQLSVR 2008 I should have read more carefully.. As I read, you did find 'em by now :) Bastard Programmer from Hell :suss:
  • MySQL

    database mysql sysadmin help question
    3
    0 Votes
    3 Posts
    0 Views
    K
    Hi Bernhard, Yep, i already did that but no luck. I don't understand why it return only 1 row. The work around that I did was like this. DataTable dt = new DataTable(); MySqlCommand command = new MySqlCommand(); command.CommandType = CommandType.Text; command.CommandText = "SELECT useraccess_privileges.MenuName, user_access.* FROM useraccess_privileges LEFT JOIN user_access ON user_access.UserName=useraccess_privileges.UserName"; MySqlDataAdapter da = new MySqlDataAdapter(command); da.SelectCommand.Connection = conn; da.Fill(dt); If the above code was applied then it will return the correct row number. I really don't understand why. Thanks if(you type your code here) { Messagebox.Show("You help me a lot!"); } else { You help me = null; }
  • Accessing Oracle database

    database sql-server oracle sysadmin tools
    6
    0 Votes
    6 Posts
    0 Views
    J
    SQLTools[^] if you want it lightweight. TOra[^] is at the other end of the spectrum. Both are opensource. SQL Developer and Oracle Developer Tools for Visual Studio has already been mentioned. They are from Oracle and are supported, ... sort of. You will also need to install some version of the Oracle Client which is available in several versions such as the normal Client, Instant Client or Oracle Data Provider for Dotnet. Oracle Developer Tools for Visual Studio has the Client built in. Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions
  • difficult query

    database oracle
    9
    0 Votes
    9 Posts
    0 Views
    M
    SELECT id_Applicant, name, date_of_birth, date_of_death FROM Applicant WHERE '5/30/2012' BETWEEN date_of_birth AND ISNULL(date_of_death,'1/1/3000')
  • SQL Server (image) data type

    database sql-server sysadmin data-structures question
    2
    0 Votes
    2 Posts
    0 Views
    L
    10 Mb will remain just that, unless you use a CompressionStream. Bastard Programmer from Hell :suss:
  • How to send an invitation mail in c# to a client

    csharp tutorial question
    4
    0 Votes
    4 Posts
    0 Views
    V
    You can create a Window Service for same. - Happy Coding - Vishal Vashishta
  • sql Date conversion not working in sql 2000

    database
    9
    0 Votes
    9 Posts
    0 Views
    V
    Put it like, CONVERT( VARCHAR, @To AS DATETIME, 103 ) ) - Happy Coding - Vishal Vashishta