sql-server-2005

Can I select 0 columns in SQL Server?

I am hoping this question fares a little better than the similar Create a table without columns. Yes, I am asking about something that will strike most as pointlessly academic. It is easy to produce a SELECT result with 0 rows (but with columns), e.g. SELECT a = 1 WHERE 1 = 0. Is it possible to produce a SELECT result with 0 columns (...

Entity Framework How to specify paramter type in generated SQL (SQLServer 2005) Nvarchar vs Varchar

In entity framework I have an Entity 'Client' that was generated from a database. There is a property called 'Account' it is defined in the storage model as: <Property Name="Account" Type="char" Nullable="false" MaxLength="6" /> And in the Conceptual Model as: <Property Name="Account" Type="String" Nullable="false" /> When sel...

vb6 ADODB TSQL procedure call quit working after database migration

This code was once working on sql server 2005. Now isolated in a visual basic 6 sub routine using ADODB to connect to a sql server 2008 database it throws an error saying: "Login failed for user 'admin' " I have since verified the connection string does work if i replace the body of this sub with the alternative code below this sub. ...

Connecting to SQL Server 2005 on another domain through VPN connection

Hello, I have SQL Server 2005 dev installed on my machine. Using SQL Server Management Studio: how can I connect to a SQL Server on another domain? Please note that the computer has to be VPN'ed into the domain I am connecting to. Thanks, Voodoo ...

Omnis 7 and SQLServer connection issue

This is probably a long shot, but I thought I would ask anyway.. I have an application I wrote back in the 90's in Omnis 7.3.5 that is still running (kind of like the Energizer Bunny..just keeps on going!) Its had no maintenance for years... The application accesses a Sybase database which is hosted on an elderly Unix box that needs to...

What is wrong with this sql where-clause?

I am selecting records based on two dates in a same column but my where condition fails to select records on the StartDate and EndDate... where CreatedDate between @StartDate and @EndDate I get only the records inbetween the dates and not the records on the StartDate and EndDate... Consider if I pass the same date as StartDate and EndD...

SQL Server 2005 Create Table with Column Default value range

Trying to finish up some homework and ran into a issue for creating tables. How do you declare a column default for a range of numbers. Its reads: "Column Building (default to 1 but can be 1-10)" I can't seem to find ...or know where to look for this information. CREATE TABLE tblDepartment ( Department_ID int NOT NULL IDENTITY, Departm...

Sql Server 2005 multiple insert with c#

Hello. I have a class named Entry declared like this: class Entry{ string Id {get;set;} string Name {get;set;} } and then a method that will accept multiple such Entry objects for insertion into the database using ADO.NET: static void InsertEntries(IEnumerable<Entry> entries){ //build a SqlCommand object using(S...

Obtain Update Table Lock at start of Stored Procedure in SQL Server

I'm writing a SQL Server stored procedure in which I want to lock a table for update before executing the body of the stored procedure. I don't want to prevent other processes from reading the table, but I do want to prevent other processes updating the table. Here is my first attempt: CREATE PROCEDURE someProcedure BEGIN SET TRANS...

How to set index on the column which have datatype varchar(4096) in SQL Server 2005?

This is the query for creating index create index idx_ncl_2 on BFPRODATTRASSOCIATION (value,attributeid) include (productid) Table structure of BFPRODATTRASSOCIATION ProdAttrAssociationId bigint no 8 ProductId bigint no 8 AttributeId bigint no 8 Value varchar no 4096 I am getting this error: T...

Why is my SQL 'NOT IN' clause producing different results from 'NOT EXISTS'

I have two SQL queries producing different results when I would expect them to produce the same result. I am trying to find the number of events that do not have a corresponding location. All locations have an event but events can also link to non-location records. The following query produces a count of 16244, the correct value. SELEC...

Different results on the basis of different foreign key value using a falg in where clause

Please see attached image. Can you please tell me what query will work. Please ignore isdefinite and productpriceid columns. Thanks ...

I want to do some experiment on SQL Server cluster to gain some experience on it, where should I start?

Hi guys, I want to do some experiment on SQL Server cluster to gain some experience on it, where should I start? I just have some basic concept of cluster and don't have any experience. Anyone can tell me some material that I can reference to? Great thanks. ...

SQL Server 2005 - Using Null in a comparison

This is more of a question to satisfy my own curiosity. Given the following statement: DECLARE @result BIT SET @result = CASE WHEN NULL <> 4 THEN 0 ELSE 1 END PRINT @result Why do i get back "1" instead of "0" Changing it to: DECLARE @result BIT SET @result = CASE WHEN NULL IS NULL ...

how to concatenate varying stored procedure parameters

please help me with writing this search sql stored procedure procedure may have different number of parameters at different time so could any body help me with writing this query. I don't know how to concatenate parameters. i am new to stored procedure CREATE PROCEDURE searchStudent -- Add the parameters for the stored procedure here ...

Connecting to MS SQL Server 2005 via Hibernate

I have JRE 1.6 and am using the following hibernate.cfg.xml file. I am always getting "Cannot open connection" and "The port number 1433/DB is not valid." <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property> <property name="hibern...

SQL Server 2005 + Enforce Foreign Key Constraint + Cacade Delete

I am using SQL Server 2005 and I have to relationships going into one table. I had to turn off " Enforce Foreign Key Constraints" because I have 2 relationships going into the same table. However I want to put cascade delete on. I thought if I have cascade delete on both of these relationships and if I say deleted something from on of...

Use MTS (Microsoft Transaction Server) for object pooling

What Is Microsoft Transaction Server (MTS) ? How using this improve the performance of the application ? How to use and configure Microsoft Transaction Server (MTS) with SLQ Server 2005? ...

deleting and reusing a temp table in a stored precedure

Hi I need to SELECT INTO a temp table multiple times with a loop but I just can't do it, because after the table created by SELECT INTO you can't simply drop the table at the end of the loop, because you can't delete a table and create it again in the same batch. so how can I delete a table in a stored procedure and create it again? i...

Why are there connections open to my databases?

I have a program that stores user projects as databases. Naturally, the program should allow the user to create and delete the databases as they need to. When the program boots up, it looks for all the databases in a specific SQLServer instance that have the structure the program is expecting. These database are then loaded into a lis...