sql-server-2008

Debugging stored procedure in SQL Server 2008 Management Studio

Hi everyone, I have a stored proc I'd like to debug in the SQL Server 2008 management studio. I see a number of tutorials about doing this, but the ones I've seen don't have any input parameters going into the SP. My SP has several, and an output parameter as well. Could someone show me how to do debug a stored procedure with paramet...

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...

How to Load Bing Map using Coordinates from Database?

I have latitude and longitude saved inside a database. I have the bing map loading and I can set the VELatLong using regular values but can't seem to be able to load them from the database. Whatever I try the map just doesn't show at all. <script type="text/javascript"> var map = null; var selStyle = VEMapStyle.Road; var sel...

interval overlapping in tsql

hi folks, i need to get splited intervals and the number of overlapping intervals, eg basedata: interval A: startTime 08:00, endTime 12:00 interval B: startTime 09:00, endTime 12:00 interval C: startTime 12:00, endTime 16:00 interval D: startTime 13:00, endTime 14:00 now i have a separate interval from 10:00 to 15:00 and have to de...

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...

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? ...

SQL Server 2008: FileStream Insertion Failure w/ .NET 3.5SP1

I've configured a db w/ a FileStream group and have a table w/ File type on it. When attempting to insert a streamed file and after I create the table row, my query to read the filepath out and the buffer returns a null file path. I can't seem to figure out why though. Here is the table creation script: /****** Object: Table [dbo...

Can T-SQL function return user-defined table type?

I have my own type: CREATE TYPE MyType AS TABLE ( foo INT ) and a function receiving it as a parameter: CREATE FUNCTION Test ( @in MyType READONLY ) RETURNS @return MyType AS ... can it return MyType or only TABLE repeating MyType's structure: CREATE FUNCTION Test ( @in MyType READONLY ) RETURNS @return TABLE (foo INT)...

Does SQL Server 2008 compress the results sent back to my web server?

I have a typical reporting application: Large report <-- HTTP Compression --> ASP.NET Web Server <-- ??? --> SQL Server 2008 Since I have so much (repetitive) data to send to the client, I would like both network hops to have compression. Is there a transport-level compression setting for SQL Server? ...

SQL Server: Must numbers all be specified with latin numeral digits?

Does SQL server expect numbers to be specified with digits from the latin alphabet, e.g.: 0123456789 Is it valid to give SQL Server digits in other alphabets? Rosetta Stone: Latin: 01234567890 Arabic: ٠١٢٣٤٥٦٧٨٩ Bengali: ০১২৩৪৫৬৭৮৯ i know that the client (ADO) will convert 8-bit strings to 16-bit unicode strings using the curre...

My VARCHAR(MAX) field is capping itself at 4000; what gives?

Hello all... I have a table in one of my databases which is a queue of emails. Emails to certain addresses get accumulated into one email, which is done by a sproc. In the sproc, I have a table variable which I use to build the accumulated bodies of the emails, and then loop through to send each email. In my table var I have my body colu...

Problem using SQLDMO/Vb6 against SQL Server 2008

I have a client, that uses SQLDMO for a portion of a custom application that was written against SQL Server 2000, and they recently upgraded to SQL Server 2008. The majority of the app still runs fine (doesn't use SQLDMO), but the admin functions which rely on SQLDMO stopped working. I installed the SQL2005 backward compatibility pack,...

Failed to Kill Process in SQL 2008

I have a process with the following information, and i execute the kill process to kill this id, and it return me "Only user processes can be killed." SPID:11 Status:BACKGROUND Login:sa HostName: . BlkBy: . DBName: SAFEMIG Command:CHECKPOINT Normally, all the session to login to this server, it should have a HostName which display...

Get Asp.Net username from SQL Server 2008?

With windows and sql server accounts, I can access the logged in user with functions like: user_name() or suser_sname(). Can I access the user that is logged into asp.net in the same way? ...

Get the inserts

Hi there, I want to know if I can get all the INSERTs that are inserted at my database, from once. Writing just once ... I want that shows me all the inserts with the data and everything that was inserted in the moment of insertion. Not just the data, but everything including the INSERTs, is this possible? I'm using SQL server 2008, r...

SqlServer Split operation

Hi All, How to split a string in sql server. Ex: Input String: stack over flow Result: stack over flow Geetha. ...

How to get parameter values for dm_exec_sql_text

I'm running the following statement to see what queries are executing in sql server: select * from sys.dm_exec_requests r cross apply sys.dm_exec_sql_text(r.sql_handle) where r.database_id = DB_ID('<dbname>') The sql text that comes back is parameterized: (@Parm0 int) select * from foo where foo_id = @Parm0 Is there any way to get ...

Importing a SQL Server 2005 Profile Trace Template into SQL 2008

I'm using SQL Server 2008, but my ERP Vendor only offers a SQL 2005 trace template that they'd like me to run on my system. When I attempt to import it, I receive confirmation that it was successfully imported. However, it does not show up in the list of available templates. I've done this on two separate servers to the same effect. ...

Which SQL query is faster? Filter on Join criteria or Where clause?

Compare these 2 queries. Is it faster to put the filter on the join criteria or in the were clause. I have always felt that it is faster on the join criteria because it reduces the result set at the soonest possible moment, but I don't know for sure. I'm going to build some tests to see, but I also wanted to get opinions on which would ...

nested insert exec work around

I have 2 stored procedures usp_SP1 and usp_SP2. Both of them make use of insert into #tt exec sp_somesp. I wanted to create a 3rd stored procedure which will decide which stored proc to call. Something like: create proc usp_Decision ( @value int ) as begin if (@value = 1) exec usp_SP1 -- this proc already has insert into #tt...