sql-server

How do I store just a date in MS SQL from VB?

My project requires I use VB (5 or 6)* to store a date in an SQL Server database. The SQL datetime type includes the time, which I don't want. I'm also aware that VB's representation of a date doesn't mirror that of SQL Server. So, how can I store a date held in VB's date type in the SQL database, as the datetime at midnight on that dat...

Sql Server Ce 3.5 Check Constraints

Does Sql Server ce Suports Check Constraints? I wanted to do something like "ALTER TABLE WITH NOCHECK ADD CONSTRAINT id_range_check CHECK ( BETWEEN and ) and this will give an error on 'WITH' ...

Connecting to SQL Server with ActiveRecord

Have you ever had to connect to SQL Server with ActiveRecord? Is this possible? Can anyone provide some starting points? ...

Configure log file to be on a particular disk of a RAID array

I'm looking at a server which has RAID1+0 array and a RAID 5 array. The RAID 1+0 is used for system files and the RAID 5 array is used for SQL server database and log files. The RAID 5 array is made up of 6 72GB SAS drives. In the HP array configuration utility they are each seen as something like "72GB SAS Dtive at Port 1l:Box 1: Bay 3...

How do I add TFS as a Source control plug in to SQL Server Management Studio Express 2008?

In SQL Server Management Studio Express 2008 options, under source control the only available options "out of the box" are Microsoft Visual SourceSafe, and... (wait for it) ...Microsoft Visual SourceSafe (internet). Since I do have VSTS 2008 installed, with the TFS client of course, I find it odd that SSMS Express doesn't include suppor...

Checking a data conforms to a list of rules

Hi, I'm interested in understanding if there is a common technique/pattern for checking data in a database conforms to a set of rules. I'm interested, perhaps, in running a service/job each night that churns through the data and raises exceptions to rules. I would quite like the system to be dynamic, i.e. it's quite easy to define new r...

Sql Server 2000 trigger that references a Sql Server 2008 database fails

We have a Sql Server 2000 database application that needs to update our applications Sql Server 2008 database when certain tables are changed. For this, we use a trigger on the Sql 2000 server that fires a stored procedure on our Sql 2008 server. When trying it from SMSS, I get this message: The operation could not be performed becaus...

How to completely clean out a SQL Server 2005 database?

I made a copy of a DB that is used for a web app to make a new instance of this web app. I am wondering how do I remove all data and transactions and what not so that it is just a clean empty shell of tables ready to be written with new data? ...

Should I use != or <> for not equal in TSQL?

I have seen SQL that uses both != and <> for not equal. What is the prefigured syntax and why? I like != because <> reminds me of Visual Basic. ...

Why does SQL Server round off results of dividing two integers?

I have a table with a smallint column that contains percentages as whole numbers (i.e., 50, 75, 85, etc.) When I divide this column by 100, as in SELECT MY_COLUMN/100 AS PCT_AS_FRACTION FROM MY_TABLE the result is rounded to the nearest whole number. For example, for a row that contains the number "50", I get zero as my result. I ca...

Creating a stored procedure to return the rowcount of another stored procedure

Title says it all - is it possible to do this? I have some filters set in my source Stored Procedure and I really don't want to have to duplicate it in another just to get the rowcount. ...

Which is faster for multiple SQL calls - parameterized queries or stored procedures?

I'm using SQL Server 2005. I'm looking at opening a SQL connection, looping though a collection and running an update query (stored procedure or parameterized query) with the data from the collection item, then closing the connection. Which is going to give me better performance and why? ...

T-SQL for merging data from one table to another

Let's say there are 2 tables Table1 { ID, Name, Other } and Table2 { ID, Name, Other }. Both of them have identical records with the same IDs except that in Table1 all Name values are NULL. How can I import Name values from Table2 to Table1 using T-SQL (SQL Server 2008)? ...

T-SQL for combining 2 columns' values into one with "replicate"

There is a table with values like this: Sets | Reps -----+------ 2 | 10 3 | 15 3 | 12 4 | 8 I need to combine those two values into one in my SELECT statement, so I could get SELECT ... AS Reps FROM Table Reps ------------ 10,10 15,15,15 12,12,12 8,8,8,8 Any ideas how to do this? Testing script: DECLARE @Test TABLE (...

How to use Sql Server Database Publishing Wizard to make a schema with NO DATA?

I can't seem to figure out how to get it to create a script that does not also include all the data, for creating an empty shell of the database. Or will I have to manually remove all the INSERTS? ...

What's the longest possible worldwide phone number I should consider in SQL varchar(length) for phone

What's the longest possible worldwide phone number I should consider in SQL varchar(length) for phone. considerations: + for country code () for area code x + 6 numbers for Extension extension (so make it 8 {space}) spaces between groups (i.e. in American phones +x xxx xxx xxxx = 3 spaces) here is where I need your help, I want it to ...

running conditional DDL statements on sql server

Hello, i have a situation where i want to check a certain column ( like version number) and then apply a bunch of ddl changes trouble is i am not able to do it with in a IF BEGIN END block, since DDL statements require a GO separator between them, and TSQL wont allow that. I am wondering if there is any way around to accomplish this ...

Date Format conversion in SQL

I want to convert date format from 01/09 to January 2009 , 09/03 to September 2003 etc. Is this possible in SQL? Please let me know if there is a API for the same. ...

SQL Query to count by time for particular column

OK I'm using MS SQL and I have a table with values like this: ID Date Radio Time 111 4/1/09 1 3:00:00 111 4/1/09 2 4:00:00 111 4/1/09 3 14:00:00 111 4/1/09 1 15:00:00 111 4/1/09 3 16:00:00 222 4/1/09 2 2:00:00 222 4/1/09 1 5:00:00 222 ...

SQL Server Transactions

When to use ado.net and SQL Server transactions? Are there any reasons why one would choose to use ado.net transactions over SQL Server transactions when there is only one SP or query fired against the database within that transactions. ...