Showing posts with label beginner. Show all posts
Showing posts with label beginner. Show all posts

Friday, March 30, 2012

Multi Value Parameters

Hi all, I am a beginner of SQL Server 2005.

How do you display multi-values parameters with coma in the SQL Server 2005 reporting?.

I believe we have to create a fucntion to do this, but how do you create a function in SQL Server 2005? we only can create / alter table.

I have an example from a book but it doesnt help me at all. it just give me an example of the code but when I tried, it did not work coz its a function like in VBA.

I want in the report look like this in the Layout:

SubCityID: =Code.ParameterList(Parameter!City.Value)
SubStore: =Code.ParameterList(Parameter!Store.Label)

Then in the report will looks like this.

SubCityID: 1, 5, 35
SubStore: Alabama, Hybird, Zap

The code for ParameterList that I ger looks like this:

Function ParameterList(ByVal Parameter As Object) As String
Dim sParamItem As Object
Dim sParamVal As String = ""

For each sParamItem in Parameter
If sParamItem is Nothing Then Exit For
sParamVal &= sParamItem & ", "
Next

Return sParamVal.SubString(0, sParamVal.Length - 2)

End Function

If there is a better way please help me.

Cheers

Quote:

Originally Posted by monadel

Hi all, I am a beginner of SQL Server 2005.

How do you display multi-values parameters with coma in the SQL Server 2005 reporting?.

I believe we have to create a fucntion to do this, but how do you create a function in SQL Server 2005? we only can create / alter table.

I have an example from a book but it doesnt help me at all. it just give me an example of the code but when I tried, it did not work coz its a function like in VBA.

I want in the report look like this in the Layout:

SubCityID: =Code.ParameterList(Parameter!City.Value)
SubStore: =Code.ParameterList(Parameter!Store.Label)

Then in the report will looks like this.

SubCityID: 1, 5, 35
SubStore: Alabama, Hybird, Zap

The code for ParameterList that I ger looks like this:

Function ParameterList(ByVal Parameter As Object) As String
Dim sParamItem As Object
Dim sParamVal As String = ""

For each sParamItem in Parameter
If sParamItem is Nothing Then Exit For
sParamVal &= sParamItem & ", "
Next

Return sParamVal.SubString(0, sParamVal.Length - 2)

End Function

If there is a better way please help me.

Cheers


Retrieve the whole SubCityId from the database using the following query and use it in your back end code...

declare @.sParamItem varchar(1000)

SET @.sParamItem = ''

SELECT @.sParamItem = @.sParamItem + convert(varchar(3),SubCityId) + ', '
FROM Table_Name WHERE My_Condition

select @.sParamItem

Friday, March 9, 2012

MSSQL7

I am a beginner with MSSQL7 so please bear with me. I am trying to open a
database that is approx 187KB in size. This file resides in the following
folder; C:\MSSQL7\DATA. This was restored from a backup we reterived from a
subjects computer. I obtained a copy of the MSSQL7 software. I was able to
load it on a standalone computer. This is as far as I can get. I want to be
able to copy the 187KB file in the approporiate folder of this newley
installed MSSQL7 program so I can simply open up the tables and see the data.
When I start Enterprise manager, I can't seem to connect it to this old
database.
Please help
cart34@.netzero.net
Have a look at these. You can use sp_attach_db to add it to the new server.
http://www.support.microsoft.com/?id=314546 Moving DB's between Servers
http://www.support.microsoft.com/?id=224071 Moving SQL Server Databases
to a New Location with Detach/Attach
http://support.microsoft.com/?id=221465 Using WITH MOVE in a
Restore
http://www.support.microsoft.com/?id=246133 How To Transfer Logins and
Passwords Between SQL Servers
http://www.support.microsoft.com/?id=298897 Mapping Logins & SIDs after a
Restore
http://www.dbmaint.com/SyncSqlLogins.asp Utility to map logins to
users
http://www.support.microsoft.com/?id=168001 User Logon and/or Permission
Errors After Restoring Dump
http://www.support.microsoft.com/?id=240872 How to Resolve Permission
Issues When a Database Is Moved Between SQL Servers
http://www.sqlservercentral.com/scri...p?scriptid=599
Restoring a .mdf
http://www.support.microsoft.com/?id=307775 Disaster Recovery Articles
for SQL Server
Andrew J. Kelly SQL MVP
"Cart34" <Cart34@.discussions.microsoft.com> wrote in message
news:522E836E-979C-4D80-8823-949D3148A6A9@.microsoft.com...
>I am a beginner with MSSQL7 so please bear with me. I am trying to open a
> database that is approx 187KB in size. This file resides in the following
> folder; C:\MSSQL7\DATA. This was restored from a backup we reterived from
> a
> subjects computer. I obtained a copy of the MSSQL7 software. I was able
> to
> load it on a standalone computer. This is as far as I can get. I want to
> be
> able to copy the 187KB file in the approporiate folder of this newley
> installed MSSQL7 program so I can simply open up the tables and see the
> data.
> When I start Enterprise manager, I can't seem to connect it to this old
> database.
> Please help
> cart34@.netzero.net