sql-server

Continue statement in while loop in TSQL?

Hi, In Sql Server 2000 and 2005 I am running a select statement in a while loop. JFYI, this select statement is connecting to many linked servers and getting some values. IF there is any error, i want it should still execute next statement in the loop (similar to continue statement in c#) Example:- while @rowcount < 10 begin set @sq...

SqlDependency.Start permissions

I'm having a really tough time finding authoritative information on how to set up and use SqlDependency caching with SQL Server 2008. We've implemented the use of sql dependency cache, and it's working in our dev environment. Unfortunately, with the default settings the user needs to have quite elevated permissions which our DBAs will no...

Use PHP to set column description in MSSQL

I'm working on a web app that is using PHP and MSSQL. One of my requirements is to use the field descriptions in MSSQL in part of the web app. I know the Stored Proc. for adding descriptions in MSSQL is: EXEC sp_addextendedproperty @name = N'Description', @value = 'Description goes here', @level0type = N'Schema', @level0name = 'schem...

Add "DateModified" Column with an Update Trigger To All Tables that contain a "DateCreated" Column

I have many tables that have a [DateCreated] column that also needs a [DateModified] column. The [DateModified] column will need an Update trigger that inserts the current date (getdate()) into this new [DateModified] column. Each table uses custom schema, not [dbo]. Whats the easiest/best way to do this? ...

SQL server schema and default schema

I have a schema define in my database. Except now everytime I do a sql statement I have to provide the schema ... SELECT * FROM [myschema].table I set the default schema for my user using management studio and also ran the ALTER USER myUser WITH DEFAULT_SCHEMA [myschema] and I still get the invalid object 'table' when writing a query...

Can I create a 'reserved word' for a commonly used string in an SQL statement?

This is not a calculation or a function, it is simply a command I have to add often which is difficult to remember. I am often running queries on data across two databases (one old, one new) so I have to add "collate SQL_Latin1_General_CP1_CI_AS" wherever values of one are being compared with values of the other. For example... ...wh...

Rails + SQL Server: what to put in database.yml?

I'm trying to connect Rails to SQL Server. I installed the activerecord-sqlserver-adapter and ruby-odbc gems, but I'm not sure what to put in my database.yml file. What exactly is a DSN, and why do I need it? (Is this some windows-specific thing?) What do I do if I want to use Windows Authentication, instead of specifying a username an...

Team Foundation server: help for starters

hi all, I have installed TFS on my local dev machine and I want to "version control" my small project using TFS. However I have having trouble configuring TFS on my machine to get started. Can you please point me to some basic , starter internet resources for installing, configuring TFS. Thanks ...

What is the correct practice for updating a .net WCF service from SQL Server when data changes via replication

Environment: Replicated Server: SQL Server 2008 R2 Client Server: SQL Server Express Language: .Net 3.5 C# The replicated server will be continually updated by web services and have many of the tables published. The Client Server will have a down stream subscription to the replicated server. Goal: As the SQL Express instance pulls it...

In an UPDATE trigger - get the Primary Key without the column's name

I need to update the DateModified Column without knowing the name of the Primary Key Column. Basically, I've got a plain-jane UPDATE trigger like this: CREATE TRIGGER updated_SCHEMA_TABLE ON [SCHEMA].[TABLE] AFTER UPDATE AS BEGIN SET NOCOUNT ON; UPDATE [SCHEMA].[TABLE] SET DateModified = getdate() ...

SQL Server script to find LOB columns

Looking for a script to scan all tables in all SQL Server databases and list the columns which are large objects (TEXT, NTEXT, ,IMAGE VARCHAR(MAX), NVARCHAR(MAX), FILESTREAM, XML, VARBINARY). while I probably can code this myself, I want a ready made script. ...

is this stored procedure correct?

I have a stored procedure below, and I don't know if it's correct. I am inserting records in table PlanFinder.InvalidAwps, and deleting the same records from the PlanFinder.NdcAwp table. Also, can anybody help me with adding try catch in the same stored procedure? Alter procedure PlanFinder.InsertInvalidRecords as Truncate table [P...

"There can only be one IDENTITY column per table" - Why?

"There can only be one IDENTITY column per table" Why is it so? Take a scenario of a vehicle, there exists a chasis number which is unique as well as the registration number which turns out to be unique. To depict this scenario in sql server we need a custom implementation for on of the columns. Conversely, in Oracle you can have as man...

sql help 2 inserts in one procedure

Thanks everyone for the feedback Hi All, I'm am trying to create a stored procedure that does two inserts into two different tables. DECLARE @New_Group1_Id DECLARE @New_Group2_Id INSERT INTO Group1 (Group1_Desc) VALUES (N'Indianapolis') SELECT @New_Group1_Id = Scope_Identity() INSERT INTO Group2 ...

how can I save Encrypted image into sql server ?

Hello, I'm doing module to save and retrieve images using SQL server database 2008 and asp.net with vb.net. i already know how to do that but I need to save the image encrypted into database because images are very secure and I'm afraid if I saved it normally as binary data any one can convert this binary to see this images. if there is ...

perform SQL Server operations with windows user id from an ASP.NET page

I have an ASP.NET application that authenticates users using Ldap against active directory. This is, the users enter their same windows credentials on the webform to login to this application. The application is basically a SQL Server database frontend, and in my limited experience, I use the standard connectionStrings label in the web.c...

Not all labels on x-axis are showing in sql server 2008 report

Here is my problem. The bar chart report is showing data on x and y axis (y axis has 3 fields - min, max, avg values for time frame) and x axis has task type. For some reason, the chart only shows task types on the x-axis for some apparently interval, even though I have no interval set expressly. Any ideas? ...

Does non-unique clustering key increase likelyhood of page level locks?

I have a table with many columns of which the total max size greatly exceeds the 8k boundary. This table contains a ModuleID column which basically tells u what type of object it is (dont worry - I didnt design this) of which there are maybe 15 different values. And then it has a unique column called propertyID which is also an IDENTITY(...

SQL Query Assistance

This is not a homework question, just something at work that's bugging me. I'm trying to write a query against these tables below. The two tables, history and code are joined to the historyassignment table by the historyid and codeid columns. Table: HistoryAssignment | AssignmentID | HistoryID | CodeID | |--------------|-----------...

Error restoring backup from SQL2K to SQL2008R2

I'm restoring a SQL 2000 user database on a sql 2008 r2 box, but sometimes I receive the following error. This is also at the SQL Log. Error: 928, Severity: 20, State: 1 During upgrade, database raised exception 156, severity 25, state 1, address 0000000001C05A9F. Use the exception number to determine the cause It has ...