Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Sunday, February 19, 2012

Blank space

Hi I am trying to remove the space between the words to make it one single
word.
ETK SETTLEM ESCROW ACCOUNT
I used this command: REPLACE(String,' ','')
Thank you for any helpHi,
This should work
declare @.s varchar(50)
Set @.s = 'ETK SETTLEM ESCROW ACCOUNT'
Set @.s = REPLACE(@.s,' ','')
select @.s
Maybe your syntax was incorrect
Thanks
Barry|||> I used this command: REPLACE(String,' ','')
And what happened? The syntax looks correct, but incomplete. Are you
trying to update the data in a table, or just select it without the spaces?
Give some more information other than "I did this"...

Sunday, February 12, 2012

Bizare String Concatenation Issue - Explanation Needed

Hi all, can someone please explain why this is happening:
I execute the following:
DECLARE @.temp VARCHAR(500)
SET @.temp = ''
SELECT @.temp = @.temp + '[' + T.NAME + ']'
FROM MyTable T
SELECT @.temp
Say [MyTable] looks like this:
|NAME|
--
A
B
C
D
Here are the result from running the above code on two different SQL Server
2000 installations:
SQL Server 2000 #1
[D]
SQL Server 2000 #2
[A][B][C][D]
I want #2. Is there some database option that I'm missing or something? Any
help would be appreciated. Thanks.SELECT @.@.version from each server? Might be different builds.
For me:
DECLARE @.temp VARCHAR(500)
SET @.temp = ''
SELECT @.temp = @.temp + '[' + T.NAME + ']'
FROM master.dbo.sysdatabases T
SELECT @.temp
select @.@.version
SQL 2000, build 878 (Sp3a plus hotfixes):
[master][tempdb][model][msdb][pubs][Nort
hwind]
SQL 2005, IDW 13:
[master][tempdb][model][msdb][AdventureW
orksDW][AdventureWorks]
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Mike Treadway" <MikeTreadway@.discussions.microsoft.com> wrote in message
news:39B330F1-41D5-4A7F-BFE0-25998D07C492@.microsoft.com...
> Hi all, can someone please explain why this is happening:
> I execute the following:
> DECLARE @.temp VARCHAR(500)
> SET @.temp = ''
> SELECT @.temp = @.temp + '[' + T.NAME + ']'
> FROM MyTable T
> SELECT @.temp
>
> Say [MyTable] looks like this:
> |NAME|
> --
> A
> B
> C
> D
> Here are the result from running the above code on two different SQL
> Server
> 2000 installations:
> SQL Server 2000 #1
> [D]
> SQL Server 2000 #2
> [A][B][C][D]
> I want #2. Is there some database option that I'm missing or something?
> Any
> help would be appreciated. Thanks.|||Thanks Mike. I should have posted an update, but I found this:
http://support.microsoft.com/defaul...b;EN-US;q287515
What I posted here was a simple example of my issue, my actual query
contained a little more SQL and it was on a view instead of a table. Doing
the following resolved my issue:
SELECT @.temp = @.temp + '[' + T.NAME + ']'
FROM (SELECT * FROM MyTable) T
This caused the query optimizer to sort the results of the inner query
first, then apply the concatenations.
Thanks again for your response Mike.
"Mike Epprecht (SQL MVP)" wrote:

> SELECT @.@.version from each server? Might be different builds.
> For me:
> DECLARE @.temp VARCHAR(500)
> SET @.temp = ''
> SELECT @.temp = @.temp + '[' + T.NAME + ']'
> FROM master.dbo.sysdatabases T
> SELECT @.temp
> select @.@.version
> SQL 2000, build 878 (Sp3a plus hotfixes):
> [master][tempdb][model][msdb][pubs][Nort
hwind]
> SQL 2005, IDW 13:
> [master][tempdb][model][msdb][AdventureW
orksDW][AdventureWorks]
> Regards
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "Mike Treadway" <MikeTreadway@.discussions.microsoft.com> wrote in message
> news:39B330F1-41D5-4A7F-BFE0-25998D07C492@.microsoft.com...
>
>

Friday, February 10, 2012

Bitmask Multi-value report parameters

Hello all,
Is there any way to return a multi-value parameter as a sum of the
values instead of a comma seperated string?
For example, I have a table where one of the values is a bitmasked
number, representing a combination of 4 possible options.
I have the Report Parameter setup with Non-queried values. Ex. Opt1 = 1, Opt2 = 2, Opt3 = 4, Opt4 = 8.
And in my query, the WHERE clause is setup like: WHERE @.param &
ColumnX != 0
But of course, if I select multiple values for Opt1 and Opt3, it
returns 1,4 instead of 5.
Any suggestions?
Thanks - JasonYour parameter can be mapped to an expression. Query parameter and Report
Parameters are two different things. RS automatically creates the report
parameter for you so it seems like they are the same thing.
To do this is a two step process:
1. In layout tab, Report Menu ->Report Parameters. Change the name of the
parameter so it does not equal the name in your query.
2. Dataset tab, click on the ..., parameters tab. In the right column click
on the mapping and change to an expression which brings up the expression
builder. Have the expression builder change this to the way you want. You
might need to create some code behind report to do this.
I suggest whipping together a little VB test app to work out the code to
convert a comma separated string into a bitmask.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Jason" <flajason@.gmail.com> wrote in message
news:1176830583.305883.64460@.n59g2000hsh.googlegroups.com...
> Hello all,
> Is there any way to return a multi-value parameter as a sum of the
> values instead of a comma seperated string?
> For example, I have a table where one of the values is a bitmasked
> number, representing a combination of 4 possible options.
> I have the Report Parameter setup with Non-queried values. Ex. Opt1 => 1, Opt2 = 2, Opt3 = 4, Opt4 = 8.
> And in my query, the WHERE clause is setup like: WHERE @.param &
> ColumnX != 0
> But of course, if I select multiple values for Opt1 and Opt3, it
> returns 1,4 instead of 5.
> Any suggestions?
> Thanks - Jason
>

BitArray to binary

I want to store a binary string in SqlServer from VB .NET through a
stored procedure. I have been storing the binary data in a BitArray
which I am not set on by any means. When I pass the BitArray into a
stored procedure, which is looking for a variable of type binary, it
throws the following: "Object must implement IConvertible." BitArray
obviously does not implement IConvertable.

If anyone has a good way of passing binary data into a stored
procedure through a parameter array I'd appreciate it."Ramzi Abboud" <ramziabb@.gmail.com> wrote in message
news:a5617e65.0410141217.21e48d0@.posting.google.co m...
>I want to store a binary string in SqlServer from VB .NET through a
> stored procedure. I have been storing the binary data in a BitArray
> which I am not set on by any means. When I pass the BitArray into a
> stored procedure, which is looking for a variable of type binary, it
> throws the following: "Object must implement IConvertible." BitArray
> obviously does not implement IConvertable.
> If anyone has a good way of passing binary data into a stored
> procedure through a parameter array I'd appreciate it.

You might get a better answer by posting in a .NET or VB group. I don't know
what a BitArray is, but you can use the ADO Command object to execute stored
procedures with correctly typed parameters, which might be another
possiblity for you.

Simon