sql-server

How to group data into buckets in Microsoft SQL

Hi, Currently my SQL statement is the following SELECT NAME, ROUND([DR# BASE]/DAYS_WORKED,0) AS 'BASE/DAY' FROM MYTABLE And the output data looks like the following NAME BASE/DAY James 300 Jane 310 Jim 313 John 325 Jonah 400 Is there a SQL statement to make the Output look like the following? NAME BUCKET BASE/DAY...

SQL Server 2005 how do I see what variables are being passed into a proc

I'm trying to debug a stored procedure. I'm creating a logtable (just a regular table) and inserting the stored proc input values into it, however this is in the middle of transaction and my inserts are getting rolled back. Is there any way to commit my inserts that have them saved even when a rollback is issued. Thanks ...

Linked server alike SSIS to read data from remote server!

I was thinking to create something like linked server which i could read data from a remote server using SSIS. My question is, can i do that in SSIS which i will only need to read data from a remote server and join with local server tables in a view! How to do that in SSIS?? Servers i am using are SQL Server 2005. ...

When Full Text Searching an XML column can you use XML Querying?

I am working on a database that is very localized, for example sake: Tables: Product - Has non localized columns (item number, created, etc) Product_Local - Has localized columns (description) and a language identifier column I am using SQL 2008 and full text searching requires for its word breakers that I set the language per column. ...

Check if a stored proc is running?

Is it possible to check is there any stored proc currently running in SQL Server??? ...

What is the problem with below query?

Hi I tried to execute the below query to get results as paging manner but when i tried to execute i'm getting error like Invalid column name 'RowNum' can you try it once DECLARE @PageNum AS INT; DECLARE @PageSize AS INT; SET @PageNum = 2; SET @PageSize = 10; WITH videosrn AS ( SELECT ROW_NUMBER() OVER(ORDER BY videoid) AS RowNum ...

Can i say that one column is more important then another in a full-text search?

I use Full-text indexing in SQL Server 2008. I can't seem to find an answer to this question. Say that i have a full-text index on a table with the columns "Name" and "Description". I want to make the "Name" column much more important then the "Description" column. So if you search for "Internet" the result with the name "Internet" wil...

How to Access Cursor Columns Without FETCH .. INTO

I'm using SQL Server to build stored procedures, and I'm using cursors to loop through a select statement I'm defining the cursor as follow: DECLARE @c_col1 varchar(max); DECLARE @c_col2 varchar(max); DECLARE c as CURSOR FOR SELECT col1, col2 FROM table; OPEN c; FETCH NEXT FROM c INTO @c_col1, @c_col2; SELECT @c_col1, @c_col2; I...

How to make SQL Server 2008 Check Constraint of a table Allow Only Certain characters?

I'd like to create a check constraint for a table in SQL 2008 which would allow A-Z characters (non case sensitive), numbers, hyphen (-), dot(.), space and underscore (_). Below is my current expression: ([company_code] not like '%[^A-Za-z0-9_ .+]%'). It fulfills all the above requirements except for hyphen. How could I make the express...

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? ...

redeploying a .NET assembly that contains CLR stored procedures

I have written a CLR stored procedure that is in an assembly. I have a build system that can auto-build and deploy .net application from our source control repository. I want the two things to work together so I can redeploy the assembly that hosts the CLR stored proc. However it looks like, unlike IIS, simply replacing the binaries ...

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? ...

Best practice regarding searching keywords with sql

I have three tables [USER] --Master user table [KEYWORD] --Master keyword table [USER_KEYWORD] --[USER]-[KEYWORD] mapping table Below is the structure in my db GO --master user table CREATE TABLE [USER] ( [USERID] INT IDENTITY, [NAME] VARCHAR(50) ) GO --master keyword table CREATE TABLE [KEYWORD] ( [KEYWORDID] INT I...

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? ...

DT_BOOL value of TRUE maps to 255 in a tinyint field. Why not 1???

I am using SQL Server Integration Services 2008 to put a certain boolean value in the database, and originally I used the SSIS type of DT_BOOL (boolean). However, in the database, the boolean value is being stored as a tinyint field (for legacy reasons). A boolean value of TRUE would be saved in the database as 255 (all bits on), inste...

SQL 2005 - Query to Find Tables with Most Rows

I searched for this for a while but came up empty ... hopefully someone here can help. Is there a query I can run on a database (SQL Server 2005) that will return the number of rows in each table? ...

Does a DDL trigger have visibility to the previous state?

A question came up in relation to another question regarding DDL triggers. If I have a DDL trigger such as the one below that is meant to warn or rollback a change if the parameter list changes, is there a way to get the previous state of (for example) the parameter list? As you can see, the trigger already references the new parameter...

How can I call a sqlserver function from VB.net(or C#) ? Is there some syntax like stored procedure?

Public Sub cleanTables(ByVal prOKDel As Short) Dim sqlParams(1) As SqlParameter Dim sqlProcName As String sqlProcName = "db.dbo.sp_mySP" sqlParams(1) = New SqlParameter("@OKDel", prOKDel) Try dbConn.SetCommandTimeOut(0) dbConn.ExecuteNonQuery(CommandType.StoredProcedure, sqlProcName, sqlParams) ...

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...