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
  • Get Names from Id

    question
    8
    0 Votes
    8 Posts
    0 Views
    T
    TRY THIS: SELECT Emp.EmployeeID, Emp.FirstName, STUFF((SELECT ',' + DeptName FROM Dept WHERE Dept.DeptID = Emp.DeptID FOR XML PATH('')),1,1,'') AS DeptNames FROM Employees Emp
  • 0 Votes
    2 Posts
    0 Views
    L
    anthasaurus wrote: Is this possible? Yup. Start here[^] :) I are Troll :suss:
  • SQL Joins Help

    question php database com tools
    4
    0 Votes
    4 Posts
    0 Views
    J
    Thanks Mycroft ... Jammer My Blog | Articles | DMon | SampleSort
  • delete all procedures from my database

    database sql-server sysadmin question
    7
    0 Votes
    7 Posts
    0 Views
    T
    DECLARE @sProcName SYSNAME DECLARE @iRowCnt INT, @i INT = 1, @sSQL VARCHAR(255) DECLARE @tblProc TABLE (Id INT IDENTITY(1,1), Name SYSNAME) INSERT INTO @tblProc (Name) SELECT name FROM sys.procedures SET @iRowCnt = @@ROWCOUNT WHILE @i <= @iRowCnt BEGIN SET @sProcName = (SELECT Name FROM @tblProc WHERE Id = @i) SET @sSQL = 'DROP PROC '+@sProcName PRINT 'Procedure '+@sProcName+' deleted.' EXEC (@sSQL) SET @i = @i + 1 END
  • ODP.Net Vs OleDb

    csharp database oracle visual-studio question
    4
    0 Votes
    4 Posts
    0 Views
    D
    ODP uses a lot of unmanaged code so unless you dispose every object, they will be lying around like forever. Make sure you dispose every ODP object. For connection, close and then dispose. For command, dispose each parameter explicitly.
  • In-memory

    design performance question
    2
    0 Votes
    2 Posts
    0 Views
    L
    FEMDEV wrote: what are it's pros cons? Stating the obvious first; memory is faster, but volatile. Loose the power, you loose the data. What kind of data? Are you talking about a typical database, flat files, a folder-hierarchy filled with Word-documents and indexed with Google Desktop Search, or something completely different? In all cases, I'd say that you don't want to move your entire database to a RAM-disk. If you "must", then move only the most frequent read data there - providing an extra cache-layer should prove to be easier than having a buffer in memory that needs be synchronized to disk. Now that's all been said, have a look at Velocity[^] :) I are Troll :suss:
  • Task to SQL Server 2005

    database sql-server sysadmin question
    4
    0 Votes
    4 Posts
    0 Views
    S
    Manish_84 wrote: 24 hrs to generation commission :wtf: For that few of rows, there is no way it should take that long. Common sense is admitting there is cause and effect and that you can exert some control over what you understand.
  • Update where count > 1

    database question announcement
    6
    0 Votes
    6 Posts
    0 Views
    B
    Then mark as answer. :-) I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com
  • Split a varbinary in a SELECT

    question database
    3
    0 Votes
    3 Posts
    1 Views
    R
    I think he means to retrieve it in chunks so as to be able to display a percentage meter. "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
  • Storing Time value in Access

    database csharp com tools question
    11
    0 Votes
    11 Posts
    2 Views
    C
    We have saved the 24 hr time in a text field as HH:MM That being said you need to look at what overhead is needed to convert it to a true time. By the way Microsoft Access and serious do not go together. :)
  • Over Write

    question c++ database sqlite announcement
    3
    0 Votes
    3 Posts
    0 Views
    M
    I am pretty sure SQLite is not a SQL server product. Which probably accounts for the lack of response! Never underestimate the power of human stupidity RAH
  • Structure and Format for Skype history databases.

    database question sqlite
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Get hirarchy query

    database question
    18
    0 Votes
    18 Posts
    0 Views
    P
    Have a look to this code and see whether it solves your problem, CREATE TABLE TempTree (Id int IDENTITY, Id_Project VARCHAR(100), Id_Parent VARCHAR(100)) INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Root','Root') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 1 1', 'Root') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 1 2', 'Root') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 1 3', 'Root') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 2 1', 'Level - 1 1') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 2 2', 'Level - 1 1') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 2 3', 'Level - 1 2') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 2 4', 'Level - 1 2') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 2 5', 'Level - 1 3') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 2 6', 'Level - 1 3') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 3 1', 'Level - 2 1') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 3 2', 'Level - 2 1') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 3 3', 'Level - 2 2') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 3 4', 'Level - 2 2') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 3 5', 'Level - 2 3') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 3 6', 'Level - 2 3') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 3 7', 'Level - 2 4') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 3 8', 'Level - 2 4') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 3 9', 'Level - 2 5') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 3 10', 'Level - 2 5') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 3 11', 'Level - 2 6') INSERT INTO TempTree (Id_Project, Id_Parent) VALUES ('Level - 3 12', 'Level - 2 6') CREATE PROC Dbo.Proc_TheTree (@parent VARCHAR(100)) AS CREATE TABLE #TheList (RootId int, RootName VARCHAR(100), ChildName VARCHAR(100)) CREATE TABLE #TheSearch (SLNO INT IDENTITY, ParentName VARCHAR(100), IsSearchCompleted BIT) IF NOT EXISTS (SELECT * FROM TempTree WHERE id_parent = @parent) BEGIN SELECT * FROM TempTree WHERE id_project = @parent END ELSE BEGIN INSERT INTO #TheSearch (ParentName, IsSearchCompleted) SELECT id_project, 0 FROM TempTree WHERE id_parent = @parent INSERT INTO #TheList (RootId, RootName, ChildName) SELECT (SELECT Id FROM Temp
  • Does PRINT work in sql server function

    database sql-server sysadmin question
    11
    0 Votes
    11 Posts
    0 Views
    L
    J walia wrote: Does PRINT work in sql server function??? You can convert your prints to match something like below; DECLARE @printz AS TABLE( Stamp DATETIME DEFAULT GETDATE() ,Msg NVARCHAR(MAX) ) INSERT INTO @printz(Msg) SELECT 'We are at the start of the proc' -- Do bunch o' SQL here INSERT INTO @printz(Msg) SELECT 'Something went terribly wrong here, eracing all evidence' -- Print some more INSERT INTO @printz(Msg) SELECT 'We are at the end of the proc' SELECT Stamp, Msg FROM @printz Another option that I sometimes resort to, is the RAISERROR[^] statement. To test that it'll print both statements from a sproc; try { using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection( "Server=.;Database=[YOURDBNAME];Trusted_Connection=True;")) using(var cmd = con.CreateCommand()) { con.Open(); cmd.CommandText = "testerror"; cmd.ExecuteNonQuery(); } } catch(System.Data.SqlClient.SqlException ex) { System.Diagnostics.Debug.Print(ex.ToString()); } CREATE PROCEDURE TESTERROR AS BEGIN RAISERROR (N'This is message %s %d.', -- Message text. 18, -- Severity, 1, -- State, N'number', -- First argument. 5); -- Second argument. RAISERROR (N'This is message %s %d.', -- Message text. 18, 1, N'number', 6); END Good luck :) I are Troll :suss:
  • How to query exclusion? SQL Help needed

    database help tutorial question
    8
    0 Votes
    8 Posts
    0 Views
    K
    DaoRecordsets don't work like that - presumably for the very reason you describe! 'Delete' simply marks a record as deleted and doesn't alter the record order. this also allows you to rollback changes if necessary. It's all working now though, so thanks for your input!
  • sql function

    database help
    3
    0 Votes
    3 Posts
    0 Views
    M
    You need to use the pivot function[^], assuming you are using sql server of course. Never underestimate the power of human stupidity RAH
  • Show Column Name once for similar records

    3
    0 Votes
    3 Posts
    0 Views
    P
    HAVE A LOOK THROUGH THIS LINK, http://www.projectdmx.com/tsql/rowconcatenate.aspx[^]
  • file no frequency in sql 2008

    database question
    5
    0 Votes
    5 Posts
    0 Views
    P
    May be you can do like this, SELECT TOP 5 FREQUENCY, FILE_NO FROM (SELECT COUNT(*) FREQUENCY, FILE_NO FROM ACCOUNTING_PAYMENT GROUP BY FILE_NO) A ORDER BY FREQUENCY DESC
  • access database

    database
    12
    0 Votes
    12 Posts
    0 Views
    C
    I hate when that happens.
  • Select and Update

    database c++ asp-net sqlite data-structures
    2
    0 Votes
    2 Posts
    0 Views
    L
    One normally uses a WHERE clause to specify which record(s) get updated. Remarks: - what is the purpose of Sleep(10)? - what would happen if a player's name contained a quote? - why don't you use SqlParameters instead of string concatenation? :) Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.