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
  • 0 Votes
    3 Posts
    1 Views
    I
    Generate Script Compatible to older version Best Of Regards, SOFTDEV If you have knowledge, let others light their candles at it
  • finding database physical path

    database sharepoint question
    3
    0 Votes
    3 Posts
    1 Views
    M
    Try the following.... USE master GO DECLARE @DB_Path nvarchar(256) SET @DB_Path= (SELECT SUBSTRING(physical_name, 1, CHARINDEX(N'master.mdf', LOWER(physical_name)) - 1) FROM master.sys.master_files WHERE database_id = 1 AND file_id = 1) SELECT @DB_PathA S PhysicalPath It uses the built-in “master” database, finds the physical path to it from the “master.sys.master_files” view, then takes a substring to get just the path portion. Thanks Md. Marufuzzaman Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you. I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
  • deploy using backend

    csharp database sql-server sysadmin tutorial
    3
    0 Votes
    3 Posts
    1 Views
    V
    Use Sql Server 2005 express edition. which gets saved as .mdf format in your application path. Connect to it. Express edition is best suit for small business. vijayaraya
  • Running a query

    database sql-server sysadmin tutorial question
    2
    0 Votes
    2 Posts
    1 Views
    N
    Use Triggers. :)
  • 0 Votes
    4 Posts
    1 Views
    D
    When you concatenate DBNull.Value into your query expression, it calls the DBNull.ToString method. This is defined to return an empty string, so your insert statement is missing a parameter after the final comma. Use the literal "null" in your SQL insert instead of DBNull.Value, that should work. Or use a DbCommand with query parameters, as someone else suggested.
  • 0 Votes
    6 Posts
    1 Views
    N
    :)
  • Openrowset across a network

    help question learning csharp linq
    4
    0 Votes
    4 Posts
    1 Views
    M
    OPENROWSET: Includes all connection information necessary to access remote data from an OLE DB data source. This method is an alternative to accessing tables in a linked server and is a one-time, ad hoc method of connecting and accessing remote data using OLE DB. The OPENROWSET function can be referenced in the FROM clause of a query as though it is a table name. The OPENROWSET function can also be referenced as the target table of an INSERT, UPDATE, or DELETE statement, subject to the capabilities of the OLE DB provider. Although the query may return multiple result sets, OPENROWSET returns only the first one. If you use any network path, please confirm that your SQL login user is permitted to perform bulk load on the Operating System. I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison. Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you. Thanks Md. Marufuzzaman
  • SQL SERVER TRIGGERS

    database sql-server sysadmin help question
    14
    0 Votes
    14 Posts
    1 Views
    M
    I think you can create a stored procedure for the insertion and call it from a SQL job that's it; I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison. Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you. Thanks Md. Marufuzzaman
  • Table Structure for Product -> Book

    question csharp lounge learning
    6
    0 Votes
    6 Posts
    1 Views
    A
    OK, ProductType would be Book, ProductCategory would be NonFiction Product: ProductCategory would be NonFiction Name would be Book Title You could then select from your tables as so: SELECT * FROM Product p JOIN ProductCategory pc ON p.ProductCategory_ID = pc.ID JOIN ProductType pt ON pc.ProductType_ID = pt.ID WHERE pt.Name = 'Book' this gives you much flexibility selecting by Type, Category and Name _etc... Hope this makes things clearer. Create a dummy DB in SSMS and generate a Database diagram - the structure will become clearer. I don't speak Idiot - please talk slowly and clearly I don't know what all the fuss is about with America getting it's first black president. Zimbabwe's had one for years and he's sh*t. - Percy Drake , Shrewsbury Driven to the arms of Heineken by the wife modified on Thursday, October 1, 2009 6:27 AM _
  • pivot error

    database sql-server sysadmin help question
    4
    0 Votes
    4 Posts
    2 Views
    I
    It works fine on my machine! I am running Express 2005 but I have the extended Northwind database from http://www.linqdev.com/PublicPortal/publicportal/home.aspx[^].
  • Current & Backedup database records out of sync problem

    database security help
    6
    0 Votes
    6 Posts
    0 Views
    M
    That is one of the weirdest business models I have EVER heard of (in 20+ years of hearing some really screwy ideas). A backup is NOT a data storage tool it is a RECOVERY tool, deleting data from a backup defeats the purpose of taking a backup. It is a snapshot of the database as at WHEN IT WAS BACKED UP. Expecting a backup to reflect the current data is just wrong. Never underestimate the power of human stupidity RAH
  • 0 Votes
    3 Posts
    1 Views
    J
    for the first question do you suggest to me to have a table design as suggested here http://social.msdn.microsoft.com/Forums/en-US/sqlgetstarted/thread/9b781fae-a12d-4405-9a6e-9dd5421b4fc4/[^] Fields FieldID FieldName 1 Website 2 Home Phone 3 MSN (the fieldnames will be user created) Field Values ContactID FieldID FieldValue X 1 Hotmail.com X 3 Abc Y 2 65766786786 Y 1 msn.com have I understook properly. or haven't I :confused: the solution for my second requirement works like a breeze :cool:(yikes why didnt I think of this) hi hi hi hi
  • how to backup oracle 10g

    database sql-server oracle sysadmin tutorial
    2
    0 Votes
    2 Posts
    1 Views
    M
    I thought the title was dumb - and even had this ready for you backup[^] but then I read the content. Correct me if I'm wrong but you seem to be asking if you can back up an Oracle database and restore it into SQL Server, assuming I have not completely misinterpreted you question. You CANNOT do that. There may be tools around that will allow you to generate a script from Oracle to create the equivalent database in SQL Server and then query the data across but backup is not going to work.
  • Set password for a SQL database ? [modified]

    database question
    4
    0 Votes
    4 Posts
    1 Views
    A
    dotnet buddy wrote: AFAIK, We cannot set user id and password to the database files(.MDF and .LDF). Correct. I don't speak Idiot - please talk slowly and clearly I don't know what all the fuss is about with America getting it's first black president. Zimbabwe's had one for years and he's sh*t. - Percy Drake , Shrewsbury Driven to the arms of Heineken by the wife
  • SSRS - Web Service vs URL access

    sql-server visual-studio question
    3
    0 Votes
    3 Posts
    1 Views
    D
    um... I've written apps which accesses SSRS reports via URL access, and I've written apps which accesses SSRS reports via Web Services. This article is for someone who hasn't done it... dev
  • How to edit a view

    question announcement database sql-server sysadmin
    2
    0 Votes
    2 Posts
    1 Views
    A
    You can't update a multi-table view, thats what your problem is. Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP
  • hierarchy

    question database
    3
    0 Votes
    3 Posts
    1 Views
    I
    The following code uses the Employees table from Northwind. WITH EmployeeStructure AS ( SELECT employeeid, reportsto, 0 as level FROM Employees WHERE reportsto is null UNION ALL SELECT e.employeeid, e.reportsto, level + 1 FROM Employees e INNER JOIN EmployeeStructure es ON es.employeeid = e.reportsto ) SELECT * FROM EmployeeStructure WHERE EmployeeID NOT IN (SELECT reportsto FROM EmployeeStructure GROUP BY reportsto HAVING ReportsTo IS NOT NULL) ORDER BY level ASC
  • 0 Votes
    6 Posts
    1 Views
    T
    As others have said, this is going to be a tedious manual process. I work with Ingres and SQLServer on almost a daily basis; Ingres isn't PostreSQL, but I'm assuming it isn't too far off either. If you have the scripts to create tables, etc, can you write a script to extract the table name, columns, datatypes and null settings? Having these, you should then be able to script the tables creation in SQLServer. I will help as I can. Tim
  • XML Column in SQL Server 2005

    database sql-server sysadmin xml help
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • run date query in nvarchar type, how ?

    database question
    6
    0 Votes
    6 Posts
    1 Views
    L
    Mycroft Holmes wrote: As we are no longer encouraged to beat them with the sarcasm stick Sigh , I see no reason not to scream it in their face. Even though neither method has the desired effect in too many cases :mad: