- Q What is recursive stored procedure?
- Q Why would i need short-term health insurance?
- Q Which statements are true regarding classless routing protocols? Select two. A. The use of discontiguous subnets is not allowed B. The use of variable length subnet masks is permitted C. RIP v1 is a classless routing protocol D. IGRP supports classless routing within the same autonomous system E. RIP v2 supports classless routing
- Q Explain what is port? what is http port, ftp port, telnet port and others?
- Q The oldest European fort in India was built by:
- Q Which prehistoric period followed the Stone Age and preceded the Iron Age?
- Q My program's prompts and intermediate output don't always show up on the screen.
- Q How can i create prompts in report net
- Q What effect does fascicle arrangement have on a muscle's action?
- Q During photo-synthesis electric energy is converted into
- Q What is Subsidiary Ledgers
Question
How do I determine if a column exists in a given table?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
Answers
In Access, we can take one of our existing schema extractors and modify it slightly:
<%
columnToFind = "foo"
dbname = "/path_to.mdb"
tablename = "tablename"
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;data source="
ConnStr = ConnStr & server.mappath(dbname)
set adoxConn = Server.CreateObject("ADOX.Catalog")
set adodbConn = Server.CreateObject("ADODB.Connection")
adodbConn.open ConnStr
adoxConn.activeConnection = adodbConn
set table = adoxConn.Tables(tablename)
found = false
for each col in table.columns
if lcase(col.name) = lcase(columnToFind) then
found = true
exit for
end if
next
set table = nothing
adodbConn.close: set adodbConn = nothing
set adoxConn = nothing
if found then
response.write("Column exists.")
else
response.write("Column does not exist.")
end if
%>
In SQL Server, you can use a much more direct approach:
<%
columnToFind = "foo"
dbname = "dbname"
tablename = "tablename"
connStr = "Provider=SQLOLEDB;Server=x.x.x.x;Database=" & _
dbname & ";UID=username;PWD=password"
set conn = Server.CreateObject("ADODB.Connection")
conn.open connStr
SQL = "SELECT COALESCE(COL_LENGTH('" & tablename & "'," & _
"'" & columnToFind & "'),0)"
set rs = conn.execute(sql)
if clng(rs(0))>0 then
response.write("Column exists.")
else
response.write("Column does not exist.")
end if
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
Your Comment
<%
columnToFind = "foo"
dbname = "/path_to.mdb"
tablename = "tablename"
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;data source="
ConnStr = ConnStr & server.mappath(dbname)
set adoxConn = Server.CreateObject("ADOX.Catalog")
set adodbConn = Server.CreateObject("ADODB.Connection")
adodbConn.open ConnStr
adoxConn.activeConnection = adodbConn
set table = adoxConn.Tables(tablename)
found = false
for each col in table.columns
if lcase(col.name) = lcase(columnToFind) then
found = true
exit for
end if
next
set table = nothing
adodbConn.close: set adodbConn = nothing
set adoxConn = nothing
if found then
response.write("Column exists.")
else
response.write("Column does not exist.")
end if
%>
In SQL Server, you can use a much more direct approach:
<%
columnToFind = "foo"
dbname = "dbname"
tablename = "tablename"
connStr = "Provider=SQLOLEDB;Server=x.x.x.x;Database=" & _
dbname & ";UID=username;PWD=password"
set conn = Server.CreateObject("ADODB.Connection")
conn.open connStr
SQL = "SELECT COALESCE(COL_LENGTH('" & tablename & "'," & _
"'" & columnToFind & "'),0)"
set rs = conn.execute(sql)
if clng(rs(0))>0 then
response.write("Column exists.")
else
response.write("Column does not exist.")
end if
rs.close: set rs = nothing
conn.close: set conn = nothing
%>
Your Comment
- 0
- 0
- New Answer
- Contributors: *,
More Software Questions..
What is the inputsplit in map reduce software?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What is software configuration management?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What Is Java Api For Xml-based Rpc (jax-rpc)?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
How can you implement fine-grained auditing?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What is IBM’s simple explanation for Big Data’s four critical features?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What is static synchronized method in JDBC API? Give an example?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What does the NULLIF function do?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What happens if a start method is not invoked and the run method is directly invoked?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
Should we override finalize method
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
what is the difference between mysql_fetch_array and mysql_fetch_object?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
How will XML affect my document links?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
Why to use Style Sheets?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What are Filters in MVC?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
Can you explain Application layer in OSI model?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
How to define new testplan attributes?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What are the minimum system requirements to run Photoshop? Is it possible to run Photoshop over linux?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
Which oracle package is used to manage the oracle lock management services?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What is Latch Up? Explain Latch Up with cross section of a CMOS Inverter. How do you avoid Latch Up?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What is marker interface?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What types of partitioning are there for BW?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,