sql-server

is SSIS insert bulk the same as a BULK Insert

I'm doing a bulk insert of a CSV file into SQL Server 2005, using an SSIS package (not built by me) I'm running SQL Profiler and see the insert statement as: insert bulk [dbo].[stage_dht]( ..... ) but there's no FROM clause in that statement, so I'm curious how is it getting it's data, and is this so-called fast load the best way to ...

overhead of varchar(max) columns with small data

As part of a bulk load of data from an external source the stageing table is defined with varchar(max) columns. The idea being that each column will be able to hold whatever it finds in the source CSV file, and that we'll validate the data (for type, size, percision etc) later. But I'm concerned that the varchar(max) column has a lot o...

What is the best way to define a column in SQL server that may contain either an integer or a string?

I have a situation where two objects of the same type have parents of different types. The following pseudo code explains the situation the best: TypeA a1, a2; TypeB b; TypeC c; a1.Parent = b; a2.Parent = c; To complicate things even further TypeB and TypeC may have primary keys of different types, for instance, the following assertio...

"<>" vs "NOT IN"

I was debugging a stored procedure the other day and found some logic something like this: SELECT something FROM someTable WHERE idcode <> (SELECT ids FROM tmpIdTable) This returned nothing. I thought it looked a little odd with the "<>" so I changed it to "NOT IN" and then everything worked fine. I was wondering why this is? This is ...

Changing SQL Provider from SQLOLEDB.1 to SQLNCLI.1 causes app to fail when accessing data via stored procedure

I'm supporting a legacy app written in MFC/C++. The database for the app is in SQL Server 2000. We bolted on some new functionality recently and found that when we change the SQL Provider from SQLOLEDB.1 to SQLNCLI.1 some code that is trying to retrieve data from a table via a stored procedure fails. The table in question is pretty st...

What can cause the SQL Server JDBC error 'The value is not set for the parameter number 0' for an output parameter access?

I have some Java code that accesses SQL Server 2005 which looks something like this: CallableStatement cstmt = ...; ... // Set input parameters cstmt.registerOutParameter(11, Types.INTEGER); cstmt.execute(); int out = cstmt.getInt(11); And the following exception is thrown from the last line: com.microsoft.sqlserver.jdbc.SQLServerExc...

Disappearing Stored Procedure

So, not sure what is happening. But I have stored procedure and it keeps disappearing out of my DB in SQL 2k. I can add it again and then try to execute it from my web app and i get an exception saying the stored procedure cant be found. So then ill go back to management and refresh and its gone again !?! here is the config for the sto...

SQL Server 2008 - Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.

I've just installed SQL Server 2008 Developer edition and I'm trying to connect using SQLCMD.exe, but I get the following error: H:\>sqlcmd.exe -S ".\SQL2008" Msg 18452, Level 14, State 1, Server DEVBOX\SQL2008, Line 1 Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. Has anyone seen...

Setting value of paramter containing " ' " (apostrophe) used in LIKE query

I have the following query in ASP.NET/C# code which is failing to return any values using a parameter... select * from MyTable where MyTable.name LIKE @search I have tried the following query alternatives to set this parameter in SQL commands... select * from MyTable where MyTable.name LIKE %@search% select * from MyTable where MyTa...

Advanced SQL GROUP BY query

I have two columns in my Items table 'Category', 'Category2', the two columns contain, essentially the same information. If I had designed the database I would have created a separate table for categories and added items to categories based based off of that table, unfortunately I didn't create the database and I can't change it now but...

How to import a file when SSIS is on another server

I want users to upload a file via our website (ASP.NET), which then gets imported into SQL Server 2005 using SSIS. Our web app is separated into a web server (IIS) and a database server (SQL Server). The problem is that after the file has uploaded to the web server, you cannot directly call the SSIS package from the ASP.NET code, becaus...

SQL Server What size is VLDB

Is it 1TB minimum or is it 2? My current client has sub 1 TB and I wanted to know if I write that they are on the verge of a re-classification due to their size they should consider these BOATLOAD of issues. :) TIA ...

What is the difference between Wide and Nonwide tables in SQL 2008?

I was looking at this page on MSDN: Maximum Capacity Specifications for SQL Server 2008 And it says the following: Max Columns per 'nonwide' table: 1,024 Max Columns per 'wide' table: 30,000 However I cannot find any information on the difference between 'wide' and 'nonwide' tables in SQL 2008. If I wanted to define a 'wide' table,...

alternate to indexed views

Whats the alternate approach to indexed views in sql server? Thanks, Salman Shehbaz. ...

SQL Server equivalent of MySQL's USING

In MySQL, you can use the keyword USING in a join when you join on columns from different tables with the same name. For example, these queries yield the same result: SELECT * FROM user INNER JOIN perm USING (uid) SELECT * FROM user INNER JOIN perm ON user.uid = perm.uid Is there an equivalent shortcut in SQL Server? ...

How to make a T-SQL Cursor faster?

Hey, I Have a cursor in stored procedure under SQL Server 2000 (not possible to update right now) that updates all of table but it usually takes few minutes to complete. I need to make it faster. Here's example table filtered by an arbitrary product id; Whereas GDEPO:Entry depot, CDEPO:Exit depot,Adet: quantity,E_CIKAN quantity that's u...

copying oracle to sqlserver 2005 jdbc

Is there any way of copying a database from oracle to sqlserver 2005? Thanks ...

java servlets : duplicate key row in object with unique index 'XAK1timItem'

I've written this java servlet which inserts items into a table however it fails. I think it might be due to my insertion and deleting which got me in trouble some how. The java servlet runs an insert statement into sql server. In my error log, it says: com.microsoft.sqlserver.jdbc.sqlserverexception: cannot insert duplicate key row ...

Best processor for SQL Server?

Our web app's db server (running SQL Server 2008) is starting to get pounded and so I would like to upgrade it to a better box. We will still probably be going with a hosted solution. I know that the more RAM the better, but what about the processor? Is it better to have a multicore processor or one that's a little more server-oriented,...

SQL subqueries question

I want to Select tblProperty.ID only when this query returns greater than 0 SELECT COUNT(tblProperty.ID) AS count FROM tblTenant AS tblTenant INNER JOIN tblRentalUnit ON tblTenant.UnitID = tblRentalUnit.ID INNER JOIN tblProperty ON tblTenant.PropertyID = tblProperty.ID AND tblRent...