Showing posts with label build. Show all posts
Showing posts with label build. Show all posts

Thursday, March 8, 2012

bulk insert fails

Hi

I have a page that bulkinsert data to my sql server, I build up the bulk insert part like this...

1 sb.Append("Exec p_BulkInsertPDI'<ROOT><PROT>")23 sb.Append("<PDI NID=""" & HiddenField1.Value & """ AID=""" & HiddenField1a.Value & """ MID="" GID="" UID=""" & UserID & """/>")45 sb.Append("</PROT></ROOT>'")
The problem I have here is that sometimes the AID value doesn't have any value beacuse on the previous page haven't sent any value to that hiddenfield.
So when I try to run this, I get a error message like this... "Conversion failed when converting the nvarchar value 'AID=' to data type int".

It would be the best if I could insert Null values if no value have been provided. Is this possible to do?

 
Regards
 

You could use the IF and Only If , e.g

sb.append("...." & _

IIF(hiddenvalue.value = "", "NULL", hiddenvalue.value) & _

".........")

EDIT: Got the syntax slightly wrong - it has been corrected.

|||Ahhh.. This sounds very promising, I'll try it and get back...|||

Hi Again

I replaced it so it look like this ...

sb.Append("<PD NID=""" & HiddenField7.Value &""" AID=""" & HiddenField7a.Value &""" FID=""" & (IIf(HiddenField7b.Value ="","NULL", HiddenField7b.Value)) &""" GID=""" & (IIf(HiddenField7d.Value ="","NULL", HiddenField7d.Value)) &""" MID=""" & (IIf(HiddenField7c.Value ="","NULL", HiddenField7c.Value)) &""" PID=""" & PID &"""/>")sb.Append("<PD NID=""" & HiddenField12.Value &""" AID=""" & HiddenField12a.Value &""" FID=""NULL"" GID=""NULL"" MID=""NULL"" UID=""" & UserID &"""/>")
And this is my sp...

p_BulkInsertPDI (@.FormData ntext)ASDECLARE @.hDoc int exec sp_xml_preparedocument @.hDoc OUTPUT,@.FormData BEGINSET NOCOUNT ON;INSERT INTO tbl_Form_Answers(NodeID, AprovalID, FaultID, Grade, MeasureID, ProtocolID)SELECT * FROM OPENXML(@.hDoc,'ROOT/PROT/PD',1)WITH ( NIDInteger , AIDInteger , FIDInteger , GID integer, MID integer, PID integer ) XMLEmpEXEC sp_xml_removedocument @.hDocEND

But now I get this errror message.. "Conversion failed when converting the nvarchar value 'NULL' to data type int"

How can I get this to work? I really don't want to make x number of insertation to the db, I would prefer to just do one.

Regards

|||

Ahhh, I didn't see that one coming. First thing you can try is use the dbnull.value instead:

sb.append("...." (IIf(HiddenField7d.Value ="",DBNull.value, HiddenField7d.Value)) )
Not sure if this will work. Otherwise your best bet is to temporarily assign a number as null. e.g. use a value you know will never occur (such as -1). After the inserts, you can then update the database and change all the -1 to NULL. Not the best method, but it should work.:

sb.append("...." (IIf(HiddenField7d.Value ="",-1, HiddenField7d.Value)) )
 
p_BulkInsertPDI
(@.FormData ntext)
AS
DECLARE @.hDoc int
exec sp_xml_preparedocument @.hDoc OUTPUT,@.FormData
BEGIN
SET NOCOUNT ON;
INSERT INTO tbl_Form_Answers(NodeID, AprovalID, FaultID, Grade, MeasureID, ProtocolID)
SELECT *
FROM OPENXML(@.hDoc,'ROOT/PROT/PD',1)
WITH ( NIDInteger , AIDInteger , FIDInteger , GID integer, MID integer, PID integer ) XMLEmp
UPDATE tbl_Form_Answers SET Grade = NULL WHERE Grade = -1

EXEC sp_xml_removedocument @.hDoc
END

|||

Hi

The DBNull.Value part didn't work so I ended up with your second proposal wich worked fine, I guess I have to live with the update part. It must be better than to make 20 database insert, which would have been the case if this wouldnt work.

Thanks for all your helpBig Smile

Best Regards

Thursday, February 16, 2012

bulding client/server apllication by using VB2005.net and SQL Server 2005

Hi

What is the ideal method that I can build client/server application by using IIS when I make my programme by using VB2005.net and SQL Server 2005 as database

thanks and waiting your replay

What do you mean by "ideal method" ?

Do you need a tutorial ?

Jens K. Suessmeyer.

http://www.sqlserver2005.de
|||

Mr. Jens K. Suessmeyer

Thanks for your replay I mean by ideal method any subject or Book explain step by step or tutorial How I can build my programme to client/server if a tutorial is available that's write for me

Thanks and waiting your replay

|||

There are several good video tutorials at this site concerning both ASP.NET and SQL Server.

Perhaps some of them will be useful for you.

http://www.asp.net/learn/videos/default.aspx?tabid=63

|||

Thanks for your advise and now I am living with Asp.net AJAX and I wish that is great vedios be useful for me

Tuesday, February 14, 2012

Building text files

Ok, I have an sp that'll build an SAP feed based on parameter input (params control which type of file I want to create). I want to build 9 files in total.

I have a table set up with my parameters and output file names.

Question 1: Process from DTS
I have a DTS package which will build a file based on params and filename from table, pulled with a Dynamic Properties task. How can I iterate through my table of parmas to create the muliple files?

Question 2: Process from a stored proc
I have a stored proc, from which the interation through values is simple. How can I create and export to the text files from the stored proc? I think I may be having a mental fart on this one. I could create a text linked server dynamically, but I have not played with them much, How to I write to one (create table etc).

PS: The file data cannot include cilumn headings

TIA -
bpdI'd go with the sproc and bcp out

Just change the IN to OUT

SET @.cmd = 'bcp ' + @.db_name + '..ETRS_ASI_FED_TEMP in '
+ @.FilePathAndName + ' -t"\t" -c -S' + @.@.servername + ' -Uscrub -Pscrub'

SET @.Command_string = 'EXEC master..xp_cmdshell ''' + @.cmd + ''''

Select @.Command_String

Exec(@.Command_String)|||Given this problem, I would probably try a VB or PERL script to extract the data. I know how to call bcp from PERL, but VB is still a bit new to me. Fortunately, if the data set you are exporting is small (few thousand rows), you could get away with just using FileObject writes. Biggest problem I have had with bcp is remembering to check the error file for any problems. Again, easy for me in PERL, but VB...|||Thanks! bcp is what I was looking for. Glad I can avoid DTS all together.

-bpd

Building SQL using variables

Hello all!

I am sure there is a technical name for this, but I am trying to build a sql statement using variables... where the variables would be entire clauses within the statement, not just values. This will ultimately be used in a stored procedure.

ie. Focus on the @.AndClause variable

-----------
declare @.AndClause varchar(128)
select @.AndClause = ' AND lastname like ''jharris%'''

SELECT *
FROM my_customer_table
WHERE 1=1
@.AndClause
-----------

I have seen this done before but can not find it in an of my references. Thank you for your helpdeclare @.AndClause varchar(128)
set @.AndClause = ' AND lastname like ''jharris%'''
declare @.vSQL varchar(200)
set @.vSQL = 'SELECT *
FROM my_customer_table
WHERE 1=1' + @.AndClause

exec(@.vSQL)|||I missed the plus sign... Thanks alot Jora! Do you know if there is technical name for this?|||euh ... building dynamic sql statements? Don't think there is one term for it. Also, you can use the stored procedure sp_executesql for executing dynamic queries. See Books Online for more info on the differences between the two methods.

Building SQL Query to fill a treeview control with Year->Month->Day nodes

Hello,
I have load dates for each row in my database table. I'm trying to build a
query that will give me all of the unique years, then all of the unique
months for that year, then finally all of the unique days for that month.
I'm trying to load a treeview control with the results like so.
Year
|_
Month
|_
Day
Day
Etc.
Year
|_
Month
|_
Day
Etc.
If anyone has any ideas or experience on how to do this I would appreciate
it.
Thanks
You could simply write a query that does a join with a calendar table.
http://www.aspfaq.com/2519
http://www.aspfaq.com/
(Reverse address to reply.)
"MJB" <mb2@.email.com> wrote in message
news:euAyUyLcEHA.2476@.TK2MSFTNGP09.phx.gbl...
> Hello,
>
> I have load dates for each row in my database table. I'm trying to build
a
> query that will give me all of the unique years, then all of the unique
> months for that year, then finally all of the unique days for that month.
>
> I'm trying to load a treeview control with the results like so.
>
> Year
> |_
> Month
> |_
> Day
> Day
> Etc.
> Year
> |_
> Month
> |_
> Day
> Etc.
>
> If anyone has any ideas or experience on how to do this I would appreciate
> it.
>
> Thanks
>
|||Hmm, looks like it could help. Unfortunately, I only want my treeview to
show the dates that are actually in the database, where as this approach
seems to just show all dates between a range.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:eSYmS0LcEHA.3480@.TK2MSFTNGP11.phx.gbl...[vbcol=seagreen]
> You could simply write a query that does a join with a calendar table.
> http://www.aspfaq.com/2519
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "MJB" <mb2@.email.com> wrote in message
> news:euAyUyLcEHA.2476@.TK2MSFTNGP09.phx.gbl...
build[vbcol=seagreen]
> a
month.[vbcol=seagreen]
appreciate
>
|||Can you show your table structure (see http://www.aspfaq.com/5006)?
http://www.aspfaq.com/
(Reverse address to reply.)
"MJB" <mb2@.email.com> wrote in message
news:#jGPjPMcEHA.3476@.tk2msftngp13.phx.gbl...[vbcol=seagreen]
> Hmm, looks like it could help. Unfortunately, I only want my treeview to
> show the dates that are actually in the database, where as this approach
> seems to just show all dates between a range.
>
> "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:eSYmS0LcEHA.3480@.TK2MSFTNGP11.phx.gbl...
> build
unique
> month.
> appreciate
>
|||Well, it's nothing special. It's just a table with a Primary Key with a few
other columns and a LoadDT column that is of type datetime.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:u5DN4RMcEHA.2840@.TK2MSFTNGP11.phx.gbl...[vbcol=seagreen]
> Can you show your table structure (see http://www.aspfaq.com/5006)?
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "MJB" <mb2@.email.com> wrote in message
> news:#jGPjPMcEHA.3476@.tk2msftngp13.phx.gbl...
to
> unique
>

Building SQL Query to fill a treeview control with Year->Month->Day nodes

Hello,
I have load dates for each row in my database table. I'm trying to build a
query that will give me all of the unique years, then all of the unique
months for that year, then finally all of the unique days for that month.
I'm trying to load a treeview control with the results like so.
Year
|_
Month
|_
Day
Day
Etc.
Year
|_
Month
|_
Day
Etc.
If anyone has any ideas or experience on how to do this I would appreciate
it.
ThanksYou could simply write a query that does a join with a calendar table.
http://www.aspfaq.com/2519
http://www.aspfaq.com/
(Reverse address to reply.)
"MJB" <mb2@.email.com> wrote in message
news:euAyUyLcEHA.2476@.TK2MSFTNGP09.phx.gbl...
> Hello,
>
> I have load dates for each row in my database table. I'm trying to build
a
> query that will give me all of the unique years, then all of the unique
> months for that year, then finally all of the unique days for that month.
>
> I'm trying to load a treeview control with the results like so.
>
> Year
> |_
> Month
> |_
> Day
> Day
> Etc.
> Year
> |_
> Month
> |_
> Day
> Etc.
>
> If anyone has any ideas or experience on how to do this I would appreciate
> it.
>
> Thanks
>|||Hmm, looks like it could help. Unfortunately, I only want my treeview to
show the dates that are actually in the database, where as this approach
seems to just show all dates between a range.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:eSYmS0LcEHA.3480@.TK2MSFTNGP11.phx.gbl...
> You could simply write a query that does a join with a calendar table.
> http://www.aspfaq.com/2519
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "MJB" <mb2@.email.com> wrote in message
> news:euAyUyLcEHA.2476@.TK2MSFTNGP09.phx.gbl...
build[vbcol=seagreen]
> a
month.[vbcol=seagreen]
appreciate[vbcol=seagreen]
>|||Can you show your table structure (see http://www.aspfaq.com/5006)?
http://www.aspfaq.com/
(Reverse address to reply.)
"MJB" <mb2@.email.com> wrote in message
news:#jGPjPMcEHA.3476@.tk2msftngp13.phx.gbl...
> Hmm, looks like it could help. Unfortunately, I only want my treeview to
> show the dates that are actually in the database, where as this approach
> seems to just show all dates between a range.
>
> "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:eSYmS0LcEHA.3480@.TK2MSFTNGP11.phx.gbl...
> build
unique[vbcol=seagreen]
> month.
> appreciate
>|||Well, it's nothing special. It's just a table with a Primary Key with a few
other columns and a LoadDT column that is of type datetime.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:u5DN4RMcEHA.2840@.TK2MSFTNGP11.phx.gbl...
> Can you show your table structure (see http://www.aspfaq.com/5006)?
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "MJB" <mb2@.email.com> wrote in message
> news:#jGPjPMcEHA.3476@.tk2msftngp13.phx.gbl...
to[vbcol=seagreen]
> unique
>

Building SQL Query to fill a treeview control with Year->Month->Day nodes

Hello,
I have load dates for each row in my database table. I'm trying to build a
query that will give me all of the unique years, then all of the unique
months for that year, then finally all of the unique days for that month.
I'm trying to load a treeview control with the results like so.
Year
|_
Month
|_
Day
Day
Etc.
Year
|_
Month
|_
Day
Etc.
If anyone has any ideas or experience on how to do this I would appreciate
it.
Thanks
You could simply write a query that does a join with a calendar table.
http://www.aspfaq.com/2519
http://www.aspfaq.com/
(Reverse address to reply.)
"MJB" <mb2@.email.com> wrote in message
news:euAyUyLcEHA.2476@.TK2MSFTNGP09.phx.gbl...
> Hello,
>
> I have load dates for each row in my database table. I'm trying to build
a
> query that will give me all of the unique years, then all of the unique
> months for that year, then finally all of the unique days for that month.
>
> I'm trying to load a treeview control with the results like so.
>
> Year
> |_
> Month
> |_
> Day
> Day
> Etc.
> Year
> |_
> Month
> |_
> Day
> Etc.
>
> If anyone has any ideas or experience on how to do this I would appreciate
> it.
>
> Thanks
>
|||Hmm, looks like it could help. Unfortunately, I only want my treeview to
show the dates that are actually in the database, where as this approach
seems to just show all dates between a range.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:eSYmS0LcEHA.3480@.TK2MSFTNGP11.phx.gbl...[vbcol=seagreen]
> You could simply write a query that does a join with a calendar table.
> http://www.aspfaq.com/2519
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "MJB" <mb2@.email.com> wrote in message
> news:euAyUyLcEHA.2476@.TK2MSFTNGP09.phx.gbl...
build[vbcol=seagreen]
> a
month.[vbcol=seagreen]
appreciate
>
|||Can you show your table structure (see http://www.aspfaq.com/5006)?
http://www.aspfaq.com/
(Reverse address to reply.)
"MJB" <mb2@.email.com> wrote in message
news:#jGPjPMcEHA.3476@.tk2msftngp13.phx.gbl...[vbcol=seagreen]
> Hmm, looks like it could help. Unfortunately, I only want my treeview to
> show the dates that are actually in the database, where as this approach
> seems to just show all dates between a range.
>
> "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:eSYmS0LcEHA.3480@.TK2MSFTNGP11.phx.gbl...
> build
unique
> month.
> appreciate
>
|||Well, it's nothing special. It's just a table with a Primary Key with a few
other columns and a LoadDT column that is of type datetime.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:u5DN4RMcEHA.2840@.TK2MSFTNGP11.phx.gbl...[vbcol=seagreen]
> Can you show your table structure (see http://www.aspfaq.com/5006)?
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "MJB" <mb2@.email.com> wrote in message
> news:#jGPjPMcEHA.3476@.tk2msftngp13.phx.gbl...
to
> unique
>

Building SQL Query to fill a treeview control with Year->Month->Day nodes

Hello,
I have load dates for each row in my database table. I'm trying to build a
query that will give me all of the unique years, then all of the unique
months for that year, then finally all of the unique days for that month.
I'm trying to load a treeview control with the results like so.
Year
|_
Month
|_
Day
Day
Etc.
Year
|_
Month
|_
Day
Etc.
If anyone has any ideas or experience on how to do this I would appreciate
it.
Thanks
You could simply write a query that does a join with a calendar table.
http://www.aspfaq.com/2519
http://www.aspfaq.com/
(Reverse address to reply.)
"MJB" <mb2@.email.com> wrote in message
news:euAyUyLcEHA.2476@.TK2MSFTNGP09.phx.gbl...
> Hello,
>
> I have load dates for each row in my database table. I'm trying to build
a
> query that will give me all of the unique years, then all of the unique
> months for that year, then finally all of the unique days for that month.
>
> I'm trying to load a treeview control with the results like so.
>
> Year
> |_
> Month
> |_
> Day
> Day
> Etc.
> Year
> |_
> Month
> |_
> Day
> Etc.
>
> If anyone has any ideas or experience on how to do this I would appreciate
> it.
>
> Thanks
>
|||Hmm, looks like it could help. Unfortunately, I only want my treeview to
show the dates that are actually in the database, where as this approach
seems to just show all dates between a range.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:eSYmS0LcEHA.3480@.TK2MSFTNGP11.phx.gbl...[vbcol=seagreen]
> You could simply write a query that does a join with a calendar table.
> http://www.aspfaq.com/2519
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "MJB" <mb2@.email.com> wrote in message
> news:euAyUyLcEHA.2476@.TK2MSFTNGP09.phx.gbl...
build[vbcol=seagreen]
> a
month.[vbcol=seagreen]
appreciate
>
|||Can you show your table structure (see http://www.aspfaq.com/5006)?
http://www.aspfaq.com/
(Reverse address to reply.)
"MJB" <mb2@.email.com> wrote in message
news:#jGPjPMcEHA.3476@.tk2msftngp13.phx.gbl...[vbcol=seagreen]
> Hmm, looks like it could help. Unfortunately, I only want my treeview to
> show the dates that are actually in the database, where as this approach
> seems to just show all dates between a range.
>
> "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:eSYmS0LcEHA.3480@.TK2MSFTNGP11.phx.gbl...
> build
unique
> month.
> appreciate
>
|||Well, it's nothing special. It's just a table with a Primary Key with a few
other columns and a LoadDT column that is of type datetime.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:u5DN4RMcEHA.2840@.TK2MSFTNGP11.phx.gbl...[vbcol=seagreen]
> Can you show your table structure (see http://www.aspfaq.com/5006)?
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "MJB" <mb2@.email.com> wrote in message
> news:#jGPjPMcEHA.3476@.tk2msftngp13.phx.gbl...
to
> unique
>

Building SQL Query to fill a treeview control with Year->Month->Day nodes

Hello,
I have load dates for each row in my database table. I'm trying to build a
query that will give me all of the unique years, then all of the unique
months for that year, then finally all of the unique days for that month.
I'm trying to load a treeview control with the results like so.
Year
|_
Month
|_
Day
Day
Etc.
Year
|_
Month
|_
Day
Etc.
If anyone has any ideas or experience on how to do this I would appreciate
it.
ThanksYou could simply write a query that does a join with a calendar table.
http://www.aspfaq.com/2519
--
http://www.aspfaq.com/
(Reverse address to reply.)
"MJB" <mb2@.email.com> wrote in message
news:euAyUyLcEHA.2476@.TK2MSFTNGP09.phx.gbl...
> Hello,
>
> I have load dates for each row in my database table. I'm trying to build
a
> query that will give me all of the unique years, then all of the unique
> months for that year, then finally all of the unique days for that month.
>
> I'm trying to load a treeview control with the results like so.
>
> Year
> |_
> Month
> |_
> Day
> Day
> Etc.
> Year
> |_
> Month
> |_
> Day
> Etc.
>
> If anyone has any ideas or experience on how to do this I would appreciate
> it.
>
> Thanks
>|||Hmm, looks like it could help. Unfortunately, I only want my treeview to
show the dates that are actually in the database, where as this approach
seems to just show all dates between a range.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:eSYmS0LcEHA.3480@.TK2MSFTNGP11.phx.gbl...
> You could simply write a query that does a join with a calendar table.
> http://www.aspfaq.com/2519
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "MJB" <mb2@.email.com> wrote in message
> news:euAyUyLcEHA.2476@.TK2MSFTNGP09.phx.gbl...
> > Hello,
> >
> >
> >
> > I have load dates for each row in my database table. I'm trying to
build
> a
> > query that will give me all of the unique years, then all of the unique
> > months for that year, then finally all of the unique days for that
month.
> >
> >
> >
> > I'm trying to load a treeview control with the results like so.
> >
> >
> >
> > Year
> >
> > |_
> >
> > Month
> >
> > |_
> >
> > Day
> >
> > Day
> >
> > Etc.
> >
> > Year
> >
> > |_
> >
> > Month
> >
> > |_
> >
> > Day
> >
> > Etc.
> >
> >
> >
> > If anyone has any ideas or experience on how to do this I would
appreciate
> > it.
> >
> >
> >
> > Thanks
> >
> >
>|||Can you show your table structure (see http://www.aspfaq.com/5006)?
--
http://www.aspfaq.com/
(Reverse address to reply.)
"MJB" <mb2@.email.com> wrote in message
news:#jGPjPMcEHA.3476@.tk2msftngp13.phx.gbl...
> Hmm, looks like it could help. Unfortunately, I only want my treeview to
> show the dates that are actually in the database, where as this approach
> seems to just show all dates between a range.
>
> "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> news:eSYmS0LcEHA.3480@.TK2MSFTNGP11.phx.gbl...
> > You could simply write a query that does a join with a calendar table.
> > http://www.aspfaq.com/2519
> >
> > --
> > http://www.aspfaq.com/
> > (Reverse address to reply.)
> >
> >
> >
> >
> > "MJB" <mb2@.email.com> wrote in message
> > news:euAyUyLcEHA.2476@.TK2MSFTNGP09.phx.gbl...
> > > Hello,
> > >
> > >
> > >
> > > I have load dates for each row in my database table. I'm trying to
> build
> > a
> > > query that will give me all of the unique years, then all of the
unique
> > > months for that year, then finally all of the unique days for that
> month.
> > >
> > >
> > >
> > > I'm trying to load a treeview control with the results like so.
> > >
> > >
> > >
> > > Year
> > >
> > > |_
> > >
> > > Month
> > >
> > > |_
> > >
> > > Day
> > >
> > > Day
> > >
> > > Etc.
> > >
> > > Year
> > >
> > > |_
> > >
> > > Month
> > >
> > > |_
> > >
> > > Day
> > >
> > > Etc.
> > >
> > >
> > >
> > > If anyone has any ideas or experience on how to do this I would
> appreciate
> > > it.
> > >
> > >
> > >
> > > Thanks
> > >
> > >
> >
> >
>|||Well, it's nothing special. It's just a table with a Primary Key with a few
other columns and a LoadDT column that is of type datetime.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:u5DN4RMcEHA.2840@.TK2MSFTNGP11.phx.gbl...
> Can you show your table structure (see http://www.aspfaq.com/5006)?
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "MJB" <mb2@.email.com> wrote in message
> news:#jGPjPMcEHA.3476@.tk2msftngp13.phx.gbl...
> > Hmm, looks like it could help. Unfortunately, I only want my treeview
to
> > show the dates that are actually in the database, where as this approach
> > seems to just show all dates between a range.
> >
> >
> > "Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
> > news:eSYmS0LcEHA.3480@.TK2MSFTNGP11.phx.gbl...
> > > You could simply write a query that does a join with a calendar table.
> > > http://www.aspfaq.com/2519
> > >
> > > --
> > > http://www.aspfaq.com/
> > > (Reverse address to reply.)
> > >
> > >
> > >
> > >
> > > "MJB" <mb2@.email.com> wrote in message
> > > news:euAyUyLcEHA.2476@.TK2MSFTNGP09.phx.gbl...
> > > > Hello,
> > > >
> > > >
> > > >
> > > > I have load dates for each row in my database table. I'm trying to
> > build
> > > a
> > > > query that will give me all of the unique years, then all of the
> unique
> > > > months for that year, then finally all of the unique days for that
> > month.
> > > >
> > > >
> > > >
> > > > I'm trying to load a treeview control with the results like so.
> > > >
> > > >
> > > >
> > > > Year
> > > >
> > > > |_
> > > >
> > > > Month
> > > >
> > > > |_
> > > >
> > > > Day
> > > >
> > > > Day
> > > >
> > > > Etc.
> > > >
> > > > Year
> > > >
> > > > |_
> > > >
> > > > Month
> > > >
> > > > |_
> > > >
> > > > Day
> > > >
> > > > Etc.
> > > >
> > > >
> > > >
> > > > If anyone has any ideas or experience on how to do this I would
> > appreciate
> > > > it.
> > > >
> > > >
> > > >
> > > > Thanks
> > > >
> > > >
> > >
> > >
> >
> >
>

Building on MSDE, but deploying in SQL 2000?

I'm new to SQL, so please forgive my rather primitive question...

If I build, for example, the Portal Starter Kit using MSDE, can I upload it to a host that supports SQL 2000 without having to make any special configurations? In other words, are MSDE and SQL 2000 interchangeable, for the most part?

Try these links first is the MSDE deployment toolkit and the second is SQL Server main site, try the first and if you run into problems, then download the evaluation edition it is good for 120 days and you can reinstall it. Hope this helps.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmsde/html/msdedepl.asp
http://www.microsoft.com/sql

|||That does help. Thank you very much! :)|||I am glad I was able to be of assistance.

Building OLAP Cubes

Hi,
In spite of my bad english, i hope you'll understand my question =)
I've to build an olap data cube which contains 3 data table... But i couldnt find any document about it. I've heard Adodb, Adomd and Mdx concepts but i have no idea about tehem, i ll be grateful if you help me...Hello,
hope I understood you well.
a cube has exaclty 1 fact table. You'll have to join the 3 table into one in a proper way.
If you mean, these three tables still have to become dimensions or facts, and you did not get the concepts of dimensions and facts, search for examples in internet, there are plenty.
Hope this helps
Tobias|||I have a similiar problem which i hope someone can help me with.

What i would like to know is how to create a Cube from a programming perspective (not using the various wizards provided)

For a relational database, i create a connection to the database and then execute SQL commands on it using the SqlCommand object. I can then create a table in the database by having the SqlCommand execute "CREATE TABLE ... etc".

For a muli-dim database, i connect to it using a AdomdConnection object. I can then execute MDX commands on it using an AdomdCommand object.
But the MDX syntax doesn't seem to support the creation of Cubes. I can create a local cube or a session cube, but not a cube from scratch.

Am i missing something?
Is there another way of creating cubes?

Monday, February 13, 2012

building models with views

Using data in SS2000 and RS2005. I tried to build a model from a view that I
created. I got the "tables does not have a primary key" error. Do I have to
use indexed views in the model?
--
Dan D.Dan,
You will need to specify a 'logical' primary key in your DSV (Data Source
View)
Bret
"Dan D." wrote:
> Using data in SS2000 and RS2005. I tried to build a model from a view that I
> created. I got the "tables does not have a primary key" error. Do I have to
> use indexed views in the model?
> --
> Dan D.

Building Lists

I have a need to build a list of values that get reported on a line from
multiple records. I've tried the following code:
Dim myList as String
Function AddList(myVal as String) as String
If myList <> "" Then
myList = myList + ", "
End If
myList = myList + myVal
Return myList
End Function
Function ClearList() As String
myList = ""
Return myList
End Function
Function GetList() as String
Return myList
End Function
I put ClearList in the group header, BuildList in the details section, and
GetList in the Group footer. When I run the report, the header is blank, the
detail section I see the string building, but in the footer I get a blank.
Is this an evaluation time issue and is there a way to alter that? Or is
there a better solution in RS?I can solve this in SQL Server using a UDF but am still looking for a
Reporting Services Solution.
UDF:
CREATE FUNCTION SubList (@.valueId as INT)
RETURNS varchar(500)
WITH SCHEMABINDING
AS
BEGIN
DECLARE @.list varchar(500)
SELECT @.list = ISNULL(@.list +', ','') + mySubValue FROM dbo.SubValues WHERE
valueId=@.valueId
RETURN @.list
END
Usage:
SELECT valueId, myValue, dbo.SubList(valueId) AS myList
FROM [Values]

Building KPI in SSAS

Hi,

I am trying to build a Kpi, based on a table like this:

Mounth | Budget

August | 1234€

October | 123€


Having Budget as a Measure and Mounth as Dimension.

i would like to create a Kpi using Analysis Services where, on Value Expression, i would like to point the measure for value of budget in October, and not for the value corresponding to the sum of all budget values.

How should i have the expression?

Thanks.

You can build a calculated member like 'Aggregate({[Due Date].[CalendarYearDate].Currentmember},[Measures].[Bud Amount]).

After that you can build a second calculated member like 'Aggregate([Due Date].[CalendarYearDate].[Month].&Music&[2004],[Measures].[Bud Amount])

My examples use a time dimension-hiearchy from Adventure Works.

For the second one I do not now if you will use a special october like october 2005.

In a third calculated member you divide these two measures and use that calculated measure as a value expression in the KPI editor.

Regards

Thomas Ivarsson

|||

Hello Maia,

You can define the value expression for the KPI like this: ([Measures].[Budget - YourFactTable],[Mounth].[Mounth].&[10])

assuming that &[10] is the key of October in your Mounth dimension table.

Hope this helps,

Artur

|||

Artur you have been a fantastic help. It worked.

Regards.

Maia

Sunday, February 12, 2012

Building cube with more than one datasources

How to build a cube with multiple datasources in case we have two separate databases? Is it possible to a build a cube with more than one dataview or datasources ?Yes its possible.

You could create multiple datasources and then add the tables to one or more datasourceviews.
You cold then built a cube based on this scenario.

Hannes

Building an SQL statement in a Stored Procedure

Hi everybody!!
The title says it all!!!
Joking aside, I need to build an SQL statement by concatenating fields and
parameters and if conditions and then execute that sql statement within the
same SP.
Is this possible, and if yes, how exactly?
Thanks,
IvanA lot of text, but I strongly encourage you to do the reading so you can mak
e an informed decision:
http://www.sommarskog.se/dyn-search.html
http://www.sommarskog.se/dynamic_sql.html
Home page: http://www.sommarskog.se/
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Ivan Debono" <ivanmdeb@.hotmail.com> wrote in message news:eGYyPVBlFHA.4012@.TK2MSFTNGP10.ph
x.gbl...
> Hi everybody!!
> The title says it all!!!
> Joking aside, I need to build an SQL statement by concatenating fields and
> parameters and if conditions and then execute that sql statement within th
e
> same SP.
> Is this possible, and if yes, how exactly?
> Thanks,
> Ivan
>|||I managed to build a string but I need to use it in a sub select. It doesn't
work.
I think the problem is because it apends a ' at the beginning and at the
end.
Is there a way to solve it?
Thanks,
Ivan
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> schrieb
im Newsbeitrag news:eIsEccBlFHA.1968@.TK2MSFTNGP14.phx.gbl...
> A lot of text, but I strongly encourage you to do the reading so you can
make an informed decision:
> http://www.sommarskog.se/dyn-search.html
> http://www.sommarskog.se/dynamic_sql.html
> Home page: http://www.sommarskog.se/
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Ivan Debono" <ivanmdeb@.hotmail.com> wrote in message
news:eGYyPVBlFHA.4012@.TK2MSFTNGP10.phx.gbl...
and
the|||You need to execute the whole query, like:
SET @.sql = 'SELECT ... FROM ... WHERE ... IN (SELECT... ...) ... '
And then do a PRINT of the @.sql variable before executing it so you can see
what the problem is. And
do read those articles if you haven't already.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Ivan Debono" <ivanmdeb@.hotmail.com> wrote in message news:OmJbYtBlFHA.1148@.TK2MSFTNGP12.ph
x.gbl...
>I managed to build a string but I need to use it in a sub select. It doesn'
t
> work.
> I think the problem is because it apends a ' at the beginning and at the
> end.
> Is there a way to solve it?
> Thanks,
> Ivan
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> schrieb
> im Newsbeitrag news:eIsEccBlFHA.1968@.TK2MSFTNGP14.phx.gbl...
> make an informed decision:
> news:eGYyPVBlFHA.4012@.TK2MSFTNGP10.phx.gbl...
> and
> the
>|||Print your query and test it in QA before attempting to execute it. That muc
h
I can say without seeing your script.
ML|||Look up coupling and cohesion in a book on basic software engineering.
That will tell you in detail why this is a very, very poor programming
pratice that good programmers would never use.|||Could you post an example of a document explaining this? Telling other peopl
e
to go find things that are basic to you is good for your ego but useless for
anything else. You won't convince a development team to do things right by
telling them how stupid they are.
Jerry
"--CELKO--" wrote:

> Look up coupling and cohesion in a book on basic software engineering.
> That will tell you in detail why this is a very, very poor programming
> pratice that good programmers would never use.
>

building an .asdatabase file from the command line

Hi,

I was wondering if anyone knew how to 'build' an 'analysis services' project (i.e - generate the .asdatabase file) from the command line, so that I could have it done automatically during a build process.

Thanks,
Kobi Reiter

Play around with the devenv.exe executable at the command-line. Although I have not tried it, you might be able to use it with your project file and with a "/build" option. The executable is the what launches when you run BI Dev Studio. Typical setup has it located at:

"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"

Dave Fackler

|||

Unfortunately, when I try to run devenv with the /build switch, it fails:

Package 'Visual Studio Source Control Integration Package' failed to load.
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

|||I'm also interested in this. Need to automate the build of our deployment package. Haven't been able to find any information on this.
|||I am also interested in this topic .... Anyone can contribute any idea(s). Thanks.|||

hello,

i would expect something like the following to work

devenv.exe <your_solution_name>.sln /build Development /Out out.log

Note that you might need an SP1 build for this.

hope this helps,

building an .asdatabase file from the command line

Hi,

I was wondering if anyone knew how to 'build' an 'analysis services' project (i.e - generate the .asdatabase file) from the command line, so that I could have it done automatically during a build process.

Thanks,
Kobi Reiter

Play around with the devenv.exe executable at the command-line. Although I have not tried it, you might be able to use it with your project file and with a "/build" option. The executable is the what launches when you run BI Dev Studio. Typical setup has it located at:

"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"

Dave Fackler

|||

Unfortunately, when I try to run devenv with the /build switch, it fails:

Package 'Visual Studio Source Control Integration Package' failed to load.
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

|||I'm also interested in this. Need to automate the build of our deployment package. Haven't been able to find any information on this.|||I am also interested in this topic .... Anyone can contribute any idea(s). Thanks.|||

hello,

i would expect something like the following to work

devenv.exe <your_solution_name>.sln /build Development /Out out.log

Note that you might need an SP1 build for this.

hope this helps,

building an .asdatabase file from the command line

Hi,

I was wondering if anyone knew how to 'build' an 'analysis services' project (i.e - generate the .asdatabase file) from the command line, so that I could have it done automatically during a build process.

Thanks,
Kobi Reiter

Play around with the devenv.exe executable at the command-line. Although I have not tried it, you might be able to use it with your project file and with a "/build" option. The executable is the what launches when you run BI Dev Studio. Typical setup has it located at:

"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"

Dave Fackler

|||

Unfortunately, when I try to run devenv with the /build switch, it fails:

Package 'Visual Studio Source Control Integration Package' failed to load.
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

|||I'm also interested in this. Need to automate the build of our deployment package. Haven't been able to find any information on this.
|||I am also interested in this topic .... Anyone can contribute any idea(s). Thanks.|||

hello,

i would expect something like the following to work

devenv.exe <your_solution_name>.sln /build Development /Out out.log

Note that you might need an SP1 build for this.

hope this helps,

Building A View with a default value for left join between two tables

Good Day;
I'm certain there must be a simple solution for this but I've yet to
find it. I wish to build a view between two tables that have a one to
many relationship using a left join to ensure all the records from the
many table are selected. However when the one table doesn't have an
join I'd like the view to exhibit a default value i.e., "Other" The
following are some sample tables and both the simple view and the
currently unattainable but desired view. If anyone could provide some
assistance it would be appreciated.
Table 1
Key Ext Key
1 50K
2 73J
3 75K
4 60A
Table 2
Key Value
50K ABC
60A DEF
75K GHI
Current Join on SMC
Key ExtKey Value
1 50K ABC
2 73J (null)
3 75K GHI
4 60A DEF
Desired Join result
Key ExtKey Value
1 50K ABC
2 73J Other
3 75K GHI
4 60A DEF
I've also tried updating the view but that didn't work for me either.
TIA
BillBill wrote:
> Good Day;
> I'm certain there must be a simple solution for this but I've yet to
> find it. I wish to build a view between two tables that have a one to
> many relationship using a left join to ensure all the records from the
> many table are selected. However when the one table doesn't have an
> join I'd like the view to exhibit a default value i.e., "Other" The
> following are some sample tables and both the simple view and the
> currently unattainable but desired view. If anyone could provide some
> assistance it would be appreciated.
> Table 1
> Key Ext Key
> 1 50K
> 2 73J
> 3 75K
> 4 60A
> Table 2
> Key Value
> 50K ABC
> 60A DEF
> 75K GHI
>
> Current Join on SMC
> Key ExtKey Value
> 1 50K ABC
> 2 73J (null)
> 3 75K GHI
> 4 60A DEF
> Desired Join result
> Key ExtKey Value
> 1 50K ABC
> 2 73J Other
> 3 75K GHI
> 4 60A DEF
> I've also tried updating the view but that didn't work for me either.
> TIA
> Bill
create table #a (col1 int)
create table #b (col1 int)
insert into #a values (1)
insert into #a values (2)
insert into #a values (3)
insert into #b values (1)
insert into #b values (3)
Select a.col1, ISNULL(b.col1, 99) as col1
From #a a
left outer join #b b
on a.col1 = b.col1
col1 col1
-- --
1 1
2 99
3 3
--
David Gugick
Imceda Software
www.imceda.com|||"David Gugick" <davidg-nospam@.imceda.com> wrote in message news:<Or1hHe9DFHA.464@.TK2MSFTNGP15.phx.gbl>...
> Select a.col1, ISNULL(b.col1, 99) as col1
David;
Thank you. That worked. Isn't it easy when you know the magic words.
Cheers;
Bill