sql-server

SQL Server : Pivot table

Hi All create PROC [dbo].[Sample] @fromDate datetime, @toDate datetime, @office varchar(30) AS declare @char varchar(200) DECLARE @Temp TABLE (ID int, Name varchar(50), Countt int, Reason varchar(20)) INSERT INTo @Temp (ID, Name, Countt, Reason) SELECT DD.ID, O.Name, Count(DD.Reason) Countt, convert(varchar,DD.Reason) Reason FROM ...

Hide Store Procedures

Dear Friends Is there any way that We can Hide Store Procedures in SQL Server from users thanks in advance ...

How to make Java work with SQL Server?

I know this is a basic question, but I can't seem to find an answer and I apologize, if this question is way too stupid, but here we go: I am supposed to work with SQL Server (no problem so far) and with Java (love java, so no problem here either), but now: What am I supposed to do to make the combination work? I got: JRE 1.6 and the sq...

Approach to generic database design

An application that I'm facing at a customer, looks like this: it allows end users to enter "materials". To those materials, they can append any number of "properties". Properties can have a any value of type: decimal, int, dateTime and varchar (length varying from 5 characters to large chunks of text), Essentially, the Schema looks...

SQL query for finding the first, second and third highest numbers

What is an example query to retrieve the first, second and third largest number from a database table using SQL Server? ...

passing null to DBtype.binary

hi I am using sqlparameter to insert value in to the table through procedure i have a prameter in procedure of type image in c# i set the parameter type as DbType.Binary now i want to pass Null value to the parameter if i use DBNull.value, i get incompatible data type error ...

Is there any way to impersonate a specific database engine while running another one?

This is something I would like to see while doing my day today programming works, But I've never seen such application yet. You input is highly appreciated. Lets say we have an application that needs MSSQL server as DBMS. And suppose you just need to install it and do something. (i.e You are not going to deply it in production servers e...

PIVOT syntax in SQL Server 2005

Pulling my hair out with this query. Maybe some of the experts here can see what I'm doing wrong? I have a TimeSheetTime Table as follows: CREATE TABLE TimeSheetTime( TimeSheetTimeID int IDENTITY(1,1) NOT NULL, TimeSheetItemID int NOT NULL, OffsetToEntryDate tinyint NOT NULL, Hours float NOT NULL ) This is populated w...

How to do Sql Server CE table update from another table

I have this sql: UPDATE JOBMAKE SET WIP_STATUS='10sched1' WHERE JBT_TYPE IN (SELECT JBT_TYPE FROM JOBVISIT WHERE JVST_ID = 21) AND JOB_NUMBER IN (SELECT JOB_NUMBER FROM JOBVISIT WHERE JVST_ID = 21) It works until I turn it into a parameterised query: UPDATE JOBMAKE SET WIP_STATUS='10sched1' WHERE JBT_TYPE IN (SELECT JBT_TYPE FROM JOB...

some good tutorials about SQL Server deadlock?

Hello everyone, I am learning SQL Server deadlock, about why there is deadlock, how to solve dead lock issue, best practices, how to analyze why deadlock happens. I am working on SQL Server 2008 Enterprise. Any recommended readings for me? thank in advance, George ...

Using Linq to query linked server in Visual Studio

I'm trying to use Linq to run queries against a linked server on our SQL Server machine through Visual Studio. On the SQL Server, I've successfully created the linked server and can run queries on it. In Visual Studio I've added a new data connection (under Server Explorer) to the SQL Server with success but the linked server tables are...

SP return null as ZERO ?

Using a stored procedure i have a fairly complex SQL statement which returns a COUNT value as a pseudo column. In many cases the result will be 'null'. This causes problems in my application, so i am wondering if it is possible to return a 'null' as '0' by default from the stored procedure? Thanks. UPDATE I need to apply the ISNULL to...

Is there something like the FileSystemWatcher for Sql Server Tables?

i would like my windows service (to be written in .NET) to recognize when new rows are added to a specific table, but instead of pulling the data from the sql-server i would like to use a server push model. does somebody has a hint for me how to achieve this? i am using sql server 2005. tia ...

SQL 2005/2008 create sequence diagram of stored procedure and db interaction

We have a very complex set of stored procedures that have been migrated over from Oracle in to SQL 2005. At one time, I heard there was a solution where sequence diagrams could be created from either watching a stack trace in VS or by the SQL profiler. I've searched long and hard and have found may tools that will create sequence diagr...

Is it safe to delete a clustered index in SQL server?

If I have a clustered index on a table is it safe to delete, and if I do, does it leave the table ordered the same way it was while indexed? ...

Turbogears 2 Tutorials?

Anyone know of a good beginners tutorial for Turbogears 2? I'm particularly interested in one that would have some details on working with existing database schema rather than creating from scratch. (and some pointers on MS SQL server setup would help too!) ...

Should I use the default dbo or a custom schema for common tables in multi-tenant database?

I have a database that's going to record data for different customers. Most of the customers have the same data requirements; however, that's not always the case. For the different requirements, I'm going to create extension tables that are going to be specific for their needs. For each customer, I'm going to create a schema and I will t...

Slowly Changing Fact Table?

Background) I've gone through the process of building a fact table for our inventory data that will in theory act as a nightly snapshot of our warehouse. What is recorded is information such as quantity, weights, locations, statuses, etc. The data is very granular and in many cases not specifically related to a single entity (our source ...

Does SQL Server round or truncate?

Say I'm inserting a 64 bit floating point double into a DECIMAL(17,5) field. Does the value get rounded or truncated? ...

Sql Server Service Broker Conversation Groups

Can someone explain conversation groups in service broker? Currently, I'm using service broker to send messages from one SQL server to another. On the sending server, I'm trying to correlate the messages so they are processed in serial on the receiving side. Based on the documentation, conversation groups seem to be a perfect fit for t...