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
  • SQL Copy Table in C#

    database csharp help question
    4
    0 Votes
    4 Posts
    0 Views
    P
    Try using SqlBulkCopy - google for that and check out the example here http://www.sqlteam.com/article/use-sqlbulkcopy-to-quickly-load-data-from-your-client-to-sql-server[^]
  • database

    database sql-server sysadmin question
    3
    0 Votes
    3 Posts
    0 Views
    N
    First of all this is a wrong forum to ask. Second is that , you did not specify the front end tool ythat u are using. However, if it is dotnet application, this link will help you Creating a .NET Windows Installer [^] If java, this may help MAKE AN INSTALLER FOR YOUR JAVA APPLICATIONS[^] Niladri Biswas
  • SQL query optimization

    database performance help sharepoint algorithms
    6
    0 Votes
    6 Posts
    3 Views
    W
    Could you look at the differences between the execution plans of the query and the SP? Wout Louwers
  • Table result to Xml

    data-structures xml tutorial question
    2
    0 Votes
    2 Posts
    0 Views
    R
    Hi Fayu, Have a look at trying for xml explicit, try this article for some help http://www.eggheadcafe.com/articles/20030804.asp[^] Hope you get it working
  • 0 Votes
    4 Posts
    0 Views
    M
    Good idea, but unfortunatelly doesn't work. It seems like the name of the table (select) never comes from Stored Procedure to the DataSet.Table. This is very sad, because any time the stored procedure is changed, the code has to be recompiled. So what I did, is an additional SELECT with the names of the tables in the order it goes in the SP. This way I know how many tables I get and the names and the order :-)
  • system error code 126

    help question database oracle com
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • "Syscomments" system table corrupted

    database c++ help sharepoint sysadmin
    2
    0 Votes
    2 Posts
    0 Views
    A
    If you can see it in object explorer try right click and that will give you an option to script it. Other than that, you may be able to pull the info out of syscomments by direct sql (id joins to id from sysobjects) If this fails, then you have learnt the lesson - always save your sql to a flat file and put in in a vserion control system. Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP
  • INSTEAD OF trigger

    database tutorial question announcement
    3
    0 Votes
    3 Posts
    0 Views
    U
    yep, But the answer I got yesterday is still dubious. I am still having no ideas about how to check time & check by which syntax. The question today is one in my effort to find out solution for the question of yesterday, but in a different form :D I think INSTEAD OF trigger can help me to sovle prolem. That is the reason for the question today ^^ However, if you think just a standard trigger is quite enough to solve my problem, could you give me a more specific example? Thanks for your help! modified on Wednesday, December 9, 2009 8:36 AM
  • sqlserver apostrophe problem.

    database help sharepoint
    8
    0 Votes
    8 Posts
    0 Views
    B
    Good,but when you have complex query and in which you use multiple times single apostrophe then you can become confused by writing much '''' in query. Regards. 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
  • e-blood bank

    csharp asp-net database mysql help
    7
    0 Votes
    7 Posts
    0 Views
    S
    please any one have any idea for this send to me here or in my email to comunicat with him/here
  • Trigger in a certain period of time of day

    database tutorial question
    3
    0 Votes
    3 Posts
    0 Views
    U
    Could you give me an example because I do not know how to assign value for t1 & t2? Thank kiu!
  • How to remove the duplicate records with the old timestamp.

    database tutorial
    8
    0 Votes
    8 Posts
    1 Views
    C
    Got the solution.. below query will be workout             DELETE T1      FROM BugsDB_DefectVolume T1, BugsDB_DefectVolume T2      WHERE T1.[Product ID] = T2.[Product ID]      and T1.BugDate = T2.BugDate and T1.Timestamps < T2.Timestamps
  • Cursor issue

    help question sales
    8
    0 Votes
    8 Posts
    0 Views
    N
    Hi, Try to understand the output of NewId() If I issue select NewId() the output will be something like 3B311450-65BB-4AF8-898B-0CD02C5086E2 . It is a pure hyphenized alphanumeric charecter. If your destination table has the Id column as integer type, then you need to either change the column type from Integer to Varchar or you need to extract only the numeric values from NewId() for your future use. I have created a sample for you. Look into that(id datatype is varchar) . I hope you will get some insight. declare @tblSource table(id int identity, FirstName varchar(50),LastName varchar(50)) declare @tblDest table(id varchar(max) , FirstName varchar(50),LastName varchar(50)) insert into @tblSource select 'firstname1', 'lastname1' union all select 'firstname2', 'lastname2' union all select 'firstname3', 'lastname3' union all select 'firstname4', 'lastname4' union all select 'firstname5', 'lastname5' Query: insert into @tblDest (id,FirstName,LastName) select NEWID(),FirstName,LastName from @tblSource select * from @tblDest Output: id FirstName LastName D2A3D81C-F76E-44A4-9D47-83FBE4DDB76B firstname1 lastname1 0B827C0E-EB68-43EA-A423-B10575EAF572 firstname2 lastname2 EB4DB402-3D8F-4C09-9E37-004CE37DE1FD firstname3 lastname3 E6CE9239-1E95-4660-B5AC-00DBFEE28474 firstname4 lastname4 345F70CC-B957-41CC-977C-9FBA7A81E912 firstname5 lastname5 In case you need to strip out only the numbers, here is an example declare @str varchar(max) set @str = 'D2A3D81C-F76E-44A4-9D47-83FBE4DDB76B' ;with cte as( select 1 as rn union all select rn+1 from cte where rn<LEN(@str)), cte2 as( select rn,chars from cte cross apply(select SUBSTRING(@str,rn,1) chars)X where chars like '%[0-9]%' ) select numericData from ( select cast(chars as varchar(max))from cte2 for xml path(''))X(numericData) Output: numericData 23817644494783476 :) Niladri Biswas modified on Tuesday, December 8, 2009 4:12 AM
  • Custom sort in SQL Server

    database sql-server sysadmin architecture question
    8
    0 Votes
    8 Posts
    2 Views
    N
    Hi, Mycroft's solution is elegant and I like the way he presents the solution. However, there are a few more ways which will accomplish the task, though again I like Mycroft's solution declare @t table(docvalue varchar(50),priority int) insert into @t select 'aaa',0 union all select 'xxx', 1 union all select 'bbb', 3 union all select 'ccc',0 union all select 'aaa',2 Query1: select docvalue,priority from @t where priority <> 0 group by priority,docvalue union all select * from @t where priority = 0 Query 2: select distinct * from @t where priority <> 0 group by priority,docvalue union select * from @t where priority = 0 Output: docvalue priority xxx 1 aaa 2 bbb 3 aaa 0 ccc 0 Niladri Biswas
  • Validation Rule In SQL Server 2005

    database sql-server design sysadmin tutorial
    8
    0 Votes
    8 Posts
    0 Views
    N
    Check Constaint [^] to help. Also you can use Rules that enforce data integrity. Check this out Creating Rules and Defaults[^] Just scroll down a bit in the page to get a cleaner picture about the Rules :) Niladri Biswas
  • 0 Votes
    15 Posts
    0 Views
    N
    Try this Will work for Sql Server(Any version), MySql,Oracle, MSAccess select * from myTable where customername in ( select customername from myTable group by customername,phonenum,city,street having(count(customername)>1 and count(phonenum)>1 and count(city)>1 and count(street)>1)) Output: id customername phonenum city street 19 jon 555 NK st.5 37 jon 555 NK st.5 Hope this helps :) Niladri Biswas
  • Import data from Xml to Sql in vs2003

    database csharp xml tutorial question
    6
    0 Votes
    6 Posts
    0 Views
    M
    <> wrote: I neva asked u 2 work or complete the task for me You are right so take the ideas I gave you one line at a time and feed them into Google, look at the results and you will find lots of articles and tutorial on each of the subjects. Then put them together in a solution. As for your keyboard use, are you serious, there are 101 keys on most keyboards and you want to use your like a bloody phone. Wake up to yourself and communicate like a professional or at least competent person. Never underestimate the power of human stupidity RAH
  • SQLServer Default Database Changed

    sysadmin database help question
    4
    0 Votes
    4 Posts
    0 Views
    T
    David Mujica wrote: Use this statement to verify what you think happened ... Users could access the system last Thursday; on Friday, they couldn't. The default database was changed to a database that is used for sending e-mail messages, so, they neither need nor have access to it. The accounts (there are only a handful) have been manually updated. David Mujica wrote: select name,default_database_name,modify_date from sys.sql_logins Since this is a SQLServer 2000 node, the listed table didn't work, but it gave me enough information to move forward. I used the following: select l.name, xdate1 as creation_Date, xdate2 as modify_date, l.dbid, d.name as defaultdb from sysxlogins l inner join sysdatabases d on l.dbid = d.dbid And that just opened up more questions... One of the accounts was created in 2007, updated a minute later and not touched after that, but, they have a default database set to a database that didn't exist at the time. As far as access rights, when someone leaves the company, their password is changed and remote access removed. Tim
  • SQLite3 program getting name of table

    database sqlite csharp html debugging
    3
    0 Votes
    3 Posts
    0 Views
    B
    Thanks for the modified code! Can't make a list like that for some reason. Maybe I'm missing an import; I kept the casting. Because of this: OdbcCommand DbCommand = DbConnection.CreateCommand(); //SQL query to return all table names //http://www.sqlite.org/faq.html#q7 DbCommand.CommandText = ("SELECT name FROM sqlite\_master WHERE type='table' ORDER BY name"); DbReader = DbCommand.ExecuteReader(); List<string> TableNames = new List<string>(); while (DbReader.Read()) { TableNames.Add(DbReader\["name"\].ToString()); Trace.WriteLine(DbReader\["name"\]); } DbReader.Close(); if (TableNames.Contains("bandwidth\_records")) { //check to make sure column names are present DbConnection.Close(); } else { //create table & columns ) Thanks!
  • Export records to excel from sql

    tools database com testing help
    4
    0 Votes
    4 Posts
    0 Views
    G
    Hi, if you are also interested in commercial solutions, check out GemBox.Spreadsheet .NET Excel component. With it you can easily do chunked exports to Excel, or export DataTable to Excel.