sql-server

Can I pass an IQueryable<> to a table valued function?

Hi, I have something like the following table to search some text: SearchedTextTable Id int primary key Text nvarchar(max) Code int The Text is full text indexed, so I made the following table valued function to work with LinqToSQL: ALTER FUNCTION [dbo].[SearchText] (@keywords nvarchar(4000)) returns @results table (Id int not null)...

What are locking issues in OLAP?

In one local financial institution I was rebuked by their programmers for expressing them my opinion that (their programmers' obsession with) (b)locking issues in their MS SQL Server 2005 OLAP (SSAS) database(s) did not make much sense to me. (The OLTP databases are SQL Server, Oracle and non-RDBMS ERP). What are locking issues in OL...

Error message with Entity Framework and Function Import

I have a DB stored procedure that returns a float. The Stored proc does calculations of inputs and spits out a "Rating" based in the inputs. I was able to update the Model and perform a function import, but when I try and use the new function in Linq i get the following error. Function metadata used in DbFunctionExpression must a...

what is the best technique to search text for list of word

hello all, i have table contain two column id and word . word column may contain one word or two or three ex ( computer , computer software , computer software computer ) i want search the text if it contain any word in that table . thank you . ...

what are the ways to call user defined function in side Stored procedure?

Hello, using select statement we can call functions inside the stored procedure, is there another ways to call functions inside the stored procedure. Thank you, Pradeep ...

SQL Identity with leading padded variable number of zeros

Hi, I need to zero pad my ID column for putting in drop down combo boxes, example 001 item text 101 item text 2 but if the numbers only went to 80, then we should have 01 item text 80 item text and so on, since I need to write this and allow tens / thousands / millions of items to go in, I don't know how many 0's i...

sp_MSforeachdb query help

Hi, I'm working with a lot of databases that are the same so I am using the sp_MSforeachdb procedure so that I can retrieve information from a table. The problem I have encountered is that there are other databases on the box that don't have the table, so I'm throwing invalid object errors. Here is What I have at the moment, I'm filte...

Running trigger that calls stored procedure on another database

We would like to run a trigger on one database (A) that calls a stored procedure on another database (B). CREATE TRIGGER trg_A ON TableA FOR INSERT AS BEGIN EXEC DatabaseB.dbo.stp_B END We would like to do this as LoginA with UserA on DatabaseA. We also have LoginB with UserB on DatabaseB. How can we accomplish this? Currently w...

SQl query required for the below Scenario

Here for part ‘CF061W’ finum is 25, I will select records whose fparinum value is 25 now I will get these parts FA061W, HRD20600 and SD1201. Now again I will select records whose fparinum value is finumber of above retrieved parts FA061W, HRD20600 and SD1201 and so on. This should continue till the highest level (flevel), for the abov...

Resizing the datagrid proportional with the form size

hii I am a fresher in the c # so i want to know how to resize the datagrid(any other control)aith respect to the form size. I just added one datagrid in the form then what i have to do?please help me...from the very basic please ...

What are the disadvantages of implementing transactions away from the database?

We know that there are some scenarios that require us to implement transactions in code, such as SqlTransaction/TransactionScope in .Net framework. The questions are: What are the overheads (besides speed)? Does it gets worse if we add more layers between the transaction and the DB? If yes, then what are the overheads and what cause ...

Else statement bug or transaction effect ?

Hi all, I'm using the following code in sql server 2005. BEGIN TRANSACTION; CREATE TABLE dbo.MyTable ( idLang int NOT NULL IDENTITY (1, 1), codeLang nvarchar(4) NOT NULL ) ON [PRIMARY]; IF @@ERROR = 0 BEGIN PRINT 'before_commit'; COMMIT TRANSACTION; PRINT 'after_commit'; END ELSE BEGIN PRINT 'before_rollback'; ROLLBACK...

What comparison method is better?

I have a trigger in a table with a good number of columns (perhaps around 100) and quite a lot of updates (for some definition of "a lot of"). If any of some fields have changed, the trigger inserts some data in another table. For obvious reasons, I want this trigger to run as fast as possible. What's the best method to do the compariso...

SELECT INTO a table variable in T-SQL

Got a complex SELECT query, from which I would like to insert all rows into a table variable, but T-SQL doesn't allow it. Along the same lines, you cannot use a table variable with SELECT INTO or INSERT EXEC queries. http://odetocode.com/Articles/365.aspx Short example: declare @userData TABLE( name varchar(30) NOT NULL, oldloca...

How to identify SQL Server instances installed on local machine ?

I have sql server 2000, 2005 exress, 2005, 2008 installed on my machine i installed on my own so there is no truble form me to know which on is on which version. However i am finding it difficult when i browse verious installation on others machine which i have not installed. Can some one please help me regarding how to identify the in...

resizing in the FlowLayoutPanel

hii I am having a form in which there is one datagridview which is in the flowlayoutpanel and there is other controls such as button an text box at the bottom I need to resize the datagrid view when the form is resized.but it shud not fill the entire form because the button and text box should not be get affected.but i need the datagri...

Array like functionality in SQL Server 2008

I want to read EmpID in EMP Table based on some condition. For every EmpID I need to do some operation in another table. How can I read single value of EmpID at a time. Thanks in advance ...

Adding one month to date if two values fall withinin same month, and then repeating the validation check (recursion?)

I have some rather dodgy data I'm looking at, and I've been tasked with finding out for how many consecutive months something has been going on for. However I have noitced that in some of my reference tables individual date values are being miscoded, and where there are multiple values in one month, the latest should be added into the ne...

Primary key violation constraint

string sqlInsert = "Insert into account_details( account_number, account_type, transfer_access_code, account_balance, customer_id) SELECT account_number, account_type, transfer_access_code, account_balance, customer_id from customer_details"; This query just takes data from customer ...

Add a Specific Time to a Date Value

I have a stored procedure that receives a date value like this: @AsOf date In the query I am using this date to filter a datetime field. I need to convert the date passed in to a datetime field with the time portion set to 09:00:00 PM so I can add a filter in the WHERE clause like this: (DateCreated < @TimeAsOfNinePM) I know this i...