sql-server

Stored procedure modified time

Is there a way to find out when a stored procedure or table was last modified? I tried checking the properties via SQL Management Studio, but only found the creation date. Thanks! ...

SQL Server 2008 table variable error: Must declare the scalar variable "@RESULT".

I'm using table values for the first time as a parameter to a function in SQL Server 2008. The code below produces this error: Must declare the scalar variable "@RESULT". Why?! I'm declaring it on the first line of the function! ALTER FUNCTION f_Get_Total_Amount_Due( @CUSTOMER_LIST [tpCSFM_CUSTOMER_SET_FOR_MONEY] READ...

Decent simple SQL Server client

Hi, does anyone know of a very simple SQL Server client tool - that does the same basic functions as Management Studio (i.e. choose a database and run a query - doesn't need an Object Explorer, or anything fancy)? Ideally it would be great to have a single exe or zip file version that I could take around on a USB key - anything to avoid...

"Access 2002 vs SQL Server 200*" as DB for sharepoint

I work with a team that has a sharepoint site currently runnning and its lists are linked to an access DB. My question is really on the investment level, what would be the reasons to upgrade DB to sharepoint if only a few 100 users access this site. Is there a real benefit to replacing the DB with a version of SQL Server, escpecially if ...

what is the difference between INSTEAD OF and AFTER trigger in SQL Server?

What is the difference between INSTEAD OF and AFTER trigger in SQL Server? INSTEAD OF trigger invoked before unique key constraint, will the AFTER trigger invoke after unique key constraint? ...

gDatabase Optimization: Need a really big database to test some of the features of sql server

I have done database optimization for dbs upto 3GB size. Need a really large database to test optimization. ...

Storing JSON in an SQL Server database?

I'm developing a form generator, and wondering if it would be bad mojo to store JSON in an SQL Server database? I want to keep my database & tables simple, so I was going to have `pKey, formTitle, formJSON` on a table, and then store {["firstName":{"required":"true","type":"text"},"lastName":{"required":"true","type":"text"}} in...

Is there any encryption method for int column?

The scenario is that I want to encrypt finance numbers in a int column of a table of sql server and it is a big app so it is difficult to change the table column type from int to any other type. I use sql server 2005 and asp.net C#. Is there any two-way encryption method for int column of a table? It can be user-defined-function in sq...

Case Order by using Null

Hello I have the following test-code: CREATE TABLE #Foo (Foo int) INSERT INTO #Foo SELECT 4 INSERT INTO #Foo SELECT NULL INSERT INTO #Foo SELECT 2 INSERT INTO #Foo SELECT 5 INSERT INTO #Foo SELECT 1 SELECT * FROM #Foo ORDER BY CASE WHEN Foo IS NULL THEN Foo DESC ELSE Foo END DROP TABLE #Foo I'm trying to produce the following o...

Implement Partial sorted query in sql server 2005

I have to show records in such a way that some selected records should come first. After this, another records come in sorted manner from the same table. For example, If I select state having stateID = 5 then the corresponding record should come first. after this another records should come in sorted manner. For this, I tried union but...

How to handle Foreign key for optional field in .NET

What is the best way to handle following situation? A dropdown(for master table) is optional in a particular form. But, In database table the field is constrained with foreign key. If user don't select from dropdown then It creates problem because of foreign key. One solution is to create default option in master table and use it in ca...

Programmatically Create a Full Text Population Schedule via TSQL

Hi All, I have a SQL 2005 TSQL script which sets up my FT Catalog and Indexes, but I would like to also create a Population schedule for these indexes via the same Code, can anyone point me in the right direction. Thank you Matt ...

How to calculate End and start Week?

how does one calculate the beginning of a week from a given date e.g 23 March 2010 beginning of the week is 21 March 2010 ...

Queuing using the Database or MSMQ?

A part of the application I'm working on is an swf that shows a test with some 80 questions. Each question is saved in SQL Server through WebORB and ASP.NET. If a candidate finishes the test, the session needs to be validated. The problem is that sometimes 350 candidates finish their test at the same moment, and the CPU on the web serv...

How to update primary key

Here is my problem: I have 2 tables: 1.WORKER, with coloumns |ID|OTHER_STAF| , where ID is primary key, and 2.FIRM, with coloumns |FPK|ID|SOMETHING_ELSE| , where combination FPK and ID make primary key, and also ID is a foreign key referenced to WORKER.ID (not null, and must have same value as in WORKER). I want to make stored proced...

How to check if a Constraint exists in Sql server?

I have this sql: ALTER TABLE dbo.ChannelPlayerSkins DROP CONSTRAINT FK_ChannelPlayerSkins_Channels but apparently, on some other databases we use, the constraint has a different name. How do I check if there's a constraint with the name FK_ChannelPlayerSkins_Channels. ...

Objective-C: Database support

How can I connect to an Oracle database and SQL Server 2005-2008 database with Objective-C? ...

How to find the worst performing queries in SQL Server 2008?

How to find the worst performing queries in SQL Server 2008? I found the following example but it does not seem to work: SELECT TOP 5 obj.name, max_logical_reads, max_elapsed_time FROM sys.dm_exec_query_stats a CROSS APPLY sys.dm_exec_sql_text(sql_handle) hnd INNER JOIN sys.sysobjects obj on hnd.objectid = obj.id ORDER BY max_logical_r...

what are registry settings to enable TCP on SQL Server 2005 and 2008?

I want to programatically enable TCP connections on SQL Server. I believe we can achieve this by modifying registry entries and restarting SQL Server service. What registry should I edit? ...

How to create following table using MDX Scripting in Sql Server 2005?

Hi! I have the following table , Database Table: BatchID BatchName Chemical Value ---------------------------------------------- BI-1 BN-1 CH-1 1 BI-2 BN-2 CH-2 2 ---------------------------------------------- I need to display the following table. ...