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
  • Correct this sql

    database tutorial question
    7
    0 Votes
    7 Posts
    0 Views
    S
    USE pubs IF EXISTS (SELECT name FROM sysobjects WHERE name = 'au_info2' AND type = 'P') DROP PROCEDURE au_info2 GO USE pubs GO CREATE PROCEDURE au_info2 @lastname varchar(30) = 'D%', @firstname varchar(18) = '%' AS SELECT au_lname, au_fname, title, pub_name FROM authors a INNER JOIN titleauthor ta ON a.au_id = ta.au_id INNER JOIN titles t ON t.title_id = ta.title_id INNER JOIN publishers p ON t.pub_id = p.pub_id WHERE au_fname LIKE @firstname AND au_lname LIKE @lastname this example was taken from msdn like examples Marc Clifton wrote: That has nothing to do with VB. - Oh crap. I just defended VB!
  • GetChanges( ) - Not returning null

    help question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • 0 Votes
    4 Posts
    1 Views
    G
    I got this to work, it appears that Visual Studio did not generate the Update methods. After going into the design view of the dataset and right clicking on the Fill,GetData of the TableAdapter and selecting "Configure" then clicking NEXT all the way through re-generates everything. After doing this everything works perfect. Glenn
  • SQL Server 2008 Spatial Data

    database sql-server sysadmin beta-testing help
    3
    0 Votes
    3 Posts
    0 Views
    B
    Thats what I am doing but its freakin slow. After a lot of research I found an excelent blog describing an efficient way to do this: Nearest neighbors[^]
  • Select value of DropDawnList Inside GridView

    6
    0 Votes
    6 Posts
    0 Views
    M
    please see the following url http://tareemnet.com/drop.JPG User Name : adnet Pass : 123 When Editting, the user can change the value using the dropdownlist, and then updating with that new value selected. I'm beginner, please provide me a full code in c# for that issue.
  • Comparing rows to columns

    database
    2
    0 Votes
    2 Posts
    0 Views
    J
    What have you tried so far ? My advice is free, and you may get what you paid for.
  • How Entertaining! [modified]

    database help sysadmin algorithms beta-testing
    17
    0 Votes
    17 Posts
    0 Views
    T
    Glad I could help. If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles]  [My Website]
  • 0 Votes
    5 Posts
    0 Views
    C
    A suggestion would be SELECT BranchName, ContractNo, Email, StartDate, EndDate, CASE -- notice that the 101 is my favorite see BOL Convert for list of others WHEN CONVERT(VARCHAR, DATEADD(day, ContractReminder, GETDATE()), 101) > EndDate THEN 'Less than ' + CAST(ContractReminder as VARCHAR) + ' days left' WHEN CONVERT(VARCHAR, DATEADD(month, remindertype, GETDATE()), 101) > EndDate THEN 'Less than ' + remindertype + ' months left' END AS MyFlag INTO #RList WHERE CONVERT(VARCHAR, DATEADD(day, ContractReminder, GETDATE()), 101) > EndDate OR CONVERT(VARCHAR, DATEADD(month, remindertype, GETDATE()), 101) > EndDate
  • 0 Votes
    2 Posts
    0 Views
    S
    look at the patindex function. Marc Clifton wrote: That has nothing to do with VB. - Oh crap. I just defended VB!
  • problem with Query

    database help
    5
    0 Votes
    5 Posts
    0 Views
    S
    try select top 1 productid, u_price, qc_dt from (select productid, u_price, qc_dt from qc where productid = 1011 order by qc_dt desc) z Marc Clifton wrote: That has nothing to do with VB. - Oh crap. I just defended VB!
  • 0 Votes
    2 Posts
    0 Views
    B
    Strange: I tried your query with SQL Server 2000 and that did not produce an error message. By the way, Employees.FirstName is a nvarchar(10), hence the long search term is not very useful here anyway. What do you actually want to do? Do you want to get a list of employees whose FirstName contains either 'abc' or 'def'? That would be WHERE FirstName Like N'%abc%' OR FirstName Like N'%def%' and so on.
  • 0 Votes
    2 Posts
    0 Views
    S
    I found out how to find those bastards! SELECT * FROM sys.sysobjects Where NAME LIKE 'DF__Foo%' or SELECT * FROM sys.objects type_desc='DEFAULT_CONSTRAINT' But I also had a better work around: :-D 1. these nameless constraints being only on developers machines so far, I just dropped them manually 2. and give them a name in the create table with CREATE TABLE FOO ( column1 bit not null CONSTRAINT DF_Foo_column1 DEFAULT 0 .... ) A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
  • SQL Server Indexes [modified]

    database question sql-server sysadmin
    12
    0 Votes
    12 Posts
    0 Views
    P
    VARCHARs don't make good primary keys anyway. X|
  • Updating related 2 Tables

    database sql-server com help announcement
    2
    0 Votes
    2 Posts
    0 Views
    S
    Hi, the hint-text gives you the information why the update failed. SqlDataSource does not provide support for abbreviations. So you have to rewrite your query to UPDATE AdCampaign SET AdCampaign.DailyBudget = 12 FROM Account INNER JOIN AdCampaign ON Account.ID = AdCampaign.AccountID WHERE (Account.EmailAddress = @EmailAddress) This should work. Regards, Sebastian It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
  • SEARCH QUERY:)

    database help question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • 0 Votes
    2 Posts
    0 Views
    M
    For a cluster, you'll need at least 2 VM's. (preferably on two different boxes, putting them both on one box is nice for playing around, but it brings you nothing than more points of failure in a production environment). Next you will need to configure a shared disk, accessible by both machines. This is usually based on some hardware contraption, such as a NAS, or a firewire setup. You may also be able to SIMULATE this in VMWare ESXi, consult the product's documentation.
  • Update query in sql server 2005

    database sql-server sysadmin announcement
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • How I can pass session parameters to SqlDataSource

    sysadmin tutorial
    2
    0 Votes
    2 Posts
    0 Views
    M
    Add the risk of sounding repetitious and single-minded: And what is the error message? There are no psychics here.
  • Select error

    help database
    2
    0 Votes
    2 Posts
    0 Views
    M
    And what is the error message?
  • 0 Votes
    2 Posts
    0 Views
    J
    Not sure I've understood you properly, but your subquery doesn't look correct. So try something like this: SELECT dbo.ContactMaster.BmcCustKey ,Sum(CASE WHEN dbo.LocationAccessGrant.CanAccessLocation = 1 THEN 1 ELSE 0 END) accesscount FROM dbo.ContactMaster LEFT OUTER JOIN dbo.LocationAccessGrant ON dbo.ContactMaster.CompanyID = dbo.LocationAccessGrant.CompanyID AND dbo.ContactMaster.ContactIdentity = dbo.LocationAccessGrant.ContactIdentity GROUP BY dbo.ContactMaster.BmcCustKey ,dbo.LocationAccessGrant.CanAccessLocation ORDER BY dbo.ContactMaster.BmcCustKey It should take care of your null values "When did ignorance become a point of view" - Dilbert