sql-server

How do you get full error information for a stored procedure error out of LINQ-to-SQL or SQL Server?

Hi, I am calling a stored procedure through LINQ-to-SQL (yes, I know it's deprecated). I am getting back an error, but the IExecuteResult only seems to be able to provide me with a number, when I would like the full string error description (like what you would get if you executed the SQL by hand in SQL Management Studio). Alternatively...

Importing XML into SQL Server

I can find lots of example on how to import certain types of XML data into SQL Server 2005. But I've been given data in the following format (repeating "row" and "cell" with ID's instead of the tags been named etc: <?xml version="1.0"?> <rows> <row id='1'> <cell id='category'>Simple</cell> <cell id='query'>summary</...

TSQL Writing into a Temporary Table from Dynamic SQL

Consider the following code: SET @SQL1 = 'SELECT * INTO #temp WHERE ...' exec(@SQL1) SELECT * from #temp (this line throws an error that #temp doesn't exist) Apparently this is because the exec command spins off a separate session and #temp is local to that session. I can use a global temporary table ##temp, but then I have to come ...

TSQL Define Temp Table (or table variable) Without Defining Schema?

Is there a way to define a temp table without defining it's schema up front? ...

Deleting Global Temporary Tables (##tempTable) in SQL Server

Does SQL server automatically purge these out after a given length of inactivity or do I need to worry about purging them automatically? If so, how do I query for a list of tables to purge? ...

Save DateTime in mssql 2005 without hours, minutes and seconds

I want to save my dates in sql2005 as dates (without hour minutes and seconds). I want to do this because the between function isn't always correct if the hours, minutes and seconds are filled in. but neither datetime nor smalldatetime allows this, in 2008 you have the Date column which can do this. I've also found this question which ...

Insert binary data into SQL Server using PHP

I have a varbinary(MAX) field in a SQL Server 2005 database. I'm trying to figure out how to insert binary data (ie. an image) into that field using PHP. I'm using ODBC for the connection to the SQL Server database. I have seen a number of examples that explain this for use with a MySql database but I have not been able to get it to work...

Altering a column: null to not null

I have a table that has several nullable integer columns. This is undesirable for several reasons, so I am looking to update all nulls to 0 and then set these columns to "NOT NULL." Aside from changing nulls to 0, data must be preserved. I am looking for the specific sql syntax to alter a column (call it ColumnA) to "not null." Assum...

SQL server VS Oracle

I'm studying SQL Server but don't know much about Oracle. Can anyone give me a fair comparison of them? I've read a comparison about SQL Server 2000 vs Oracle 9i, but it's a little out of date. Have SQL server 2008 caught up Oracle 11g/i yet? (another question, what is the differences between i and g version of Oracles?) In addition, ha...

SQL - Using datediff in my SQL statement

This is my SQL statement that works using datediff.............. SELECT SUM(b134_nettpay) AS Total, b134_rmcid, b134_recdate FROM B134HREC WHERE datediff (dd, '2006-05-05', getdate()) > 90 GROUP BY b134_rmcid, b134_recdate ORDER BY b134_recdate DESC, b134_rmcid I need to Replace the Hardcoded date '2006-05-05' with MAX(b134_recdat...

SQL: retrieve only the records whose value has changed

Sorry for the nondescript title. I'll edit as we go along. I have a table RateTable: | Code | Date | Rate | B001 2009-01-01 1.05 B001 2009-01-02 1.05 B001 2009-01-03 1.05 B001 2009-01-04 1.05 B001 2009-01-05 1.06 B001 2009-01-06 1.06 B001 2009-01-07 1.06 B001 2009...

IGNORE_DUP_KEY option in SQL Server

Hello everyone, I did quite some search in MSDN and Google, but looks like the description for IGNORE_DUP_KEY option is very limited. My confusions, Is IGNORE_DUP_KEY option an option for a column? for a table? for a couple of columns? for an index (making index unique)? If set IGNORE_DUP_KEY to Yes, when insert a batch of records (u...

Specific rights to GRANT, REVOKE or DENY on stored procedures

Hi all, On a SQL Server 2008 database I want to give a user the rights to GRANT, REVOKE and DENY on objects only of type stored procedure (not using the db_securityadmin database role). How can i do this? Thanks! Sandor ...

.Net vs SSIS: What should SSIS be used for?

If I have the option of using .Net and can do data transformations just fine in .Net, when would I need SSIS? Is there a certain task that SSIS would be better for? Are the added benefits of transparency worth it? Is it just what I am more comfortable with? What are the best practices for determining this? ...

Re-indexing large table - how screwed am I?

I have a 1 TB, 600m row, table which has a misguided choice of indexed columns, specifically a clustered index on the primary key column which is never used in a select query. I want to remove the clustered index from this row and create it on a number of other rows. Table is currently like this: colA (PK, nvarchar(3)) [clustered i...

Which are more performant, CTE or temporary tables?

Which are more performant, CTE or temporary tables? ...

How to get ASPNET to be recognized as a Trusted Connection by SQL Server 2005

Here's the situaiton. I'm working on developing a new website to access an old database. This is a DoD installation so there's lots of security around. The current application is written in classic ASP, VBScript and some javascript. The new systems is ASP.NET. Accessing the database in the old system meant hitting the server with yo...

How do I Execute SQL Stored Procedures from within another Stored Procedure?

Everytime I refresh my DB with a backup file. I have to run about 10 stored procs separately because the backup file does not contain them. Is there a way to have one single sql script that refrences all these 10 stored procs and just run that ONE file compared to TEN? ...

How to set Windows Authentication on database imported into SQL Server 2000

Database cannot be seen when creating datasource in .NET - pre-existing databases can be seen. How do I set the permissions on the imported database? ...

Is connection pooling working correctly in Subsonic?

I am getting reports that connection pooling is not working in the Subsonic orm when used with sql server on a remote machine. I'm not sure how they are monitoring this, maybe with the profiler. Subsonic opens late, closes early as you are supposed to do in an orm layer, but is there any problem with the implementation that would cause...