sql-server

Check if SQL server (any version) is installed?

Hi to all, I need to find if SQL server is installed on a machine. It could be any version of SQL server (7, 2005,8, sql express etc). We need to know this information as we are writing an installer and need to show to the user that if SQL server has not been found, the installation cannot proceed. I have seen versions that use the reg...

SQL Server table design - don't want two records the same

One of the tables in my database has three columns. They are dt_id (PK), dt_name (varchar) and u_id (FK). dt_id is a identity column. But I want to have so that dt_name can only be once per user. So you can only put in " dt_name='CC', u_id=1 " once. How can I set the dt_name column so ? ----Edit:---- Sorry, i will explain better.....

SQL Server SPID

Fellow devs, From SQL Server Management Studio, I can see that a lot of SPIDs are still present eventhough the application which has triggered them has already used and closed the query. What could be causing this? Any avenues for me to look at concerning this? Thanks. ...

i want to export table from SQL Server to mysql

Hi i want to migrate the tables from SQL Server to mysql, Can please refer some good tools or give some suggestion , how to start the migration , Also please tell me how to export the table in SQL Server. Thanks ...

How to BULK INSERT a file into a *temporary* table where the filename is a variable?

I have some code like this that I use to do a BULK INSERT of a data file into a table, where the data file and table name are variables: DECLARE @sql AS NVARCHAR(1000) SET @sql = 'BULK INSERT ' + @tableName + ' FROM ''' + @filename + ''' WITH (CODEPAGE=''ACP'', FIELDTERMINATOR=''|'')' EXEC (@sql) The works fine for standard tables, b...

Sql by hour starting at noon

I'm currently using a select statement with one column as DATEPART(hh, CallTime) AS Hour and then doing: GROUP BY DATEPART(hh, CallTime) ORDER BY Hour This displays the hours starting at midnight and going through midnight - how would I go about having this go from noon to noon? Thanks! ...

.NET Object persistence options

I have a question that I just don't feel like I've found a satisfactory answer for, either that or I've not been looking in the right place. Our system was originally built using .NET 1.1 (however the projects all now support 3.5) and all entities are persisted to the database using stored procedures and a "SQLHelper" that has the stan...

Best practice for Uploading Excel data in SQL Server using ASP.NET

Hi All, I am looking for best practice for uploading excel data in Sql server 2000 database through asp.net web application. Excel data will be predefined Format with almost 42 columns and out of 42 10 fields are mandatory and rest are conditional mandatory. i.e. if data exists it should be in defined format. I also need to validate for...

converting ID to column name and also replacing NULL with last known value.

TABLE_A Rev ChangedBy ----------------------------- 1 A 2 B 3 C TABLE_B Rev Words ID ---------------------------- 1 description_1 52 1 history_1 54 2 description_2 52 3 history_2 54 Words column datatype is ntext. TABLE_C ID Name ----------------------------- 52 Description 54 Hi...

Winforms: How to upload a picture into SQL Server database using C#

I want to upload images to my SQL Server database. I have two buttons , One picture box. With the browse button, I am able to select the file from disk, and it is displayed into the picturebox. The problem is that I am not able to save the picture from picturebox into the database. Please help me out with the code. Appreciate it. ...

SQL Server Deadlock Fix: Force join order, or automatically retry?

i have a stored procedure that performs a join of TableB to TableA: SELECT <--- Nested <--- TableA Loop <-- | ---TableB At the same time, in a transaction, rows are inserted into TableA, and then into TableB. This situation is occasionally causing deadlocks, as the stored pr...

Backup remote SQL Server 2005

How do I backup data from a remote MS-SQL Server DB to my local computer? I'm having access to Management Studio 2008. ...

SQL Server 2008: SQLXML Query function .query('//mypath/text()') doesn't XML decode

In Microsoft SQL Server 2008, when executing .query('{xpath}/text()') on an XML stream column value, if the value of the XPath selected node contains "&amp;", the return value is "&amp" instead of "&". Is this a bug, or am I doing something wrong? Or rather, how do I get the unencoded text, i.e. equivalent of .innerText (per W3C XML DOM...

SQL Server 2005 Express edition Output keyword syntax

I'm playing with the Output keyword in SQL Serer 2005 Express. I've written the following query: Declare @tempTable as Table(masterLotDB datetime) Insert into dbo.tblMasterLot (RecordCreation) Values ('2009-10-02') OUTPUT INSERTED.RecordCreation into @tempTable I get a syntax error of Msg 102, Level 15, State 1, Line 6 Incorrect syn...

What is the time of a datetime field in a database if only the date is entered?

I am working on an Access adp that has its data stored in sql-server. I have a sql statement that inserts the date part of a dateTime object into a datetime field of a table. INSERT INTO...DateValue(myDateTimeVariable) What is the time defaulted to? (I am hoping that it defaults to 12:00 AM) ...

How to connect SQL Server 2008 Express?

Hey, I can`t connect SQL Server Express 2008,I downloaded and installed SQL Server 2008 Express 64Bit, Microsoft SQL Server Management Studio. And I can`t connect to the SQL Server, I tried those options 1.Disable the firewall 2.Restart the SQL Server Service at Sql Server Configuration Service , I have two services that dosen`t worki...

Speeding up bulk inserting in SQL Server 2005

Is there any way to speed up bulk inserting in 2005? I'm looking into partitioning, is it good? ...

How to query SQL Server 2008 database for first and last name and order by relevance?

Basically I have a table like this: CREATE TABLE Person( PersonID int IDENTITY(1,1) NOT NULL, FirstName nvarchar(512) NOT NULL, LastName nvarchar(512) NULL ) And I need to find the top n results based on a user-query like this: "Joh Smi" The following query returns the results I need (I think). Just not in the relevant ...

Error checking in .NET with SQL 2005

Can I throw an exception on the SQL 2005 server so that I can catch it in C# code with SqlCommand.ExecuteQuery()? ...

What does this SQL Database error mean in C#?

I was adding a service-based database, but I got this message: A network-related or instance-specific error occurred while establishing a connection to the SQL server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Net...