sql-server-2005

How to insert a record into multiple tables using a trigger ?

I have two Tables. I want to insert the same record on both tables at the same time. I.e., while I insert a record for the first table, this same record also is inserted in the second table using a trigger. Do you have any experience/advice in this process ? ...

Saving / Caching Stored Procedure results for better performance? (SQL Server 2005)

I have a SP that has been worked on my 2 people now that still takes 2 minutes or more to run. Is there a way to have these pre run and stored in cache or somewhere else so when my client needs to look at this data in a web browser he doesn't want to hang himself or me? I am no where near a DBA so I am kind of at the mercy of who I hir...

"User Preferences" Database Table Design

I'm looking to create a table for user preferences and can't figure the best way to do it. The way that the ASP.NET does it by default seems extremely awkward, and would like to avoid that. Currently, I'm using one row per user, where I have a different column for each user preference (not normalized, I know). So, the other idea that ...

Run db query (sql server 2005) with ajax. Is it possible?

I never worked with ajax. I need to know if it is possible to use ajax to run a query on the db (sql server 2005). My target is to run a query with refreshing the page. Have you got any ideas? ...

Do I need stored prodedures with Linq2SQL ?

I just started using Linq to SQL, and it just occurred to me that I don't really need any sprocs in the database since i can do all the data access through Linq to SQL. Is there any reason to write sprocs with Linq to SQL? Thank you. ...

partition function in SQL Server 2005

In MSDN about partition function from here, $PARTITION(Transact-SQL). I am confused about what the below sample is doing underlying. My understanding is, this SQL statement will iterate all rows in table Production.TransactionHistory, and since for all the rows which will mapping to the same partition, $PARTITION.TransactionRangePF1(Tra...

How might someone crack the SQL Server 2005 encryption stack?

This is one for all you security gurus out there. I have a SQL Server 2005 database with a database master key, which is encrypted with a very strong password using the server key, which in turn is encrypted using the service account credentials in the Windows Data Protection layer. I have a certificate which is encrypted using the dat...

Any way to convert database diagrams in sql server 2005 to other formats?

Can i convert the diagram to other formats like to Visio (other than copy to clip board command in sql server 2005) or any other utilities to do so? ...

Perform INSERT with SELECT to insert multiple records.

In the diagram below there is a 1:1 relationship between 'DodgyOldTable' and 'MainTable'. Table 'Option' contains records with 'OptionVal1', 'OptionVal2' and 'OptionVal3' in the 'OptionDesc' field. I need to do an insert into MainTable_Option with a select from DodgyOldTable. Something like this: INSERT MainTable_Option ([MainTableID],[...

"The wrong number of parameters does not match number of values for stored procdure" System.Data.Common.DbCommand nuance.

This could be an sql server database setup issue, but I am not to sure where to start looking. I have a stored procedure : CREATE PROCEDURE aStoredProcedure @dteSince DATETIME = null AS ... The c# code to call the stored procedure is :- using (IDataReader dr = database.ExecuteReader("aStoredProcedure")) { ... The c# code works fin...

Migrating MOSS 2007 from SQL 2000 to SQL 2005 - Addendum

This is a continuation of an earlier question I had about moving the databases for a MOSS 2007 installation from SQL 2000 to SQL 2005. Here's the URL for the original question: http://stackoverflow.com/questions/254517/migrating-moss-2007-from-sql-2000-to-sql-2005 In my test environment, I've successfully moved the databases to the SQ...

"infinite" sql statement?

Hi there, I've got a very strange sql-related problem. I'm accessing a MSSQL Server 2005 with PHP (odbc), when I profile the sql statement the following is executed: declare @p1 int set @p1=180150003 declare @p3 int set @p3=2 declare @p4 int set @p4=1 declare @p5 int set @p5=-1 exec sp_cursoropen @p1 output,N'SELECT fieldA, fieldB,...

ExecuteXmlReader and null Resultset Throws TargetInvocationException

I'm calling a stored procedure on a SQL Server 2005 database which returns an XML resultset. Sometimes it will return an null resultset becuase there are not rows to return. When this happens athe ExecuteXmlReader method throws a TargetInvocationException. This seems to be a known issue (see: http://social.msdn.microsoft.com/Forums/en-US...

Problems with CLR Code on Sql Server 2005

I am considering accessing some CLR code from a UDF in Sql Server 2005. I've heard stories that unhandled exceptions thrown in CLR code can bring down the server. Obviously my function would contain a try-catch block. However, certain exceptions (stackoverflow) can skip the catch. Does anyone have a set of guidelines that can comp...

Benefits of using sqlclient data provider with sql server 2005 over oledb data provider

hi all, Recently I think of shifting from oledb data provider to sqlclient as I am using sql server 2005 express edition as my app's backend which contain millions of records.. Can anybody give me concrete reasons for the same please reply sooon ...

Entity framework and VARBINARY

I’m using the .NET entity framework and I’ve got one entity containing a varbinary. Is there an easy way to get the size of the varbinary in the codebehind, efter it’s been retrieved from the database? I’m thinking there might be some way to get the size directly from the entity, something like entity.Context.Size – or do one need to ha...

sqlserver date arithmetic problem

I have a records of events with starttime and endtime for a calendar control. I want to get the events done on a particular date say 2/28/2009 But the db table has date data in form 2/28/2009 10:00:00, 2/28/2009 12:00:00. I tried this query in a sproc created in VS 2005 IDE but it didn't work ALTER PROCEDURE dbo.spSelectBenchEvent (...

Import data from Microsoft Works database into SqlServer

How can data be imported from a Microsoft Works database (*.wdb file) into a SqlServer2005 database. Would SSIS be able to do this? ...

Convert integer to a list of week days

I have an integer stored in a database (SQLAgent Frequency Interval) This integer is actually the sum of the selected days of the week that the schedule is to run The possible values are any combination of these values Sunday =1 Monday = 2 Tuesday =4 Wednesday= 8 Thursday = 16 Friday = 32 Saturday =64 ex 65 means that the schedul...

Is there an Access equivalent of the SQL server NewId() function?

I have written SQL statements (stored in a text document) that load data into a SQL server database. These statements need to be repeated daily. Some of the statements use the NewId() function to populate a keyed field in the database, and this works fine. While I'm in the process of writing an application replicate these statements, ...