sql-server-2005

Linq for sql server reporting services, is it possible?

Is it possible to use my existing Linq data model for server side reporting (sql server 2005 reporting services)? ...

TSQL - Case Date Compare

Hi, I am trying to compare a date in SQL and create a new field to allow me to group the results by Todays date and other date(s). I am converting both dates to CHAR. However i am getting an expression error near = and ) - This is for an SSRS report. There is already a fairly complex SQL statement and i am just trying to add this ex...

SQL UPDATE with JOIN

I need to update table in SQL Server 2005 with data from its 'parent' table, see below: sale --------- id (int) udid (int) assid (int) ud --------- id (int) assid (int) sale.assid contains the correct value and want to update ud.assid with its value. What query will do this? I'm thinking a join but I'm not sure if its possible. ...

SQL to output line number in results of a query

I would like to generate a line number for each line in the results of a sql query. How is it possible to do that? Example: In the request select distinct client_name from deliveries I would like to add a column showing the line number I am working on sql server 2005. ...

SQL Server 2005 Shrink and Rebuild indexes

Hello, We have a weekly maintenance plan to shrink all user databases and rebuild their indexes. This has working fine until we created a read-only database, now each time the plan runs it fails when it starts processing this database due to its read only state. As far as I can see we have two options remove the read only flag from th...

if statements in sql query

Good morning all. I have an issue with a query. I want to select something in a query only if another field is somethingelse. The below query will better explain select Case isnull(rl.reason,'Not Found') When 'D' then 'Discontinued' When 'N' then 'Not Found' When 'I' then 'Inactive' When 'C' then 'No Cost' When '' then 'Not ...

Sql Server User vs Role

In Sql Server 2005, what is the difference between a database user account that is mapped to an active directory group vs. a database role that is contains the same active directory group as a member? ...

Do stored procedures have the ability to delete a file from the OS?

Out of curiosity, does a stored procedures have the ability to delete a file from the OS? If not I will have to make a windows Batch file that deletes the file and then runs the stored procedure using OSQL. ...

[sp_executesql] Incorrect syntax near 'sp_executesql'

I don't understand why the following is giving me the error. I thought it was related to the commented out section, but @SQL is nvarchar(4000). BEGIN sp_executesql N'SELECT ''td''' --sp_executesql @SQL, N'@StartDate DateTime, @EndDate DateTime, @End2 DateTime, @Program varchar(4)', @StartDate, @EndDate, @End2, @Program END ...

SQL Server 2005 Profiler How do you view the entire Stored Procedure Chain

SQL Server 2005 Profiler shows that a Stored Procedure (SP) was called and what variables were passed. However I don't know how to get profiler to show me subsequent calls. By this I mean when SP A calls SP B and SP B calls SP C. Is there a way to get profiler to show this chain? Thanks ...

How do I pass unicode into a stored procedure?

So I'm developing a PHP script that stores form data in an MSSQL DB. It seems the only way to be sure to avoid SQL injection is to use stored procedures, which one should anyway. All is good in English but in other character sets, in this case Thai, I get ????? I'm sure I'm missing something obvious. Here's the SP: ALTER PROCEDURE [...

Using Excel source on a machine without excel installed in SSIS

I have made an SSIS package that uses the Excel source to extract data from an Excel 2003 file and inserts it into SQL Server. When executed on production machine it gives and error of 'productleveltoolow'. Excel is not installed on the server. Can this error be due to this reason? ...

Can I save an 'Object' in a SQL Server database?

I want to save an object (of any type) into a field in a database in SQL Server 2005. Is it possible? Do I have to convert the object into something, like a byte array for example and cast it back when retrieving it? ...

Import Package Error - Cannot Convert between Unicode and Non Unicode String Data Type

I am trying to troubleshoot this error without success. I have made a dtsx package on my computer using SQL Server 2008. It imports data from a semicolon delimited csv file into a table where all of the field types are NVARCHAR MAX. It works on my computer, but it needs to run on the clients server. Whenever they create the same pack...

What is the max number of parameters that can be passed in stored procedure

Server in qustion is SQL Server 2008. On the same note, I need to know what is the max length of the string parameter passed in SP? ...

How to write a procedure that creates a view depending on its parameter in SQL Server 2005

I would like to write a procedure that creates a view depending on its parameter in SQL Server 2005. Grossly, this should look like this : CREATE PROCEDURE testprocedure @clientid float as create view testview as select * from deliveries where clientid=@clientid (but this does not work, it gives the error : Incorrect syntax near t...

Reporting Services (SSRS 2005) matrix column group shifting right when exported to xls

I have an SSRS matrix report that has 4 column groups with the last group set to hide some of its columns if they contain no data. The report works perfectly, however when exported to excel an empty column header appears and all the headers shift right. It can happen multiple times on the same sheet. For examples instead of seeing some...

Request joining the results of two other requests with GROUP BY clause in SQL Server 2005

I often find myself doing something along the following lines in sql server 2005 : Step1: create view view1 as select count(*) as delivery_count, clientid from deliveries group by clientid; Step2: create view view2 as select count(*) as action_count, clientid from routeactions group by clientid; Step3 : select * from view1 ...

How do I make schema changes to a mirrored database?

I have a mirrored database and I need to make some changes to it. Mainly, adding a view and some stored procedures. Now I know that if you make schema changes you are supposed to remove mirroring and the mirror database, make your changes to the principal, then backup-restore the principal and restore mirroring. Is this the case for s...

[SQL Server 2005]: XML query() works, value() requires singleton found xdt:untypedAtomic

I have a typed xml document stored as text. So I use CONVERT the data type to xml by using a Common Table Expression in order to be able to use XML methods: WITH xoutput AS ( SELECT CONVERT(xml, t.requestpayload) 'requestpayload' FROM TABLE t WHERE t.methodid = 1) SELECT x.requestpayload.query('declare namespace s="http://blah...