sql-server

Exception handling in a real time, SQL-Server driven system

Hi, I have developed a report viewer in .NET Winforms (it just runs queries and displays results). This works against a reporting database. However, the above is a small subset of a much larger application, which gets data from another database. It looks like this: Monitored system has a change in state (e.g. latency increases) => Eve...

how are GUIDs generated in SQL Server?

How are GUIDs generated in SQL Server? I understand that I should use newid(), but what is the algorithm that function uses? Is it a hash of the time/date? ...

SQL Server Multiple cascade sequence

Assume Table A has two children tables, B and C with cascade delete between A-B, and cascade delete between A-C. When a row is deleted in A, the matching rows from B and C are deleted. How does SQL Server determine the order of the Cascades to fire? What I need is to fire the A-C cascade delete before the A-B cascade delete fires. I k...

Joining one particular table causes high logical reads

I'm writing a stored procedure in SQL Server that joins about 10 tables. When I exclude the join of this particular table from the query, logical reads looks reasonable. When I include it in though, logical reads of some of the tables rise to 9000. This table has primary key clustered, and I'm joining it just like the other tables in the...

Aggregate SQL Function to grab only one from each grouping

I have a table that I need to normalize with many fields In SQL-Server 2000. It contains 2 fields which I'm using to come up with distinct combination as defined by the specs. ID and Rate: there are multiple rows of same IDs and Rates I first created a temp table by grouping the IDs and Rates combination. SELECT ID, Count(*) AS IDCou...

SQL Server: Conversion failed when converting from a character string to uniqueidentifier.

I've been banging my head against a wall for the past hour trying to figure this out, sql is giving me the following error Msg 8169, Level 16, State 2, Procedure GetAppointmentsByProfessionalName, Line 6 Conversion failed when converting from a character string to uniqueidentifier. when this stored procedure is executed -- ======...

Fastest way to insert many records in the database

I am inserting record in the database (100,1.000, 10.000 and 100.000) using 2 methods (is a table with no primary key and no index) using a for and inserting one by one using a stored procedure The times are, of course better using stored procedure. My questions are: 1)if i use a index will the operation go faster and 2)Is there any...

Help needed to write SQL Query for SQL Logins.

I need to write SQL Query to Retrive the Following Settings of SQL Logins for SQL server 2005: 1.Enforce password policy 2.Enforce password expiration 3.User must change password at next login Thanx in advance. ...

How to solve warning "Referenced assembly targets a different processor than the application"

I have been able to build my windows form application that access databases in SQL Server. All parts of the application are able to access the server apart from the part where one can back up/restore a database. In this part I can not access the databases on the server and have come to believe it is because of these warnings. What do the...

Conditional insert sql server

Let's consider this basic insert insert into TableName (Col1,Col2,Col3) values (Val1,Val2,Val3) i want this insert to be done only if Val1 !=null and Val3!=null How to accomplish this? ...

Bug Status report gives 2 warnings in design previewer

I am customizing the Bug Status report from the CMMI process template in TFS2010. When opening the report in BIDS (a report designer SQLServer 2008), assigning 2 live shared datasources and clicking the preview tab, the compiler windows shows 2 warnings: [rsInvalidSize] The value of the DynamicHeight property for the chart ‘dundasChart...

Stored procedure - Passing a parameter as xml and reading the data

I have this stored procedure, that reads data from xml and make some inserts ALTER procedure [dbo].[SP_InsertIOs] @iosxml xml AS DECLARE @currRecord int -- parse the records from the XML EXECUTE sp_xml_preparedocument @currRecord OUTPUT, @iosxml BEGIN TRY INSERT INTO SN_IO ( [C1] ,[C2] ,[C3] ) SELECT [C...

duplicating database

how to duplicate whole database in sql ...

Getting DB Server DateTime in application

I am using Entity framework and have 1 field in database AddedDate that is DateTime and not null, so I need to pass DateTime value. But the problem is I have to pass DB Server datetime. How can I manage in this sceario or how can I get DB Server datatime to pass this. I need to some unique solution, because I am this on many forms. E...

Installing and distributing SQL Server without Management Studio

Have developed a small Windows application using SQL Server as its database. I need to give the installation pack to my customer, and include the required SQL Server 2005 Enterprise Edition. How can I distribute my database without including Management Studio? ...

How to insert selected value in insert statment in sqlserver

i need to insert 4 column in sql table fist 2 column i have type remain 2 column i have to get it from another table ..how combine and insert this in single query ...

Free MS-SQL front end like Heidi SQL

Hi guys, Yeah I know that SQL Server has got free express editions(2005/2008) But what i want is a small simple opensource tool like Heidi Sql. What are my options? Regards, naveenj P.S: This is for my fellow Java developer who admonished me for entertaining the idea that he would install MS-SQL in his machine(lol) ...

Microsoft SQL Server 2000 DTS as text

I've to document a bunch of SQL Server 2000 DTS, is it possible to export the DTS definition in text format? Thanks. Han ...

sql connection on c# smartdevice application

Hi all! I'm trying do build an application using the pocket pc emulator... My goal is to connect to a sqlserver express db placed onto another pc note that in a simple desktop program everything works fine, but in the smartphone program, when this code is run: SqlConnection DatabaseConnection = new SqlConnection(@"Data source=SERVER\SQL...

SQL function returns wrong value

I have a function that takes 2 parameters: @iEmployeeID and @dDate. It's purpose is to find a budget rate for the given parameters. In other words, it should find the largest date being smaller or equal to the @dDate argument, and return the rate that corresponds. Budget rates are: Start Rate ------- ----- 01-01-2008 6...