sql-server

How reliable is SQL server replication?

We have a database on SQL Server 2000 which should be truncated from time to time. It looks like the easiest solution would be to create a duplicate database and copy the primary database there. Then the primary database may be safely truncated by specially tailored stored procedures. One way replication would guarantee that the backup ...

MySQL versus SQL Server Express

Did the recent purchase of MySQL by Sun and the subsequent buggy releases kill the MySQL brand? I whole heartedly embraced MySQL when it first came out as I used to be a poor developer and all the RDBMs were too expensive. I have fond feelings for MySQL and their being able to compete with Oracle and SQL Server. I credit the original ...

How can I create a view in a SQL Server database with C#?

How do I create a view dynamically in SQL Server using C#? ...

Does anyone know if there is a list of German words used in the Fulltext word breaker?

SQL Server Full Text Search uses language specific Word Breakers. For the German language this is used to break/split words including compound words. However, it appears not all known compound words are included in the Word Breaker. I would like to know if a list is available of the words the Word Breaker does know about. ...

If I have an mssql varchar[1024] that is always empty in a table, how much actual bytes will be wasted?

If I have an mssql varchar[1024] that is always empty in a table, how much actual bytes will be wasted in the db file on disk per row? Please let me know the size for both: NULLs allowed storing '' NULLs not allowed storing '' NULLs allowed storing NULL Since the max varchar size is > 2^1 and < 2^3 I would assume 2 bytes for the len...

What's the best practice for primary keys in tables?

When designing tables, I've developed a habit of having one column that is unique and that I make the primary key. This is achieved in four ways depending on requirements: Identity integer column that auto increments. Unique identifier (GUID) A short character(x) or integer (or other relatively small numeric type) column that can serv...

Stored Procedures to .sql files

Is there a simple process in SQL 2005 for spitting all of my stored procedures out to individual .sql files. I'd like to move them into VSS, but am not too excited by the prospect of clicking on each one to get the source, dumping it into a text file and so on.. ...

Source Safe not saving "exclude" SQL SMO dll settings in Visual studio 2005

We use VS2005 and SourceSafe here at work for a project. I have this Setup and Deployment project for a couple of projects which have SQL SMO dll dependencies. I do not want to deliver these DLLs, so i set them all to "exclude" from the target. However when I check the solution in, and pull it back out from VSS, four of those 8 dlls come...

Parameterizing a SQL IN clause?

How do I parameterize a query containing an IN clause with a variable number of arguments, like this one? select * from Tags where Name in ('ruby','rails','scruffy','rubyonrails') order by Count desc In this query, the number of arguments could be anywhere from 1 to 5. I would prefer not to use a dedicated stored procedure for this ...

What's your approach for optimizing large tables (+1M rows) on SQL Server?

I'm importing Brazilian stock market data to a SQL Server database. Right now I have a table with price information from three kind of assets: stocks, options and forwards. I'm still in 2006 data and the table has over half million records. I have more 12 years of data to import so the table will exceed a million records for sure. Now, ...

How to map Image type in NHibernate?

I have at my SQL Server 2000 Database a column with type Image. How can I map it into NHibernate? ...

CAST and IsNumeric

Why would the following query return "Error converting data type varchar to bigint"? Doesn't IsNumeric make the CAST safe? I've tried every numeric datatype in the cast and get the same "Error converting..." error. I don't believe the size of the resulting number is a problem because overflow is a different error. The interesting thi...

Table Naming Dilemma: Singular vs. Plural Names

Convention has it that table names should be the singular of the entity that they store attributes of. I dislike any T-SQL that requires square brackets around names, but I have renamed a Users table to the singular, forever sentencing those using the table to sometimes have to use brackets. My gut feel is that it is more correct t...

What are the differences between osql, isql, and sqlcmd?

I am interested in using some kind of a command-line utility for SQL Server similar to Oracle's SQL*Plus. SQL Server seems to have several options: osql, isql, and sqlcmd. However, I am not quite certain which one to use. Do they all essentially do the same thing? Are there any situations where it is preferable to use one over the other...

"GRANT ALL TO role" in SQL Server

Please can someone explain what the following statement does in SQL Server 2005: GRANT ALL TO pax_writer pax_writer is a database role previously created using the statement CREATE ROLE pax_writer AUTHORIZATION dbo ...

Is SQL Server/Windows integrated security good for anything?

The distinctions among Windows user permissions and any set of SQL Server GRANTs seem like unrelated concepts. As often as not, it seems to actually be implemented with pseudo-logins for database roles; but that doesn't map usefully back to Windows permissions. Assuming single-login identity verification, why not just go with the simples...

nvarchar(256)....?

Why does nvarchar(256) seem to the be the standard for user names in SQL Server? Any system functions that return a user name return nvarchar(256), the ASP Membership provider uses nvarchar(256) 256 seems like an odd number (yes, I know its even...) - 255 I could understand (1 byte address) but 256 doesn't make sense to me. Can anyo...

PHP, MSSQL2005 and Codepages

I have a php script which accesses a MSSQL2005 database, reads some data from it and sends the results in a mail. There are special characters in both some column names (I know, it's terrible) and in the fields itself. When I access the script through my browser (webserver iis), the query is executed correctly and the contents of the...

Data not filtering before a join.

A puzzler from a coworker that I cannot figure out... update btd.dbo.tblpayroll set empname = ( select b.Legal_Name from ( SELECT Legal_Name, Employee_ID FROM Com.dbo.Workers WHERE isnumeric(Employ...

How do I get rid of .. Replace(Replace(Replace(Replace(Replace( … ?

I’m selecting data on an old database which has an abused status column. The status column has multiple pieces of information in it. Values are like ‘New Contact YYYY’, ‘Online YYYY’, ‘Updated YYYY’, ‘Withdrawn YYYY’, etc…. As you may have guessed, YYYY represents the year … which I need. In the past I’ve done something similar to R...