sql-server-2005

How to manage long execution time taken by the sp's in sql-server

We are using sp's to convert a uploaded file into corresponding master values and their combination as the business rule demands. For this we have made 4 sp's . All these sp's are called from a single sp which the user calls from application along with the data from the file. Note: Each sp must be called after the previous one has finis...

else If in tsql

I must update table, and I can't use else if in tsql. Is it exists? Status = ( CASE WHEN (Status in (0)) THEN 0 ELSE IF Status in (1) THEN 7 ELSE Status END ...

ODBC API to retrieve UserDefinedType of a Column in SQLServer 2005/2008

Hi, I have read that the ODBC API "SQLDescribeCol" could be used to retrieve the SQLDataType of a column. Similarly, is there any ODBC API which could be used to retrieve UserDefinedType of a column? -Vengatesh ...

Passing whole dataset to stored procedure in MSSQL 2005

How do I pass a dataset object to a stored procedure? The dataset comprises multiple tables and I'll need to be able to access them from within the SQL. ...

Join two tables at the same server

Hi, I have two databases at the same server 192.168.1.100 DB1 and DB2 When I'm trying to execute : select h.code,eh.Defaultname From hotels h JOIN [192.168.1.100].[dbo].[DB2].Hotels eh ON h.code = eh.code I get Could not find server '192.168.1.100' in sysservers. Execute sp_addlinkedserver to add the server to sysservers. I don't...

How do I convert this SQL query to LINQ-to-SQL?

How do I convert this SQL query to LINQ-to-SQL?: select COUNT(ua.UserAlertID) as Alerts, ph.LastName +' '+ ph.MiddleName as Name, ph.Email,us.UserSystemID, ur.UserStatus from PHUser ph inner join UserSystem us on us.UserID=ph.UserID inner join UserRole ur on ur.UserID=ph.UserID inner join Role rr on rr.RoleID=ur.Role...

how can we get data from xml file in sql server 2005 as described?

--- This is the content of the XML file or consider as XML variable. From above xml file , i want the data like .. id name desc parentid 1 serach Search NULL 2 Search By Name SearchName 1 3 Search By ID SearchID 1 How can we get with single SQL statement in SQL serv...

SQL report with Matrix which grows horizontal, need to break to next line instaed of moving to the next page.

I have a Sqlreport (SSRS 2005) which is using a Matrix, to print pivot table format data. and prints horizontically.Thats fine but it does not break to the next line of the same page, instead move to the next page and grows horizonticaly on the next page. I dont want to go another page instaed need to go to the next line. Please help m...

Getting Database Image to JQuery Dialog

Hello, I have a SQL Server 2005 database. This database has a table named "GalleryItem". Each GalleryItem has an ID (an int) and a field called "Thumbnail" (an image). Because this field is an image type, it's stored as binary in the database. My problem is, my user interface is pure HTML with JQuery. The user runs a query and the resu...

SQL - Is this possible?

I have a table that looks like this: -------------------------------------------- | Date | House# | Subscription | -------------------------------------------- | 3/02/10 | x | Monthly | -------------------------------------------- | 3/03/10 | y | Weekly | -------------------------------...

Change collation during a query in SQL Server? Proper sort for English/Cyrillic/EU languages

I am doing research for an existing system that has SQL Server as a backend. We're starting to store ad-hoc item title data in multiple languages (including Russian language in Cyrillic characters and other European languages). My question is about sorting this data, what are my options for changing the sort order on demand without chang...

sql query problem

i want to compare two date and time with each other and i want to select records that "StartTime" is greater than now time and the "StartDate" is greater than now date. but output is not correct.thanks in advance. my tabale'records are: StartDate StartTime ------------------------------- 1389/07/11 11:04 1389/06/23 21:17 1389/...

How can I force SQL Server Group By to respect column order when grouping?

I am using SQL Server 2005. SEE END OF THIS POST REGARDING BAD TABLE DESIGN. I have two columns. I would like to group by the first column with respect to the order of the second column. Microsofts documentation states that GROUP BY clause does not care about order, how can I enforce this?? Here is my pseudo query: SELECT col_1, ...

How to perform updates in entity framework 3.5 within an SqlTransaction

I'm working on a plugin that gets loaded via IOC from a 3rd party data driver. The plugin and data driver both operate on the same SQL Server 2005 database, but the plugin focuses on a small subset of tables that have foreign key relationships to the tables that the data driver manages. My problem is that in some operations, the data d...

How to limit the size of a table?

I have a SQL Server 2005 database. I am logging data to a table. I want to prevent the table data from getting too big. How can I limit the size of the table to x number of rows, and keep logging? I want the oldest rows to drop off. ...

SQL Server 2005 Index rebuild when increasing the size of a varchar field

I have a 12 varchar(50) fields in a table of about 90 million rows that I need to increase to varchar(100) in length. Each of these fields has an index (with only the one field as a member). If I increase the length of the varchar fields, will the indexes either need to be rebuilt (or would be rebuilt automatically), or would the stati...

Generate range of constants in SQL Server

Is there a way to select a range of constants, such as every integer between 1 and 100, or every month between two dates? Instead of doing this... select '2010-01-01' union select '2010-02-01' union select '2010-03-01' union select '2010-04-01' union select '2010-05-01' union select '2010-06-01' union select '2010-07-01' union select '...

Help with select query

I have a table with 2 columns:] ID Name 1 A 1 B 1 C 1 D 2 E 2 F And I want write a query to have output like : 1 A B C D 2 E F It's possible ? ...

Search Results are very slow when retreiving Varchar Records using like operator

Email Match field = '@hotmail.com' Email Match field entered: Results 1199 - speed of return 40 seconds Email Match field not entered: Results 429 - speed of return 1.6 seconds SELECT * FROM emails e where e.[From] like '%@hotmail.com%' OR e.[To] like '%@hotmail.com%'order by [id] DESC I have to use % at start and end because i want...

T-SQL Reverse Pivot on every character of a string

We have a table like below in an sql server 2005 db: event_id staff_id weeks 1 1 NNNYYYYNNYYY 1 2 YYYNNNYYYNNN 2 1 YYYYYYYYNYYY This is from a piece of timetabling software and is basically saying which staff members are assigned to an event (register) and the set of weeks the...