I am writing a stored procedure and within this procedure I am using isNULL. If the value is null I want to use a select statement as the replacement value is this even possible?
IF ISNULL(@v_FilePrefix, (SELECT @v_FilePrefix = TransactionTypePrefix
FROM [ConfigTransactionType]
WH...
I have the following in a field ABCD, EFG, HIJ and can confirm this by selecting it. I need to be able to search this string for ABCD so I used the following:
case
when CHARINDEX(g.letters ,'ABCD') <> 0
then (- 2)
else (- 1)
end
However its always returning -1
...
Currently in a simple form i have the following declared table in code:
declare @FileIDs as table
(
ID int not null
)
and i can fill it up e.g. manually like this:
insert into
@FileIDs
values
(1)
insert into
@FileIDs
values
(2)
insert into
@FileIDs
values
(3)
Also i have another table called Files and ...
Hello,
I am making a login form on my site, and need a little bit of help. I keep receiving an error when I use this script:
<?php
$em = $_REQUEST["email"];
$pa = md5($_REQUEST["password"]);
//connectioninfo hidden
$connectionInfo = array( "UID"=>$uid,
"PWD"=>$pwd, ...
I hate code that looks like its been hacked together. I have just written this:
update table1.dbo.totals
set @FEE = case
when isnull(g.SGROUPS,0) > 1
then @GROUPPRICE * case
when CHARINDEX('JMCG', g.GROUPS) > 0
then (g.SGROUPS - 2)
else (g.SGROUPS - 1)
...
I would like to have a stored procedure that will update values in a table row depending on whether or not the parameters are provided. For example, I have a situation where I want to update all the values, but also a situation where I'm only required to update two values. I was hoping to be able to do this with only one procedure, rathe...
Subquestioning "full-text search sql server 2005"
Would the use of FTS (Full Text Search) be faster in comparison with searches using tsql LIKE on indexed column(s)?
Why?
And how much?
...
How do I construct my query to return only the values that match a, b, AND c? For example,
I would like to return all companies that have financial data with a fiscal year of 2007, 2008, and 2009.
SELECT Company from Table WHERE FiscalYear IN (2007,2008,2009) gives me all the companies in which any of the 3 years exists. I need to fi...
Hello,
I have such a simple question, I feel stupid for asking it. I can't believe I'm hitting my head on this.
I have a table called "Orders". "Orders" has a smalldatetime field called "DateOrdered". I need to get all of the "Orders" on a specific date. I have tried the following without any success:
SELECT * FROM Orders WHERE [DateO...
Hey all, i was wondering if there was a way to do this in MS SQL Server 2005:
DECLARE @theDate varchar(60)
SET @theDate = '''2010-01-01'' AND ''2010-08-31 23:59:59'''
SELECT AdministratorCode,
SUM(Total) as theTotal,
SUM(WOD.Quantity) as theQty,
AVG(Total) as avgTotal,
(SELEC...
Is is possible in SQL Server 2008 to create such a constraint that would restrict two columns to have NULL values at the same time? So that
Column1 Column2
NULL NULL -- not allowed
1 NULL -- allowed
NULL 2 -- allowed
2 3 -- allowed
...
is there a simple way to just output each record in a select statement to write to its own file?
for example, if you have the tsql query in sql server 2005,
select top 10 items, names + ':' + address from book
and you ended up with 10 text files with the individual name and addresses in each file.
is there a way to do this witho...
Or "octothorpe" for the pedants :)
Google says "non-sharable temp table" but I don't know what that means. Any clarification would be helpful.
Thanks
...
UPDATE: Adding more Employee and ReplacementEmployee
Table Employee -
EmployeeId SerialNo
-----------------------------
1 11111
34 23233
23 13234
Table ReplacementEmployee-
ReplacementId SerialNo
-----------------------------
11 11111
23 23233
13...
I have 4 SQL server(2008 version) tables
1) USER- to store user information (Fields : UserId,UserName)
2) FILES - to store files uploaded by user (FileId,FileName,UserId)
3) PHOTOS -to store files uploaded by user (PhotoId,PhotoName,UserId)
4) GROUPS= to store groups created by user ( GroupId,GroupName,UserId)
Now I want to get a USE...
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
...
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...
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...
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...
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...