sql-server

How to limit an SQL query to return at most one of something?

I have a table in my database representing releases of software; the relevant columns of the schema being as follows: ProductID int PlatformID tinyint Date datetime All are not null, and there is also a unique key assigned to the first two columns. I would like to build a query (using LINQ) which returns the latest release ...

How can I give condition on the column names in SQL Server 2008

I have my database with the columns as follows: keyword, part1_d1, part1_d2 ........ part1_d25, part2_d26, ......part2_d34 FYI: d1 through d34 are documents.. How can I give a query to obtain columns with column_name like '%part1%'; as below keyword, part1_d1, part1_d2, ........ part1_d25 I tried the query: select (Select COLUMN...

SQL Server interview questions.

So I have an interview next week for a shop that makes heavy use of SQL Server 2008. I also use it on a daily basis and feel quite comfortable with it however there is always the nagging question: What don't I know? So I humbly ask, what can a C# developer expect an interviewer to ask with regards to an SQL Server 2008 for a mid-level d...

The best database for a C++ and java applications

Hi I am making an ATM console application in C++. I am planning to use a database, my friend suggested to use files. However, I want to use a database like mySql, Oracle or sqlServer express. Q: Which one of the databases would be more applicable for a C++ application ? I am also making a second application in java. This is a large li...

[SQL Server] There is already an object named '##Temp' in the database.

I have a stored procedure on SQL Server 2000. It contains: select ... into ##Temp ... ... drop table ##Temp When I run the stored procedure with ADO a second time, it prompts: There is already an object named '##Temp' in the database. Could anyone kindly tell me what's wrong? ...

Unique constraint on multiple columns

Hello, I have a table CREATE TABLE [dbo].[user]( [userID] [int] IDENTITY(1,1) NOT NULL, [fcode] [int] NULL, [scode] [int] NULL, [dcode] [int] NULL, [name] [nvarchar](50) NULL, [address] [nvarchar](50) NULL, CONSTRAINT [PK_user_1] PRIMARY KEY CLUSTERED ( [userID] ASC ) ) ON [PRIMARY] GO how can add uni...

can anyone check this and clear my error

Dim conn, spinsert Set conn = Server.CreateObject("ADODB.Connection") conn.Open " Provider=sqloledb;Data Source=eightprinter;Initial Catalog=Movetest;User Id=moving;Password=moving123" If conn.errors.count = 0 Then Response.Write "Connected <br>" spinsert = "dbo.Sp_Companydetails_Insert "&errCompname&" , "&errUser&" ,"&errPwd&"...

How to read image field from MSSQL with PHP

Hi Everyone, I am creating a web site that needs to synchronise an online MySQL database reading from the offline MSSQL server. All communication and reading all fields from MSSQL is working OK except that image field. I have been working with PHP and Mysql for some time and know how to insert/retrieve images to/from a MySQL database(us...

Error converting data type varchar to int error? can anyone tel me the reason for this error

during inserting values from ASP page to SQL 2000 ...

Extract 2% data of SQL Server database

Our production database size is 25Gb (approx) and having 700 tables, I just want to import about 2% of the data for every table in my local database for development/testing purposes... (data should be imported in a way that foreign key constraint should be preserved) ??? Your comments/suggestions will be warmly welcomed !!! ...

SQL Server: How to open .PRC files?

I have old .prc files (SQL Server Stored Procedures) which have exported from SQL Server 2000. Now when I try to open a .prc file using SSMS 2008, I get a bunch of chinese characters and other odd characters. I tried a solution found here, but it did not help. ...

How Can I Sort A 'Version Number' Column Generically Using a SQL Server Query

I wonder if the SQL geniuses amongst us could lend me a helping hand. I have a column VersionNo in a table Versions that contains 'version number' values like VersionNo --------- 1.2.3.1 1.10.3.1 1.4.7.2 etc. I am looking to sort this, but unfortunately, when I do a standard order by, it is treated as a string, so the order comes ou...

Sharepoint Infopath plus one extra database

I have the following setup: Sharepoint 2010 with SQL Server and Office 2010. This is the situation I have. Non programmers are supposed to create simple infopath forms. Admins then upload those to sharepoint, which will get served to users as simple webpages. When a user submits the form it's fields are supposed to be stored in a sepa...

Updating one column with other's value in same table

Please consider this sql statements Create table abc (A int, B int ) insert into abc values (1,2) Both of the below statements do the same thing. Why? update abc set A = B, B =0 where A=1 and update abc set B =0, A = B where A=1 I was thinking that in the later statement B columns value is set first and then A columns' value...

Generated DBML code incorrectly marks returned columns as NOT NULL for stored procedures

I have a stored procedure in SQL Server that returns some data via a select: CREATE PROCEDURE spDDIs_Get(@ID INT) AS IF NOT EXISTS (SELECT ID FROM tDDIs WHERE ID = @ID) RAISERROR('ICT0005:DDI does not exist', 18, 1) ELSE SELECT D.ID, D.SchemeID, C.ID ConfigurationID, C.Description Configuration, D.RecordCall, D.DDIN...

SQL Server: help with a simple stored procedure?

I'm trying to create a simple stored procedure which I can use to write data to a log table. I'm a noob in stored procedures, so what I'm missing here? I get an error saying: Msg 201, Level 16, State 4, Procedure toLog, Line 0 Procedure or function 'toLog' expects parameter '@messageTime', which was not supplied. How to modify this co...

What's the point of writing a dynamic query in a stored procedure.

If we need some information that can be achieved only through dynamic query then should not it be written in the application code directly (in DAL) rather than in the stored procedure? Because the benefit we achieve from SP is already lost if we use dynamic query in it which is the already saved execution execution plan along with it. ...

String concat on MS SQL for a group of rows

Lets say I have 2 tables: 1 with users and another one which keeps record of which users used what codes. Users ----- Id, Name 1, 'John' 2, 'Doe' Codes ------ Id, UserId, code 1, 1, 145 2, 1, 187 3, 2, 251 Now I want to pull a query that results he following Name, UsedCodes 'John', '145,187' 'Doe', '251' How can this be done wi...

Error in Union trying to sort null at end in sql server

Hi, I am trying to sort my database in some particular order, but I want all null's at the end, so I am selecting all values with not null, and then selecting all values WITH null, and trying to join them with Union.. like: SELECT * FROM preferences WHERE preferenceOrder IS NOT NULL ORDER BY preferenceOr...

How do I fix a "Performance counter registry hive consistency" when installing SQL Server R2 Express?

I'm trying to install SQL Server 2008 R2 Express from this site: http://www.microsoft.com/express/database/ I have a 64-bit, Windows 7 machine. I have tried both the 32-bit and 64-bit versions but each fail on "Performance counter registry hive consistency". How can I fix this so that I can install SQL Server 2008 R2 Express? ...