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
  • Database Restor

    help database sysadmin tutorial learning
    3
    0 Votes
    3 Posts
    0 Views
    L
    Does the service have read/write privileges on the mdf-file and read-privileges the location where your backup is located? Bastard Programmer from Hell :suss:
  • Sum the Counts

    database sql-server sysadmin help tutorial
    2
    0 Votes
    2 Posts
    0 Views
    M
    Elizabeth Rani wrote: Now i need to sum all the days and get the sum as 7 Seems to add up to 6! You can used compute after you query in the proc compute sum(Days) or put the existing query into another outer query Select sum(days) from (put your query here) Never underestimate the power of human stupidity RAH
  • Automate job schedule

    database sql-server sysadmin agentic-ai xml
    3
    0 Votes
    3 Posts
    0 Views
    S
    Here is suggestion which I have not tried with database backups but I have used from scheduling jobs with the windows scheduler. Create a batch program(text file with DOS commands, and with extension .bat). In the batch program connect to -iSQL and pass to it a .sql file that contains the backup instructions.--> That means you also have to create a .sql file. Now create a schedule in windows scheduler that executes the bat program Windows Scheduler calls mybackup.bat; mybackup.bat calls -isql which in turn calls mybackup.sql. Test the whole thing on test on test database.
  • 0 Votes
    9 Posts
    2 Views
    L
    Oops, sorry, this is my first post and I couldn't see that the question was already answered. Please ignore. I am not sure if I understand the question but here are the results of my testing... -- Original query with bits added in so I get a result set DECLARE @totalIds INT; SET @totalIds = 2 DECLARE @DeletedIDArr VARCHAR(50) DROP table #deletedIds SELECT * INTO #deletedIds FROM (SELECT 1 AS Id UNION SELECT 2) a DECLARE @Iterator INT SET @Iterator = 0 WHILE (@Iterator < @totalIds) BEGIN IF(@Iterator = 0) BEGIN SELECT TOP 1 @DeletedIDArr = CAST(Id AS varchar(50)) FROM #deletedIds END ELSE BEGIN SELECT TOP 1 @DeletedIDArr = (@DeletedIDArr + ',' + CAST(Id AS varchar(50))) FROM #deletedIds WHERE Id NOT IN(SELECT TOP (@Iterator) Id FROM #deletedIds); END SET @Iterator = @Iterator + 1 END SELECT @DeletedIDArr -- My version SET @DeletedIDArr='' SELECT @DeletedIDArr = @DeletedIDArr+CAST(Id AS varchar(50))+',' FROM #deletedIds SET @DeletedIDArr = LEFT(@DeletedIDArr,LEN(@DeletedIDArr)-1) SELECT @DeletedIDArr
  • RETURN; before END

    question css database tutorial
    5
    0 Votes
    5 Posts
    0 Views
    L
    I think I recognize a Fortran voice... :) Luc Pattyn [My Articles] Nil Volentibus Arduum
  • 0 Votes
    6 Posts
    0 Views
    L
    yousefshokati wrote: Hi And tanks for your answer You're welcome :) yousefshokati wrote: You say that When we design our database , we should design in a way that we do not have any closed path ? Am I right? I'm saying that you should normalize the design; that will eliminate all weird stuff from the design and give you something you can work with. I know that it's a bit of an investment in terms of time, but it repays itself rather quickly. yousefshokati wrote: We have MembersTable Which represents the members of teams and we have TeamsTable That represents the Team Entity Now We have to relations between these 2 . The First relation is "Plays For" which means that "Member Plays for team A for example " and the second is "Captain Of" which stands for "Members x is captain of team A" . Now if we update one of these FK s that are in tables for creating the relationships then we will get an error , won't be? Yes, you will. Normalization would state that you don't need the second entity. MembersTable MemberId MemberName IsCaptain Best wishes for the year to come :) Bastard Programmer from Hell :suss:
  • Table not updated when value not set

    sharepoint oracle announcement
    3
    0 Votes
    3 Posts
    0 Views
    J
    lionelcyril wrote: When the condition c_count = 0 is encountered I have not set the value for juriscode (ie i hv not mentioned that condition). I have noticed that when no value is set to the v_juriscode variable the table row is not updated, I wanted to know why this happens. Precluding the previous answer that statement is contradictory. If the update runs, the where condition is satisfied and no error occurs then an update did happen. There is no alternative. If an update occurs then a value will be updated. There is no such thing a "no value" unless you mean null (presumably you don't mean spaces.) If you didn't set a value then null is used. If you don't want an update if there is no value then use the code from the other response. If you want an update with a different value then set v_juriscode to a default value before you execute the rest of the code.
  • 0 Votes
    5 Posts
    0 Views
    L
    Doing a trace isn't the same as an intruder-protection, and those are both different from versioning a row. I'd suggest you create a fingerprint for the data. What are you trying to achieve/prevent exactly? Bastard Programmer from Hell :suss:
  • Grant permissions to role on another role

    database help tutorial
    2
    0 Votes
    2 Posts
    0 Views
    C
    you can create login groups and grant permissions. For Granting permissions please check below link http://msdn.microsoft.com/en-us/library/ms186717.aspx[^] Mani Prabhakar
  • how to loop over results of a select statement ?

    database help tutorial question
    3
    0 Votes
    3 Posts
    0 Views
    J
    And the following doesn't do it? select PersonelCode , MyFunction(PersonelCode), ... from PersonnelTable
  • Checking database has a table.

    database tutorial
    14
    0 Votes
    14 Posts
    0 Views
    L
    If there is a view or stored procedure with the same name, this script will fail.
  • Sending Column Name From SP to C# App

    question csharp sharepoint database
    6
    0 Votes
    6 Posts
    0 Views
    S
    Provided you don't misspell it by adding an extra 's' :)
  • how to loop over results of a select statement ?

    database help tutorial question
    3
    0 Votes
    3 Posts
    2 Views
    P
    How about SELECT PersonelCode ,MyFunction(PersonelCode), ... FROM PersonnelTable
  • Microsoft SQL Server 2008 R2 (between)

    database sql-server sysadmin help
    5
    0 Votes
    5 Posts
    0 Views
    L
    vkstarry wrote: YYYY/MM/DD always works. vkstarry wrote: MM/DD/YYYY might work depending on your date settings.
  • 0 Votes
    2 Posts
    0 Views
    L
    googling for Failed to open malformed assembly with HRESULT 0x80070008 turned up this[^]. Check your disk! :) Luc Pattyn [My Articles] Nil Volentibus Arduum
  • 0 Votes
    3 Posts
    0 Views
    L
    Access gives you the error message "No value given for one or more required parameters." when you specify a non-existent column name. It assumes that it is a query parameter and complains that its value has not been supplied. Check if the TblEmp table in the Access database contains an EmpPK column. Most probably, it does not. You might have misspelled the column name.
  • 0 Votes
    6 Posts
    0 Views
    R
    Use this SELECT TestField1 as t1_from_C_Drive From OpenRowset('Microsoft.Jet.OLEDB.4.0',';Database=C:\temp\Test.mdb;', 'SELECT * from T_Test') as b
  • You have an error in your SQL syntax!

    sharepoint database mysql sysadmin help
    4
    0 Votes
    4 Posts
    0 Views
    C
    I think just the "AS" keyword is missing from your original code. The use of CREATE OR REPLACE is valid at anytime. :) 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] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
  • colums to single row

    com help
    4
    0 Votes
    4 Posts
    0 Views
    G
    Hi.... Try This.... DECLARE @Temp TABLE(Name VARCHAR(20),Age TINYINT, Total INT) INSERT INTO @Temp(Name,Age,Total) SELECT 'Ram',26,800 UNION ALL SELECT 'kumar',36,300 UNION ALL SELECT 'Sam',34,200 DECLARE @SQLStr VARCHAR(8000) SET @SQLStr = '' SELECT @SQLStr = @SQLStr + 'Name:' + Name + ' Age:' + CAST(Age AS VARCHAR) + ' Total:' + CAST(Total AS VARCHAR) + '; ' FROM @Temp PRINT @SQLStr
  • 0 Votes
    15 Posts
    0 Views
    P
    Trusting it not to lose one big file is one thing, also trusting it not to lose many small ones is another. (Easier to back up too.)