sql-server

Is there a way to get DateTime value from timestamp type column. MS SQL 2005

I need a select from table which does not have column that tells when row was inserted, only timestamp column (values like: 0x0000000000530278). Some data was imported to the table yesterday and now I need to find out what exactly was imported :( Is there a way to do it using only timestamp info? Here I found that: Timestamp is a 8 by...

Functions vs Stored Procedures

Let's say I have to implement a piece of T-SQL code that must return a table as result. I can implement a table-valued function or else a stored procedure that returns a set of rows. What should I use? In short, what I want to know is: Which are the main differences between functions and stored procedures? What considerations do I hav...

SQL Server Storage of Data: 4 gb Raw, how much in SQL Server?

I have a SQL Server 2005 database and I have 4 GB of text files that I need to import into it. The question is, if these 4 GB of text files are 1.2 GB when they are zipped, how big would the database be if they are imported? Does SQL Server shrink data by default, or how would I set this (think create a database as a detached item, to be...

PHP/PDO and SQL Server connection and i18n issues

In our web-app we use PHP5.2.6 + PDO to connect to a SQL Server 2005 database and store Russian texts. Database collation is Cyrillic_General_CI_AS, table collation is Cyrillic_General_CI_AS, column type is NVARCHAR(MAX). We tried connecting to a database using two following schemes, both causing different problems. PDO mssql: $dbh ...

Do I need to set up Kerberos to use Replication in SQL Server 2005?

I want to setup replication on three SQL servers and one is not configured for Kerberos. (The SPNs are not setup yet) Do I need Kerberos and Pass-through delegation working to use replication in SQL Server 2005? ...

Multiple Indexes vs Multi-Column Indexes

I've just been adding an Index to a table in SQL Server 2005 and it got me thinking. What is the difference between creating 1 index and defining multiple columns over having 1 index per column you want to index. Are there certain reasons why one should be used over the other? For example Create NonClustered Index IX_IndexName On Tabl...

Create SQL Table from Excel spreadsheet

Is there an easy way to create a table in SQL Server (2005) from an Excel spreadsheet. I'm thinking maybe some tool? Thanks in advance. ...

In a SELECT statement(MS SQL) how do you trim a string

For Example; SELECT TRIM(Names) FROM Customer ...

How do I work with Multiple Recordsets in C++ ODBC

I am trying to streamline a complex process of storing information in multiple tables and them linking them to a central table. The linking occurs using IDENTITY values generated in each table to provide the unique linking. I know I can use a combination of SET NOCOUNT ON and SELECT @@identity to get each identity, but that still requi...

SQL Server - script to update database columns from varchar to nvarchar if not already nvarchar

Hello, I am in a situation where I must update an existing database structure from varchar to nvarchar using a script. Since this script is run everytime a configuration application is run, I would rather determine if a column has already been changed to nvarchar and not perform an alter on the table. The databases which I must support...

How can I combine multiple rows into a comma-delimited list in SQL Server 2005?

Right now, I have a SQL Query like this one: SELECT X, Y FROM POINTS It returns results like so: X Y ---------- 12 3 15 2 18 12 20 29 I'd like to return results all in one row, like this (suitable for using in an HTML <AREA> tag): XYLIST ---------- 12,3,15,2,18,12,20,29 Is there a way to do this using just SQL? ...

SQL Server - Using CLR integration to consume a Web Service

There are a few tutorials on the web that describe consuming a Web Service using SQL Server 2005's CLR integration. For the most, the process seems pretty convoluted. I've run into several issues including the need to change my database's trust level, and using the sgen tool to create a static XmlSerializer assembly; and I still haven't ...

Executing a stored procedure inside BEGIN/END TRANSACTION

If I create a Stored Procedure in SQL and call EXEC spStoredProcedure within the BEGIN/END TRANSACTION, does this other stored procedure also fall into the transaction? I didn't know if it worked like try/catches in C#... ...

Generating a Reporting Services 2005 PDF report and storing it on disk

Is there an easy way to generate a PDF report from an RDL that's been uploaded to Report Manager and put that file somewhere on the server's disk? I already have a location on disk to put the file, I just need to know how to programmatically generate the PDF. This is for SQL Server 2005 Reporting Services. Code in either VB or C# is fine...

SQL Express for production?

Is using SQL Express in a production environment a reasonable choice? I looked at Microsoft's comparison chart: http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx I would be using SQL Express with a small to mid-sized web site. I don't believe I would exceed the 4GB database size limit. Is SQL Express typically sup...

Determine Time Zone Offset in T-SQL

My database application is going to be deployed at multiple sites in different time zones. I need a T-SQL function that will determine the UTC timestamp of midnight on January 1 of the current year for YTD calculations. All of the data is stored in UTC timestamps. For example, Chicago is UTC-6 with Daylight Savings Time (DST), the fun...

Adding a Trendline to Bar Chart in Reporting Services

The title says it all. How do I go about adding a trendline to a bar chart in reporting services 2005? ...

Database Null

I have an asp.net text form that contains numerous decimal fields that are optional. I want to selectively update the database but not inserting a "0" for fields that do not have data (maintaining the null status). Typically, I would create multiple functions, each with a different signature to handle this. However, I am inserting the ...

Quick and dirty way to compare SQL server performance

Further to my previous question about the Optimal RAID setup for SQL server, could anyone suggest a quick and dirty way of benchmarking the database performance on the new and old servers to compare them? Obviously, the proper way would be to monitor our actual usage and set up all sorts of performance counters and capture the queries, e...

How do I add a Line break in a SQL Server Stored Procedure?

I'm making a Stored Procedure that basically concatenates a long string with data from many records. I want to do: set @output = @output + 'aaa' + LINEBREAK How do I specify that line break? ...