Showing posts with label format. Show all posts
Showing posts with label format. Show all posts

Monday, March 19, 2012

Create reports in ASP format?

We use an internal tool that can display ASP pages. I would like to use SQL Reporting Services to create reports in ASP format. The ASP page will access the database to get data. Is this possible possible with Reporting Services?

Ric

Hmmm... from what I understand, an ASP page is very similar to an ASPX page (created by Visual Studio). Possibly you could embed a report viewer in your ASP page. However, I'm not really sure that this is possible.

I'm not so sure that you want to create reports in ASP format -- that isn't possible. I think you are saying you want to display reports within an ASP page.

|||Active Server Pages and C# are completely different. Similar only because they are both programming languages. ASP was never meant to work with SQL Reporting Services. ASP works through ODBC and other interfaces and can connect to SQL databases and display the data onto web pages that have been setup using HTML tables using such things as the for loop etc..., but was never meant to work in this enviorment.

Sunday, March 11, 2012

Create Primary Key with increment and format?

I have an access table that has a primary key (entitled "ID Number"), no duplicates, the field is an integer.
And, importantly, the value is set to "increment".
The format is "phd"000 - so it starts outphd001,phd002, and so on...
How to do this in an SQL table? Can that format be done? Or is it better not to do it via SQL but in coding instead?In SQL Server you do Unique constraint or Unique index for no duplicates the former allow nulls the later not null being primary key and set IDENTITY property on the column for auto increament. Run a search for Unique constraint and Unique index and the IDENTITY property in SQL Server BOL(books online). Hope this helps.

Thursday, March 8, 2012

create new table format

Im new / novice user to writing SQL scripting. I have two tables and table1 has two columns

uslid and groupid,

uslid1, group1

uslid1, group2

uslid1, group3

uslid3, group1

uslid3, group3 etc

the second table2 has three columns

uslid, name, and location

uslid1, john, bldg 4

uslid2, jane, accounting

uslid3, joe, mail room

. I am trying to do a inner join but not working and not sure if this will work to create new temp table.

example of what i am trying to get in new temp table on one row:

uslid, name, location, groupid1, groupid2, groupid3

uslid1, john, bldg 4, group1, group2, group3

uslid3, joe, mail room, goup1, , group3

Hope i explained this ok. Im using 2003 server sql 2000 ver 7, thank you in advance.

Apart from the join issue, it sounds like you may not have the right database design. Here's a site that will lead you through the design effort and then explain the joins.

http://www.informit.com/guides/content.asp?g=sqlserver&seqNum=60&rl=1

Buck Woody

create new table format

Im new / novice user to writing SQL scripting. I have two tables and table1 has two columns

uslid and groupid,

uslid1, group1

uslid1, group2

uslid1, group3

uslid3, group1

uslid3, group3 etc

the second table2 has three columns

uslid, name, and location

uslid1, john, bldg 4

uslid2, jane, accounting

uslid3, joe, mail room

. I am trying to do a inner join but not working and not sure if this will work to create new temp table.

example of what i am trying to get in new temp table on one row:

uslid, name, location, groupid1, groupid2, groupid3

uslid1, john, bldg 4, group1, group2, group3

uslid3, joe, mail room, goup1, , group3

Hope i explained this ok. Im using 2003 server sql 2000 ver 7, thank you in advance.

Apart from the join issue, it sounds like you may not have the right database design. Here's a site that will lead you through the design effort and then explain the joins.

http://www.informit.com/guides/content.asp?g=sqlserver&seqNum=60&rl=1

Buck Woody

Sunday, February 19, 2012

Create Dynamic table from CSV

Hi,

I'm trying to import a csv file directly to my database every month. The contents of the file stays the same, however the format of the columns may vary. For example, 1 month I can have the following:

Time, Probe1, Probe2, Probe3, Probe4

Whereas the next month I can have something like this

Time, Probe2, Probe3, Probe1, Probe4

The "Time" column will always be on the left side, but the probes may vary in their placement.

I'm importing this csv to a temp table, where I then run a query to select any new data and enter that in my main tables. The problem is that when i import the csv, if the placement of the columns has changed, the data gets entered in the wrong locations.

Is there any way to create this temp table dynamically, based on what the header columns of the csv file are?

Any help appreciated!

I think the best approach would be to configure your flat file connection manager to read each row as a single column. This column would then be input to a script transformation component which would parse the line into columns and, based on the column order in the header row, put the values into the appropriate output columns.
|||Here is a code sample for a transformation script to illustrate the idea. The Row.Line is the input column that contains an entire line of a text file. This line is taken and split into an array by the comma delimiter. The first time we see the line, it is a header with column names. A boolean flag is used to detect the header condition and we save the column names in a variable. For every subsequent row, we iterate through the column names and match them to an output column that has been defined for the script, assigning the value parsed from the file into the correct column. Using this method, the order of the columns in the text file is irrelevant.

Code Snippet


Dim Line As String = Row.Line
Dim LineTokens As String() = Line.Split(","c)

If IsHeader Then
HeaderColumns = LineTokens
IsHeader = False
Else
' match input columns to output columns
With Output0Buffer
.AddRow()

For i As Integer = 0 To HeaderColumns.Length - 1
Select Case HeaderColumns(i)
Case "Time"
.Time = LineTokens(i)
Case "Probe1"
.Probe1 = LineTokens(i)
Case "Probe2"
.Probe2 = LineTokens(i)
Case "Probe3"
.Probe3 = LineTokens(i)
Case "Probe4"
.Probe4 = LineTokens(i)
End Select
Next

End With
End If


|||

Thanks a lot for the help...

Looks like it'll solve my problem Smile

Thanks!

|||Just make sure you revist the thread and marks it as answered |||

Ok, Since i'm not very proficient with SSIS...

here's what I have going right now.

Under Data Flow, I have a Flat File Source which uses my Flat File connection manager...there's only 1 column, just like you said.

Then I have it going to the transformation script component.

Under Input Columns, I only have Column 0, and its output alias is the same.

Under Inputs & Outputs, I didn't change anything...I didn't add any output columns since I want this to be done dynamically...

Then for the script,

I put in the script you gave me, and this is where i'm having problems...

I renamed Row.Line to Row.Column0,

but there's still a few undefined...such as IsHeader, HeaderColumns, and OutputBuffer.

Where do I define these?!

Thanks!

|||IsHeader and HeaderColumns are global variables that I didn't show in the example. They are shown below would go right under "Inherits UserComponents" in the script.

Code Snippet


Dim IsHeader As Boolean = True
Dim HeaderColumns() As String


Output0Buffer (don't forget the "0") is built for you to the definition that you supply on "Inputs and Outputs". This object will have the same name as your output (without spaces), but with "Buffer" appended to it. You should have one now, but likely just forgot to add the "0" (the default output is "Output 0" ).

You can't leave your output columns blank as they can't be created dynamically. You said your columns were constant, but could appear in different orders in the source. The script will worry about the order of the input columns, but you still need to define the constant output columns.

|||

Beauty.

It's working now.

Thanks a lot for the help.

Friday, February 17, 2012

Create DB from Backup

This is a multi-part message in MIME format.
--=_NextPart_000_000C_01C6A76D.C365CB60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi all, is there an easy way to create a Data Base from a Backup file?
I've tried creating the data base and then trying to restore the prevous = backed up data base but I get some errors like "Directory lookup for the = file (the mdf file) failed with the operating system error 3 (The system = cannot find the specified path)"
TIA
-- .seb
http://sgomez.blogspot.com
--=_NextPart_000_000C_01C6A76D.C365CB60
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&
Hi all, is there an easy way to create = a Data Base from a Backup file?
I've tried creating the data base and = then trying to restore the prevous backed up data base but I get some errors like = "Directory lookup for the file (the mdf file) failed with the operating system = error 3 (The system cannot find the specified path)"

TIA
-- .sebhttp://sgomez.blogspot.com=
--=_NextPart_000_000C_01C6A76D.C365CB60--Do not create the database. Just do a restore. On the Restore database
window select Options and make sure that the Restore As column shows a valid
path and that you have permissions on it.
Ben Nevarez, MCDBA, OCP
Database Administrator
".seb" wrote:
> Hi all, is there an easy way to create a Data Base from a Backup file?
> I've tried creating the data base and then trying to restore the prevous backed up data base but I get some errors like "Directory lookup for the file (the mdf file) failed with the operating system error 3 (The system cannot find the specified path)"
> TIA
> --
> ..seb
> http://sgomez.blogspot