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
  • MySQL Table Lock Question

    question mysql
    2
    0 Votes
    2 Posts
    0 Views
    J
    I don't know the answer either. (I would assume it waits) But check if you can use named locks[^] instead, then your application can name the lock and check if another instance have made a lock with the same name or not. But watch out, there are a lot of pitfalls. So read the manual properly. People say nothing is impossible, but I do nothing every day.
  • 0 Votes
    2 Posts
    0 Views
    A
    up
  • 0 Votes
    4 Posts
    1 Views
    J
    You could also try using the sys.dm_db_index_physical_stats[^] to look at the average fragmentation of your tables to identify any that have a higher level of fragmentation and then use REORGANIZE or REBUILD[^] to correct them. Jack of all trades ~ Master of none.
  • Combining Data From Temp Tables

    question tutorial database help
    11
    0 Votes
    11 Posts
    0 Views
    J
    You're welcome. People say nothing is impossible, but I do nothing every day.
  • Database backup size

    database question sql-server sysadmin tutorial
    2
    0 Votes
    2 Posts
    0 Views
    Richard DeemingR
    This StackOverflow answer[^] might help. You need a combination of sp_spaceused for the data[^] and some low-level access for the transaction log[^]. "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • Production Data Per User (Query Issue)

    database help tutorial
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • SMO Retrieve Table Record

    csharp database sql-server sysadmin tutorial
    7
    0 Votes
    7 Posts
    3 Views
    S
    Thanks all for your replies! I'm realized that it was not adequate question. I'm going to use one of these methods (just like in ADO.NET :)) Server.ConnectionContext.ExecuteReader Server.ConnectionContext.ExecuteWithResults Sorry for taking your time.
  • how can reporting in this Situation

    database help
    2
    0 Votes
    2 Posts
    0 Views
    S
    You need to use SQL PIVOT: MSDN: Using PIVOT and UNPIVOT[^] Try: SELECT 'TotalValue' AS Sum_Total_Values_By_City, [London], [Tehran], [Paris] FROM (SELECT City, Value FROM MyTable) AS SourceTable PIVOT ( SUM(Value) FOR City IN ([London], [Tehran], [Paris]) ) AS PivotTable Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Latest Article(s)]: How to extend a WPF Textbox to Custom Picker Server side Delimiters in ASP.NET
  • 0 Votes
    5 Posts
    0 Views
    M
    How about a temporary table: create table #t2 ( order_no varchar(255), order_line_no int, long_description varchar(8000), done bit ) Insert Into #t2 (order_no, order_line_no, long_description, done) Select order_no, order_line_no, long_description, 0 From #t1 Where line_type = 'p' Declare @i int Set @i = 1 While (Select count(*) From #t2 where Done = 0) > 1 Begin Update t2 Set t2.long\_description = t2.long\_description + ' ' + t1.long\_description From #t1 t1 inner join #t2 t2 On t1.order\_no = t2.order\_no And t1.order\_line\_no = t2.order\_line\_no + @i And t1.line\_type <> 'P' And t2.done = 0 Update t2 Set t2.done = 1 From #t1 t1 inner join #t2 t2 On t1.order\_no = t2.order\_no And t1.order\_line\_no = t2.order\_line\_no + @i And t1.line\_type = 'P' Set @i = @i + 1 End You could also use a cursor. Mike
  • Syntax error (Missing Operator) in Query expression ':0:1

    database help
    16
    0 Votes
    16 Posts
    2 Views
    L
    I was just guessing, based on the fact that there would generally be a comma separator in such expressions. However, from the further messages it seems that OP had not checked the documentation for proper format of the command.
  • 0 Votes
    6 Posts
    1 Views
    L
    Thanks for pointing out. I didn't know that unlike Oracle, DDL statements are transactional in SQL Server.
  • Customize color coding in SQL editor window

    database help tutorial
    5
    0 Votes
    5 Posts
    1 Views
    L
    Thanks God you didn't expect anyone here to remote connect to your computer and change the colors for you.
  • sql server

    sharepoint database sql-server sysadmin tutorial
    9
    0 Votes
    9 Posts
    0 Views
    L
    Exactly, just like the question and your answer.
  • Do I need a pivot Query?

    database question
    4
    0 Votes
    4 Posts
    0 Views
    J
    It looks more like unpivot to me. People say nothing is impossible, but I do nothing every day.
  • sql server 2008

    database sql-server sysadmin
    6
    0 Votes
    6 Posts
    0 Views
    P
    Kapilkp wrote: a column of unicode data Then put it in an NVARCHAR field. N for Unicode.
  • Change the language for Sql Server 2008

    database sql-server sysadmin help question
    3
    0 Votes
    3 Posts
    0 Views
    M
    Change your field type from VARCHAR to NVARCHAR. NVARCHAR is the unicode definition and will accept double byte characters. Never underestimate the power of human stupidity RAH
  • Totals of each transaction type

    question help tutorial
    5
    0 Votes
    5 Posts
    0 Views
    R
    Thanks PIEBALDconsult The problem was amongst other things the dates !! This works now: SELECT user_id, SUM(CASE WHEN (stkhstm.transaction_type = 'RECP' AND stkhstm.movement_date >= {ts '2012-01-01 00:00:00'} AND stkhstm.movement_date < {ts '2013-01-01 00:00:00'}) then 1 else 0 end) , SUM(CASE WHEN (stkhstm.transaction_type = 'SRET' AND stkhstm.movement_date >= {ts '2012-01-01 00:00:00'} AND stkhstm.movement_date < {ts '2013-01-01 00:00:00'}) then 1 else 0 end) FROM vektron.scheme.stkhstm stkhstm GROUP BY user_id 'BETWEEN' would be a bit more elegant I guess :)
  • Building dictionary translation

    database business xml help tutorial
    7
    0 Votes
    7 Posts
    1 Views
    L
    Y@ssco wrote: But from where i can get the dictionary itself? http://www.freedict.org/nl/[^], or search for the Ergane-database. IIRC, it's a (free) MS-Access database which uses the Esperanto-language as intermediate to go from one language to another. Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]
  • query..

    database
    4
    0 Votes
    4 Posts
    1 Views
    B
    select * from vendor where id in (select top 2 id from vendor order by id desc) union all select * from labour where id in (select top 2 id from labour order by id desc) I Love T-SQL "VB.NET is developed with C#.NET" If my post helps you kindly save my time by voting my post.
  • embedding sql server express in application

    c++ database mysql sql-server sqlite
    3
    0 Votes
    3 Posts
    0 Views
    L
    Danzy83 wrote: SQLite3 makes that provision but does not encrypt the data. It does[^]; Encryption Support The entire database file can be encrypted. Binary and cleartext passwords are supported. Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]