sql-server

SQL Query Notifications and GetDate()

I am currently working on a query that is registered for Query Notifications. In accordance w/ the rules of Notification Serivces, I can only use Deterministic functions in my queries set up for subscription. However, GetDate() (and almost any other means that I can think of) are non-deterministic. Whenever I pull my data, I would li...

Does the SQL Server 2005 database size property include the full-text index?

The title pretty much says it all, but in SQL Server 2005 Management Studio, if I look at the database properties and pick up the size value, will that include the full-text index data? Does it include the log file as well? Rough values are fine, but some of our ft indexes can be large, so I want to be sure of this. ...

PostgreSQL analog of SQL Server index

Trying to recreate my SQL Server database on PostgreSQL. Everything is ok except I can't find how to recreate this index: USE [mytablename] GO CREATE NONCLUSTERED INDEX [myindex] ON [dbo].[mytablename] ([col1],[col2]) INCLUDE ([col3],[col4]) GO Will be very grateful for help. Alexey Update: http://img38.imageshack.us/...

SQL Query 'invalid column name'

The following sql query works fine if I leave the four commented SET statements commented out. However, if I uncomment them, or just say I uncomment the first one SET @StoreID = tt_StoreID then I get the following message Invalid column name 'tt_StoreID' Why doesn't it recognize it, and how do I fix it ? *---------------------...

Stop SQL Server doing an unneccessary clustered index insert on a view

Hi I have a large table (between 74 and 88million rows) which is the middle table (Table B) of a many to many relationship. I have a view that builds a unified picture of the data contained in the these tables. The view has a clustered index defined against it. Table A on the left hand side of my large table is the core table in my da...

What is a good Microsoft SQL Database Export / Import tool?

I need a tool that will look at a Microsoft SQL Server database and export the data as a SQL script. I want to be able to run the script on another box with an empty database and insert all the data from the previous one without having to muck with the index's due to ref-integ constraints. ...

Getting rid of hard coded values when dealing with lookup tables and related business logic

Example case: We're building a renting service, using SQL Server. Information about items that can be rented is stored in a table. Each item has a state that can be either "Available", "Rented" or "Broken". The different states reside in a lookup table. ItemState table: id name 1 'Available' 2 'Rented' 3 'Broken' Add...

Is it possible to track the progress of ObjectContext.SaveChanges?

I'm working on a small console utility to upload batches of data to our hosted SQL server. The total data size can get up to several megabytes. I'd like a way to display the progress of the SaveChanges operation. Is there any way I can do this with the Entity Framework? If not, any recommendations would be appreciated. ...

Storing a 30KB BLOB in SQL Server 2005

My data is 30KB on disk (Serialized object) was size should the binary field in t-sql be? Is the brackets bit bytes ? ... so is binary(30000) .... 30KB? Thanks ...

Swap columns from two sql server tables

I would like to know if there is anyway I can compare two columns in SQL Server. The two columns are located in two different tables. When the column 1's value is smaller than the column 2's value: I want to replace the value of the column 1 with the value of the column 2. ...

Hidden features/Best uses of SQLCLR (MS SQL Server 2005 and 2008)

Continuing on the hidden features theme, I havent found one for SQLCLR (Microsoft 2005 / 2008). For example, undocumented features, tricks to do things which are very useful but not documented enough? Also features that are very useful in general. ...

GUID Primary Key not being created

When I add a user to my database, I am using a Guid for the primary key. But it is coming in as just a solid string of 0's. Where am I supposed to set it? I set it to "RowGuid()" in the MS-SQL server... ...

Sql Server table not updated with LINQ

I have a database that I have restored on SqlExpress from a bak file which was located on my SQL Server Pro instance. I am using Linq to interact with the database and am able to query and update some of my tables (i havent tried them all). However, I have at least one table that will not accept any kind of update (my UserAddress table)....

Is it a good idea to use rowguid as unique key in database design?

Hi there, SQL Server provides the type [rowguid]. I like to use this as unique primary key, to identify a row for update. The benefit shows up if you dump the table and reload it, no mess with SerialNo (identity) columns. In the special case of distributed databases like offline copies on notebooks or something like that, nothing else ...

sql server trigger

I have a table structure like this: create table status_master ( Name varchar(40) status varchar(10) ) I need to create trigger for status column if the status column value updated value FAIL then the trigger invoke one insert commant like: insert into temp value('s',s's') Could you please any one give me tha idea to solve this...

Executing an Oracle Stored Procedure from SQL Server 2005

how do we execute an Oracle Stored Procedure from SQL Server 2005? As part of a SQL Server scripts we need to execute an Oracle 10g Stored Procedure and download data to SQL Server 2005 ...

SQL Server 2005 Outer Join Problem In Stored Procedure

Good Afternoon All, I have two tables in my SQL Server 2005 DB, Main and MSDRGWEIGHTS. I want to create a stored procedure that updates Main.RelWeight with the appropriate value from MSDRGWEIGHTS. I have written the following code as part of the stored procedure: UPDATE MAIN left outer join MSDRGWEIGHTS AS W ON MAIN.MSDRG=W.MSDRG SE...

Collapse Blank Columns For Each Row

I have a large table I imported from an Excel spreadsheet. For five of the columns, containing teacher names, I'd like to collapse all of the blanks in each row so I have no blanks to the left of any name. An example would probably show better what I mean. Here's an example of the data now: Student ID Teacher1 Teacher2 Teacher3 Tea...

Insert value to another sqlserver db

I have 2 SQL Servers: temp1 XX.13.23.2 temp2 XX.23.45.6 The temp1 server has a database called db1 and contains a procedure called p1. I want that procedure to insert the value on Temp2 server Database name db2 on table T1. Is it possible to use procedure to insert value on another server's database? If this is this possible th...

Sql Server Management Studio - Programatically Creating Scipts based on DAL; Why use SET ANSI_NULLS ON before each table

I'm looking to generate the SQL scripts for table creation programmatically based on class definitions in my DAL similar to SQL Server Management Studio. So, when I right click on a table in MS SMS, and tell it to script table as > Create to > new query window, it generates some very understandable code. However, I'm not sure why the...