sql

SQL Server Storage of Data: 4 gb Raw, how much in SQL Server?

I have a SQL Server 2005 database and I have 4 GB of text files that I need to import into it. The question is, if these 4 GB of text files are 1.2 GB when they are zipped, how big would the database be if they are imported? Does SQL Server shrink data by default, or how would I set this (think create a database as a detached item, to be...

Alternatives for java sql PreparedStatement IN clause issue?

I'm looking for the best workarounds for the PreparedStatement "IN clause" issue, which apparently is not supported for multiple values due to sql injection attack security issues: One ?, One value. Not a list of values. To illustrate: select my_column from my_table where search_column in (?) using ps.setString(1, "'A', 'B', 'C'");...

Do I need to set up Kerberos to use Replication in SQL Server 2005?

I want to setup replication on three SQL servers and one is not configured for Kerberos. (The SPNs are not setup yet) Do I need Kerberos and Pass-through delegation working to use replication in SQL Server 2005? ...

Partition a list of sets by shared elements

Here's the jist of the problem: Given a list of sets, such as: [ (1,2,3), (5,2,6), (7,8,9), (6,12,13), (21,8,34), (19,20) ] Return a list of groups of the sets, such that sets that have a shared element are in the same group. [ [ (1,2,3), (5,2,6), (6,12,13) ], [ (7,8,9), (21,8,34) ], [ (19,20) ] ] Note the stickeyness - the set (6,...

Sanitizing Database Return Data

I am wondering what everyone thinks the best method of handling results from your own database is. Other teams may be involved and there is always the chance the procedure/data could be altered and erroneous results would occur. My question is this. Is it better to let and exception occur, catch and log it or try to handle all contingenc...

Best LINQ Tutorial?

What is the best LINQ tutorial that you know of? I am starting to play with it, but I haven't found a really good source yet. Any ideas? ...

Can/how do you add a circle of references without breaking RI?

I'm primarily interested in pgsql for this, but I was wondering if there is a way in any RDBMS to do an insert operation, without disabling and re-enabling any FOREIGN KEY or NOT NULL constraints, on two tables that refer to each other. (You might think of this as a chicken that was somehow born from its own egg.) For a practical examp...

In a SELECT statement(MS SQL) how do you trim a string

For Example; SELECT TRIM(Names) FROM Customer ...

Why is LINQ to SQL converting my string parameter to a column name?

This Linq to SQL query ... Return (From t In Db.Concessions Where t.Country = "ga" Select t.ConcessionID, t.Title, t.Country) ... is generating this SQL: SELECT [t0].[ConcessionID], [t0].[Title], [t0].[Country] FROM [dbo].[Concessions] AS [t0] WHERE [t0].[Country] = ga ... when what I want is WHERE [t0].[Country] = 'ga' Any ...

How can I combine multiple rows into a comma-delimited list in SQL Server 2005?

Right now, I have a SQL Query like this one: SELECT X, Y FROM POINTS It returns results like so: X Y ---------- 12 3 15 2 18 12 20 29 I'd like to return results all in one row, like this (suitable for using in an HTML <AREA> tag): XYLIST ---------- 12,3,15,2,18,12,20,29 Is there a way to do this using just SQL? ...

Executing a stored procedure inside BEGIN/END TRANSACTION

If I create a Stored Procedure in SQL and call EXEC spStoredProcedure within the BEGIN/END TRANSACTION, does this other stored procedure also fall into the transaction? I didn't know if it worked like try/catches in C#... ...

Single-row subqueries in Oracle -- what is the join plan?

I've just discovered that Oracle lets you do the following: SELECT foo.a, (SELECT c FROM bar WHERE foo.a = bar.a) from foo As long as only one row in bar matches any row in foo. The explain plan I get from PL/SQL developer is this: SELECT STATEMENT, GOAL = ALL_ROWS TABLE ACCESS FULL BAR TAB...

Determine Time Zone Offset in T-SQL

My database application is going to be deployed at multiple sites in different time zones. I need a T-SQL function that will determine the UTC timestamp of midnight on January 1 of the current year for YTD calculations. All of the data is stored in UTC timestamps. For example, Chicago is UTC-6 with Daylight Savings Time (DST), the fun...

How do I create a decimal field in Access with Alter Table?

I want to programmatically create a new column in an Access table. I've tried many permutations of "ALTER TABLE MyTable Add MyField DECIMAL (9,4) NULL;" and gotten "Syntax Error in Field Definition". I can easily create a number field that goes to a Double type, but I want decimal. I would very strongly prefer to do this in a single ...

Encrypted data base query

I've just found out about stackoverflow.com and just checking if there are ideas for a constraint I'm having with some friends in a project. Although this is more a theoretical question to which I've been trying to find an answer for some time. I'm not much given into cryptography but if I'm not clear enough I'll try to edit/comment to ...

what does "select count(1) from table_name" on any database tables mean

When we execute select count(*) from table_name it returns the number of rows. What does count(1) do? What does 1 signifies over here? Is this same as count(*) as it gives the same result on execution? ...

best practices for catching exceptions from sql in c#

What are some good ways to catch business logic exceptions or return values from SQL in c#? For instance upon creating a new user, if the user already exists, the system, and the user must be notified. I have used the raise_error() method with a particular state int value, I have used stored procedure return int values, and I have also s...

ORA-01438: value larger than specified precision allows for this column

We get sometimes the following error from our partner's database: <i>ORA-01438: value larger than specified precision allows for this column</i> The full response looks like the following: <?xml version="1.0" encoding="windows-1251"?> <response> <status_code></status_code> <error_text>ORA-01438: value larger than specified precis...

Multiple languages in one database - SQL Server 2005

Hello, We have an application where people can type in multiple langugaes. Though we only have one database to store all the data. We have text columns as nvarchar ( assuming we only want text data to be in multiple languages and not all dates etc.) Do you think this is a feasbile solution and are there any other points to consider bes...

SQL - state machine - reporting on historical data based on changeset

I want to record user states and then be able to report historically based on the record of changes we've kept. I'm trying to do this in SQL (using PostgreSQL) and I have a proposed structure for recording user changes like the following. CREATE TABLE users ( userid SERIAL NOT NULL PRIMARY KEY, name VARCHAR(40), status CHAR NOT ...