sql-server

How to update sql server timestamp column without changing record data

I have an sql server table with a timestamp column. Is there a way to force the timestamp column to change without an actual update of the record? The reason I am asking is because I want the record's timestamp to change when a record is inserted/updated/deleted in a child table. Timestamp may not be the best way to go about doing this...

What's an efficient way to find rows where the timestamp and identity are not in sequence?

Background: I have a MS SQL application that reads data from our Oracle billing database once an hour, looking for new payments. It does this by storing a timestamp based on the CRT_DTTM of the most recent timestamp found each time it runs. e.g. SELECT * FROM V_TRANS WHERE TRANS_CLS = 'P' AND CRT_DTTM > TO_DATE('2010-01-25 12:59:44...

Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.

Hi All, I am using WinHost.com to host my site. The SQL Database/membership system works perfectly on my local computer, but when uploaded to the server it doesn't work. I've followed all steps correctly. And I have contacted support for my service but it's been over 2weeks and no reply. I keep getting this error when i try to login or...

Need help on rewriting a query that Uses a Cursor

I have a query that looks like this: DECLARE Match_Cursor CURSOR FOR SELECT ID,UserKey,TypeCode FROM [DB1].Table1 as t1 OPEN Match_Cursor FETCH NEXT FROM Match_cursor INTO @ID,@UserKey,@TypeCode; WHILE (@@FETCH_STATUS <> -1) BEGIN INSERT INTO #TempTable SELECT t2.Name, t2.Address, t2.Country, @UserKey, @Typ...

How do I get multiple XML children inside a single parent node instead of repeating the parent node for each child?

I'm trying to produce valid XML for a HL7 CDA document from SQL Server 2008 using FOR XML. I'm having trouble with the syntax to get multiple children inside a node instead of repeating the node for each child. /* Expected output: <!-- ******************************************************** Past Medical History section ************...

Caching in SSRS before clicking View Report

I know that there is Sql Server Reporting Services uses caching. But, I would like to now if it caches the report before clicking the View Report button i.e. does it already cache the data for the report by merely changing the values of the dropdown Report Parameters. Here is the scenario: I call stored procedures to get the labels a...

I cannot change sql server's default port (1433)

I want to add another port to default 1433 port of sql server. So I opened the configuration manager, selected Protocols for MSSQLSERVER and then double clicked on TCP/IP to see its properties. Then I selected the IP Addresses tab and scrolled down right to the IPAll section. and then I change 1433 to 1433,1450 so that I could also conne...

How do I group by min value in one field of table, keeping all the values from that same row?

I have a table like this: Field1 | Field2 | Field3 1 | 1 | 22 1 | 2 | 10 2 | 5 | 40 2 | 2 | 55 I want to group by Field1, and then take the values from the rest of the row with the minimal Field2, eg: Field1 | Field2 | Field3 1 | 1 | 22 2 | 2 | 55 Note that this is not the...

Sql Server error catching

Hi, Does anyone know of a way to capture an error message returned from a linked server? As an example, if i run the following command in SQL Server management studio: BEGIN TRY exec ('select * from xxx') at my_linked_server END TRY BEGIN CATCH print 'ErrorNumber...'+ CAST(ERROR_NUMBER() as varchar) print 'ErrorSeverity...'+ ...

sql server 2008 composite key

How to set a field as a composite key in sql server 2008 and how to create a composite key in gui sql server 2008? ...

SQL 2008 - MDX Leaf Level Calculation with Parent Aggregates

What is the optimal way to create a calculated measure to compute a custom variance formula (I cannot use the default Variance function because it does not accommodate custom weights). So the leaf level formula will have 2 components one component will be a fact at the leaf level and the other component will be a parent aggregate at vari...

.Net library to handle spatial data from SQL Server

I want to create application which would display spatial data on Map. I'm thinking about using SQL Server spatial features but not sure how should I handle that data in C#. Is there a good library I could use for that? ...

Render html code in sql server client report (rdlc)

I am using the asp.net web application and microsoft visual studio reportviewer control and rdlc for creating a report ( not using sql server reporting). I used the Product table to view the result. It has five fields and I display all the itemsin the report. One field is Description and it store the html code as the value(eg: <div><ul...

Error comparing dates in SQL query

Within a ASP.NET/C# class I am trying to run a query where I compare dates: select * from table1 CreatedDate >='DATEADD(d,-500,GETDATE())'; Basically I am trying to select rows from the the last 500 days. The problem is I am getting the following error: Syntax error converting datetime from character string. An example of the Creat...

Create a large dataset for speed testing

I need a Microsoft SQL Server 2005 or above stored procedure that will create a large number of rows (example: one million) so that I can then try various things like seeing how much slower SELECT * is compared to selecting each individual field name, or selecting from a view that selects from another view rather than selecting directly ...

need help with sql server 2008 query - max from select

hi i have this query and i need to get the max value of number and the city how to do it ? select city,count(id) as number from men group by city order by number desc thank's in advance ...

Subsonic: Select on a View, locks the table update?

Hi, I have a Web site live and running now. I am using the Subsonic to handle the database connections etc. I am getting time out expired error while updating a table (say Employee). When I check sp_who2, I see the suspended connection for the PID which is updating with a block by anothor pid, so I run the profiler and found out when e...

What SQL-Server lock level is suitable for insert?

I want to make almost 1000 inserts in a table in each second. And also each day I want to query all inserted rows just once at altogether. And I want to improve efficiency by multi-threading and connection-pooling. But i want to know which level of concurrency control is more suitable for me. The list of options for SQL-Server are in MSD...

How do I create a new sql server session in entity framework?

How do I create a new sql server session in entity framework? Thanks~ ...

Is there any tool available by which one can calculate (a)the size or a single row in sqlserver (b)the amount of traffic hitting the sqlserver

Is there any tool available by which one can calculate the size or a single row in sqlserver. This would really help in calculating the expected size of DB. Further one option can be to use sp_spaceused but it gives the details of the whole table... what we want is the size of a record (maximum size) in a table. Further is there any to...