Monday, April 21, 2008

SQL server 2005 - generate scripts. Can i do this faster?

i am preparing scripts from DEV server, to an other environment.
step 1. script all the objects (drop script)
- 1.1. right click on tasks > select "Generate script"
- 1.2. select database click next
- 1.3. script behaviour: "Generate DROP statements only." also select
false for all the table/view options from bottom side, click Next
- 1.4. select stored procedures, user defined functions, views (this
way i won't forget any of them ... might have been modified by other
developer). click next
- 1.5. click "Select All", then Next (sps)
- 1.6. click "Select All", then Next (func)
- 1.7. click "Select All", then Next (views)
- 1.8. select script to file (any other option would be ok), change
file name to "drop scripts.sql" ? (doesn't matter) and click next
- 1.9. click finish
- 1.10 WAIT a LOT :)
then comes step 2 (2.1 - 2.10) with the only difference that at step
2.3. i'll select "Generate CREATE statements only."

i'll have 2 scripts.
in sql 2000 it was easier.

and now, the question:
can i make this somehow faster?
is there a script I could run and have the same result ...
or is there at least a way to have drop AND create-s generate all in
the same time?

I'll post an answer when i find a good one.

If you can help, just comment here pls.


Wednesday, April 16, 2008

GridView Id column

If I make a "BoundColumn" for the Id, with visible - false, I can't get the Id ...

This one works:

e.Row.Cells["mycolumn"].Style.Add("display", "none");

this way the Id is still there, you just cannot see it...

Gridview rowcount from Js

I needed to get some rowcont in a Js variable, to have a google-like "select all" (all from all pages) button, that i didn't want to show up if there is only one page in my gridview.

Radu helped me out with this idea:
(I am using this on rowDataBound, because I didn't want to use an other event, I already had this one ...)

ScriptManager.RegisterClientScriptBlock(grvAgentCommissionFeePercentage, this.GetType(), "ScriptIDAndTicksForRefreshnumber" + DateTime.Now.Ticks.ToString(), "multiplePages = " + grvAgentCommissionFeePercentage.PageCount.ToString() + ";", true);

if you need the whole nine yards, just comment ... i'll get back to you

Thursday, April 10, 2008

Programming Languages and their Celebrity Equivalents

I found this "article" and i think it is very funny

click here

Friday, April 4, 2008

Could not load file or assembly AjaxControlToolkit

I had this error today, after I installed my app on a server (wix installer btw)

what did i do?
googled :)
and then ...

delete all the data from
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\"my prj"\

and reinstalled the app

it worked

Thursday, April 3, 2008

Javascript - properties for any HTML object

Sometimes you need to see what properties can you use for any given object.
Just copy-paste this:

var stuff = '';
for (p in document.Form1.elements)
stuff = stuff + ' ' + p;

( ... and replace the document.form1.elements with anything you'd like. For example document.body, or document.getElementById("someTDfromYourTable"), etc. ...)

Try-catch in SQL

Ever wanted Try-catch in SQL?
Here's your chance!
2005 only

SELECT convert(smallint, '2003121')
select 'errno: ' + ltrim(str(error_number()))
select 'errmsg: ' + error_message()

SQL Cursor Sample

I need this piece of code pretty often
A clean, almost empty, sql cursor example
Would be a lot better if you'd have a query, select it, right click, and "surround with: cursor" :)
But cannot be done just yet


DECLARE cursorServProvDefServ CURSOR FOR
SELECT Company
FROM Company

OPEN cursorServProvDefServ
FETCH NEXT FROM cursorServProvDefServ INTO @CPilot


FETCH NEXT FROM cursorServProvDefServ INTO @CPilot
END --while @@FETCH_STATUS = 0
CLOSE cursorServProvDefServ

DEALLOCATE cursorServProvDefServ