sql-server

Condition text field character insert with SQL Update statement

I need to update a field in a SQL-Server table conditionally. The field contains single-letter indicators of various status types, all together in the field. e.g. "I" for Insured, "O" for Other Insured, "H" for Health Qualified, etc., but together as a composite. The field might contain nothing, any of the letters, or all of the letters....

Split function in SSIS Expression

Hello All, I got a column values as '035-7448-001-3854535' In SSIS - Data Flow i need to split this into three different components as **Col1 Col2 Col3** 035 7448-001 3854535 this can be done using script component. Is there a way to deal with this in Derived Column Comp...

SQL Server date error

I try to execute the query below but I got an error saying"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.". I try to convert the date and cast the date but same error will comes out. select DATEDIFF(YEAR,cast(Startdate as datetime),isnull(cast(Enddate as datetime), GETDATE())) fro...

How to drop clustered property but retain primary key in a table. SQL Server 2005

i have the following key: ALTER TABLE dbo.Table ADD CONSTRAINT PK_ID PRIMARY KEY CLUSTERED ( ID ASC ) so i have clustered index and primary key on ID column. Now i need to drop clustered index (i want to create new clustered index on another column), but retain primary key. Is it possible? ...

Load XML by SSIS - DTD is prohibited in this XML document error

Hi All, Hope you all are doing well. Previously I asked a question how to import a XML file to SQL Server thanks to all you responses. As my source file come with heavy amount of data, I am trying to load by SSIS. Below are the steps I followed: Imported XML by BulkLoad to a XML type column Created XSD Schema out of that XML file in...

Count using like in SQL - how to?

I got a two tables tblGoals -name -url -siteID tblUrlCollection -url -siteID How do I count how many times every "url" from tblGoals is in tblUrlCollection using "url" and "siteID" as input? Would like to use like or something so I can add wildcards to the end of the "url" input parameter. Please help me out - thanks a lot. Perfor...

Why is CSV export missing in my SSRS report?

Hi, I have a few SSRS reports running on SQL Server 2008 Web Edition SP1 on my production web server. For some reason, CSV and XML export is not offered to me when viewing my reports in the report viewer. This applies to all reports on that server. As you can see, PDF, Word and Excel still work fine, it's just XML and CSV that are mi...

Why is this Sql Server CAST(..) rounding a Decimal to a VarChar ?

Hi folks, I'm trying convert some decimals to varchar, but they are getting rounded. Can someone tell me why? declare @UpperLeftLatitude DECIMAL, @UpperLeftLongitude DECIMAL, @BottomRightLatitude DECIMAL, @BottomRightLongitude DECIMAL SET @UpperLeftLatitude = 38.663 SET @UpperLeftLongitude = -122.857 SET @BottomRightLatit...

Is it faster to check if length = 0 than to compare it to an empty string?

I've heard that in some programming languages it is faster to check if the length of a string is 0, than to check if the content is "". Is this also true for T-SQL? Sample: SELECT user_id FROM users WHERE LEN(user_email) = 0 vs. SELECT user_id FROM users WHERE user_email = '' ...

Variable not getting set by select

I have an issue where a variable is not getting set by a select statement. The select joins a table variable @contracts (which is used to control a loop) and then joins to the real contract and contract line tables. my select is: select top 1 @contract_id = c.contract_id , @account = ch.account , @service = c...

SQL Server joins and where statements not working

I have this SQL Server statement, and I am not sure why it is returning no records: SELECT contacts.firstname , contacts.lastname , contacts.address1 , contacts.city, contacts.zip, countries.title AS countrytitle, states.title AS statetitle FROM providers, payableinvoices, contacts LEFT JOIN countrie...

MS SQL SSRS. I have Page Setup button in BIDS designer but users dont have it in the Reports Manager

There are quite a few buttons in BIDS (VS2008) when I preview a report but in the Report Manager what the users can see - there is only Export button. I would like at least have Page Setup button so the user can manage the export. If for instance I want to export to PDF on landscape A3 - what do I do? P.S. the SSRS and DB are MS SQL ...

x86 and Vista 32 bit compatability

Can i run x86 version of Microsoft® SQL Server® 2008 Management Studio Express on windows vista 32 bit edition? ...

What are the differences and gotchas when changing SQL Server compat mode from 90 to 100?

I would like to know what the implications for my database might be to swap from compat mode 90 (2005) to 100 (2008). Are there any performance enhancements? Are there any deprecated features? ...

SQL Server query problem

I have a problem regarding this query. I want to get the applicant latest position (please see below query). The result should be like this: aId Position Startdate Enddate 154 Web Developer 2008-04-07 NULL 155 Analyst 2008-06-12 2009-06-12 156 Quality Controller ...

Getting DATETIME for rows inserted/Modified

Hi There, am using SQL server 2005 , i have a requirement to get the Creation datetime of all the rows in a particular table, unfortunately the table do not have any "rowverion" or datetime column ( i know this is a major design flaw). so , i was wondering if SQL server maintains datetime for each row inserts. comments suggestions app...

Update all column values in a table with a column value of another table (related by a foreign key)

Hi, I'm trying to populate a new column in a table with data residing in another table's column. UPDATE dbo.PackageSessionNodes SET Created_By = (select userid from dbo.PackageSessions, dbo.PackageSessionNodes where dbo.PackageSessions.PackageSessionId = dbo.Packag...

SQL: Is it possible to SUM() fields of INTERVAL type?

I am trying to sum INTERVAL. E.g. SELECT SUM(TIMESTAMP1 - TIMESTAMP2) FROM DUAL Is it possible to write a query that would work both on Oracle and SQL Server? If so, how? Edit: changed DATE to INTERVAL ...

Secure SQL Server accessed by fat client

Is there a way to secure a sql server database which is accessed by a fat client? Meaning: The application communicates directly with the database as it places sql statements itself. That means, the connection string has to be somewhere on the client. Using this connection string (either with winauth or sql server authentication) any use...

Surprising performance differences: List.Constains,SortedList.ContainsKey,DataRowCollection.Contains,DataTable.Select, DataTable.FindBy

Originally i wanted to ask for the fastest way to query a Datatable for a special row. I have tested 5 different methods for their performance with a surprising(for me) result. Background: I have created a View in a MS Sql-Server 2005 Database. This view has current a total count of 6318 rows. Because i must check very often if a given...