sql-server

create pdf files in sql server

All of our correspondence is done via database mail in sql server. The data for document generation and the rules to trigger the generation are all on sql server. We now have to create a pdf file. I was planning on using pdfsharp/migradoc to do it, but then we'd have to create document and time its readiness with sql server data state...

Using SQL Server Agent to Run a Remote SSIS Package Programmatically on the Server

Based on the example here from MSDN, how could one provide SSIS package level variables if one were to invoke the package via "sp_start_job" procedure? Here is the example code from MSDN: Dim jobConnection As SqlConnection Dim jobCommand As SqlCommand Dim jobReturnValue As SqlParameter Dim jobParameter As SqlParameter Dim jobResult As ...

SQL job result in c#

I have this small code using SQL Server Agent to Run a Remote Package Programmatically on the Server. But the problem with the code is that even if the job out come is failure, but job was executed successfully. so this program always works fine. I want to know if I can actually capture the job result in C#.. Any thoughts? namespace L...

Combine two tables from two different SQL Server instances

Hi Everyone, I wanna learn how to join two tables which are located two different SQL Server instances. Thanks in advance. ...

SQL Server: inline conditional convert with XML?

I need to convert data in plain text columns into xml columns. However, not all of the content is valid XML, so I need to ignore any rows with invalid XML. Is there a way I can filter out the invalid data either using some sort of inline conditional convert or something in the WHERE clause? ...

foreign keys on table from different database

I have two databases in SQL Server and i have a common table for both the databases an important big table which holds the foreign keys to other tables. The problem is the Table is in DatabaseA, and I need to refer foreign keys to this table from DatabaseB. I know SQL doesn't support cross database referential integrity so what's the be...

SQL Server 2008: Unexpected results using SELECT TOP

Can anyone explain the SQL Server 2008 behaviour I'm seeing? Given a simple table definition: Column Type Nullability id (PK) int not null author_id int null title varchar(255) not null body varchar(MAX) not null type varchar(255) null comments_count...

Is SQL Server Timestamp deprecated and what to use in replacement

The T-SQL MSDN page states The timestamp syntax is deprecated. This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Does this mean to suggest that the SQL Server Timestamp data type is ...

SQL Server 2008 Express failed to attach mdf file

Here is the message. What's wrong with it? Is it a installtion problem? TITLE: Microsoft SQL Server Management Studio Cannot show requested dialog. ADDITIONAL INFORMATION: Parameter name: nColIndex Actual value was -1. (Microsoft.SqlServer.GridControl) BUTTONS: OK ...

How to do unit test on remote store procedure

I'm facing to do the unit test on the data access layer, all the data access layer call database through the store procedure. I plan to create a clean database used for unit testing, but I found most of store procedure will remote call the other database, I've no idea on how to unit test this kind of store procedure, should I create all ...

Get the records of last month in SQL server

I want to get the records of last month based on my db table [member] field "date_created". What's the sql to do this? For clarification, last month - 1/8/2009 to 31/8/2009 If today is 3/1/2010, I'll need to get the records of 1/12/2009 to 31/12/2009. ...

unique count of the columns ?

i want to get a unique count of the of multiple columns containing the similar or different data...i am using sql server 2005...for one column i am able to take the unique count... but to take a count of multiple columns at a time, what's the query ? ...

FOR XML AUTO in stored procedure

will FOR XML AUTO queries in stored procedures and using ExecuteXmlReader to retreive data to set business objects cause any performance hit? ...

Store sql query output in a excel file

Store sql query output in a excel file ...

Date Column was created

Hi, Do you know if there is a way to get the creation date for a SQL Server 2005 table column? I tried the sp_columns [tablename] to get some table information but no luck. Thank you. ...

Optimize for speed a simple stored procedure

Hello: In SQL 2008 I've this easy-but-bad-write sp that works: ALTER PROCEDURE [dbo].[paActualizaCapacidadesDeZonas] AS BEGIN SET NOCOUNT ON; DECLARE @IdArticulo AS INT DECLARE @ZonaAct AS INT DECLARE @Suma AS INT UPDATE CapacidadesZonas SET Ocupado=0 DECLARE csrSumas CURSOR FOR SELECT AT.IdArticulo,...

Can you tell SQL Server not to return specific rows?

We have a database where contacts are only soft-deleted, i.e. we set a bit named deleted to true. The API handles this, but sometimes you need to run queries directly against the database and it's easy to forget that bit, and export contacts that are actually deleted. It's not a big problem, because I'm used to the system, but if I'm on ...

How to convert access query to sql server query string?

how to converse access query to sql server query string by programing? example for access query string SELECT dbo_VNMST.VISITDATE, dbo_VNTREAT.TREATMENTCODE, dbo_VNMST.HN, dbo_VNMST.VN, dbo_VNTREAT_1.TREATMENTCODE, Count(dbo_VNMST.HN) AS CountOfHN, dbo_PATIENT_NAME.SUFFIX, Mid([firstname],2) AS FIRSTNAME1, Mid([lastname],2) AS LASTNAM...

Refresh ASP.NET page periodically to display real time data from SQL Server

I have a shopping cart based application in asp.net 2.0 which uses the concept of group buying.My requirement is that when user checks out a particular product,he should do it with the latest price of that item at that time. Now there is a scenario. I have a product with price 50.I did a checkout.50 is displayed in my cart.At the same ...

SQL Server index for cursors

I have an application that sometimes runs slow and I think it is related to database cursors. Don't have any access to the application source so I can't control the database calls but the database is open so I can add index where needed. Problem is that I don't know really know how to speed up cursors with index. The cursor queries a...