sql-server

Repair bad character due to encoding problem

Hi all, Recently we had an encoding problem in our system : If we had the string "æ" in our db ,it became "æ" on our web pages. Now this problem is solved, but the problem is that now we have a lot of "æ" in our database : users didn't see and validate pre-filled form with these characters. I found that If you read in utf 8 C3A6 yo...

Processing a database queue across multiple threads - design advice

I have a SQL Server table full of orders that my program needs to "follow up" on (call a webservice to see if something has been done with them). My application is multi-threaded, and could have instances running on multiple servers. Currently, every so often (on a Threading timer), the process selects 100 rows, at random (ORDER BY NEWID...

FREETDS and UNIXODBC character converting

hello guys.. ive got an error to fix. its: [FreeTDS][SQL Server]Error converting characters into server's character set. Some character(s) could not be converted when i use turkish characters to insert i get this error. my question is how can i disable that converting thing? im connecting to sql server via freetds and unixodbc. than...

Finding the SQL output of a parameterized query

I'm making a parameterized query using C# against a SQL server 2005 instance, and I'd like to take a look at the SQL that is run against the database for debugging purposes. Is there somewhere I can look to see what the output SQL of the parameterized command is, either in the database logs or in the Visual Studio debugger? ...

How does the SQL Server Fulltext Index grow?

I'm trying to get an idea of fulltext index growth and gauge its long-term memory needs. Does it keep a cache of each search? (Knowing that the first search for a new keywords always takes slightly longer, and is subsequently faster) Will it grow indefinitely? Or is its size pretty much finite after its creation? Should I expect perfo...

How to create view from more than one table in MS Sql Server database?

I have to create a view from more than one table in MS Sql Server database, but i am not able to get the correct syntax for the same. need help. thanks. ...

SQL insert default value

SQL Server 2000 Say if I have a table like CREATE TABLE [Message] ( [MessageIdx] [int] IDENTITY (1, 1) NOT NULL , [Message] [varchar] (1024) COLLATE Latin1_General_CI_AS NOT NULL , [column1] ... , [column2] ... , ... , [ValidUntil] [datetime] NULL , CONSTRAINT [PK_Message] PRIMARY KEY CLUSTERED ( ...

SQL Server with XML and selecting child nodes

I have the following XML: <tests> <test>1</test> <test>2</test> <test>3</test> </tests> And I am trying the following query: CREATE PROCEDURE [dbo].[test] @Tests xml=null AS BEGIN SELECT doc.col.value('(test)[1]', 'nvarchar(50)') FROM @Tests.nodes('//tests') AS doc(col) END But it only returns me a v...

How to automatically reseed after using identity_insert?

Hello, I recently migrated from a PostgreSQL database to a SQL Server database. To switch the data over I had to enable IDENTITY_INSERT. Well come to find out that I get all sorts of strange errors due to duplicate identity values(which are set as primary keys) upon doing an insert in any of the tables. I have quite a few tables. What ...

Help with simple query - why isn't an index being used?

I have the following query: SELECT MAX([LastModifiedTime]) FROM Workflow There are approximately 400M rows in the Workflow table. There is an index on the LastModifiedTime column as follows: CREATE NONCLUSTERED INDEX [IX_Workflow_LastModifiedTime] ON [dbo].[Workflow] ( [LastModifiedTime] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORE...

How do I do batch upserts in SQL Server?

I'm using the MERGE statement to upsert rows in an sql server 2008 database. However, my sproc is a single-row operation, whereas in fact I'd prefer to batch these. Is this even possible and, if so, how do I do it? ...

Oracle for the SQL Server DBA guides?

I am looking for a reference for a SQL Server DBA who has to come up to speed on basic Oracle 11 DBA tasks: backup, recovery, user administration, etc. There seems to be some material on the web for the reverse: Oracle -> SQL Server, but the only potentially useful resource I have found in a few searches is yet to be published: http://w...

Clustered index - multi-part vs single-part index and effects of inserts/deletes

This question is about what happens with the reorganizing of data in a clustered index when an insert is done. I assume that it should be more expensive to do inserts on a table which has a clustered index than one that does not because reorganizing the data in a clustered index involves changing the physical layout of the data on the di...

What would cause linq to sql to think that a parameter is nullable?

Hi I have a stored procedure that declares a input parameter @BatchNumber uniqueidentifier This field in the table is set to not allow nullables. When I drag in the stored procedure and it hooks everything up it says the parameter is nullable. I don't understand why. Is this normal for it to think that the parameters are nullable?...

t-sql pivot filter based on input column name

Based on following AreaState table Area State ------------------- A1 Active A1 Active A1 Active A1 Proposed A1 Proposed A2 Active A2 Proposed I want to write a stored proc that returns count of state for each of the areas. Input to the stored proc is any valid State (in this case @state is the input parameter). I was hoping ...

SQL Images in different tables

I am storing images in a SQL database , right now I have images being stored in separate tables depending on the object the images belong to, is there any reason ( performance etc..) why I should keep it this way and not store all images in the same table? ...

i want to get id through passing values in sql server 2008?

id Ptypefield Value 1 1 D 2 1 E 3 1 F 4 1 G 5 1 H 6 2 FL 7 2 IF 8 2 VVS1 9 2 VVS2 10 2 VS1 11 2 VS2 12 3 0.50 13 3 1.00 14 3 1.50 15 3 2.00 16 4 Marquise 17 4 Round 18 4 Pear 19 4 Radiant 20 4 Princess this table i want to get id no i give value like D and F this is ...

How do you write a recursive stored procedure

I simply want a stored procedure that calculates a unique id (that is separate from the identity column) and inserts it. If it fails it just calls itself to regenerate said id. I have been looking for an example, but cant find one, and am not sure how I should get the SP to call itself, and set the appropriate output parameter. I woul...

SQL: how to get all the distinct characters in a column, across all rows

Is there an elegant way in SQL Server to find all the distinct characters in a single varchar(50) column, across all rows? Bonus points if it can be done without cursors :) For example, say my data contains 3 rows: productname ----------- product1 widget2 nicknack3 The distinct inventory of characters would be "productwigenka123" ...

Use SSIS to import binary data in XML file

Hi, I am trying to use SSIS to import data from a XML file. One of the element in the XML file contains binary data of a pdf file. I created a SSIS package and setup the column properties of the XML source to DT_BYTES and also tried DT_IMAGE. But I get the following error. Error: 0xC0209029 at Data Flow Task, XML Source [1253]: SSIS Err...